Customizing Azure Monitor DataSources

Last updated on 18 October, 2023

LogicMonitor DataSources that use the ‘Azure Monitor’ collection method can be customized to collect additional metrics, different aggregation methods, or metrics with specific dimensions. The JSON path field in each datapoint controls which parameters get passed by LogicMonitor’s Cloud Collector into the Azure Monitor API request. 

Prerequisites

Customizing the LogicMonitor Datapoint Definition

To add dimensions to a new or an existing DataSource, complete the following steps:

1. Navigate to Settings > LogicModules > DataSources and search for the Azure API Management DataSource.

2. Click Add DataPoint.

3. Select the Normal datapoint option.

4. Enter the datapoint name and add the dimension parameter in the JSON path field.

The JSON path has a predictable format, with three possible values delimited by ‘.’:

metricName.aggregation.dimension

Where,

  •  metricName is the name of the Azure Monitor metric
  • aggregation is the (optional) desired aggregation

Note: ##primaryAggregation## can be used to dynamically pass in the Azure supported aggregation, as not all aggregations are supported for all metrics at all times. There are several tokens that you can use here. For a complete list of the supported tokens, see Tokens Available for Data Collection.

  • dimension is the (optional) desired dimension to filter the metric by in the following format:

    dimensionName:dimensionValue
  1. Select the desired metric from the list of the supported metrics in Azure Monitor for the resource. For example, select the Requests metric available in the resource Microsoft.ApiManagement/service.
  2. Select one of the dimensions available for the metric from the list, such as the GatewayResponseCode dimension, which provides the count of responses from the gateway based on the HTTP response code (e.g, 200 for HTTP OK response).

    Enter the following syntax in the JSON path for the new metric:
   Requests.##primaryaggregation##.GatewayResponseCode:200

The aggregation type available for the Requests metric is Total. So, the aggregation type Total will replace the token ##primaryaggregation## in the expression and give you the count of successful responses from the gateway.

  1. Click Save to save the metric definition.
  1. Click Save to save the updated DataSource.

Dimensions in Metrics

Simple metric data such as request count does not provide sufficient context for the collected values. Dimensions are name-value pairs that carry supplementary data to describe the metric value. 

For example, an Azure API Management service metric – FailedRequests supports the dimension Location. So with the Location dimension, you can view the failed requests across all the locations or for an individual location.

The Azure API Management (APIM) service is a hybrid,multi-cloud management platform for APIs across all environments. Azure Monitor provides several useful multi-dimensional metrics for the Azure API Management service. 

Azure Multi-Dimensional DataSources

You can customize the Azure DataSources if you cannot find the desired metrics via LogicMonitor’s Azure Monitor coverage and LogicMonitor’s Collector. Some of the ways you can customize Azure Monitor DataSources include:

  • Adding or modifying dimensions for the metrics collected: You can easily add the dimensions to the metric paths for existing DataSource definitions. In some cases, where dimension values are dynamic and not static, an Active Discovery method is the most efficient way to “discover” the dimension values as instances and monitor the associated metrics. For more information, see What is Active Discovery?

Adding Azure Multi-Dimensional Datasources

To add dimensions to the Azure DataSources, complete the following:

1. Navigate to Settings > DataSources > Add > DataSource. For more information, see Creating a DataSource.

2. Enable the Multi-instance checkbox.

3. Enable the Active Discovery checkbox.

4. In the Discovery method field, select AZURE DIMENSIONS from the drop-down list.

5. Enter the required Dimension Name.

6. Click Add DataPoint.

7. On the Add Datapoint page, select Normal Datapoint.

8. Enter the details in the Name and JSON path fields.

The syntax for the JSON path is:

metricName.aggregation.dimensionName:##WILDVALUE##

Where 

  • metricName is the name of the Azure Monitor metric
  • aggregation is the (optional) desired aggregation

Example 

The following example illustrates how to create a multi-dimensional DataSource using the Active Discovery method. 


For example: If you are creating a multi-dimensional Microsoft_Azure_VirtualNetwork DataSource, you must select Azure Dimensions in the Discovery Method field and add the required dimension name in the Dimension Name field. 

So, for the Microsoft_Azure_VirtualNetwork DataSource example, you will enter RemoteIP in the Dimension Name field.

You can add all the required Datapoints related to the RemoteIP dimension. So with Azure Dimension, you can collect information for all the metrics grouped under a single dimension.

Note: For editing the JSON paths for datapoints that are using the Active Discovery method, a standard JSON path is followed for Azure Dimensions in LogicMonitor:


BgpPeerStatus.##primaryaggregation##.BgpPeerAddress:##WILDVALUE##

Note: You can also collect information for a single metric, add the <metric name> in the Metric Name field to collect information for the required metric.

Creating an Azure API Management Instance

To create an instance, complete the following steps:

  1. To  create an Azure API Management instance, run the following Azure CLI commands:
  az group create --name apim-rg --location centralus

  az apim create --name lm-apim --resource-group apim-rg \
     --publisher-name LM --publisher-email [email protected] \
     --no-wait

Note: The Azure quickstart guide describes several other alternatives for creating an APIM instance such as the management portal, PowerShell, and ARM template.

  1. Wait for 30 to 40 minutes to allow the Azure API Management service to be created and activated. Use the following command to record the current status of the API:
  az apim show --name lm-apim --resource-group apim-rg --output table

  1. On the Azure management portal, select the API Management service that you just created. You will find the Echo API, which is created by default when you create a new Azure API Management instance.

Note: You can use the Echo API to test the metrics.

Once you have created an instance, you can configure the APIM DataSource in LogicMonitor to ingest a multi-dimensional metric. 

Inspecting the Metric

Now that you have an API Management instance and LogicMonitor recording the metrics, let’s generate some metrics from the API Management service.

1. On the API Management service, navigate to APIs > Echo API. Click Retrieve resource GET endpoint and click on the Test tab.

2. Use the integrated test console to send a few HTTP requests to the service.

3. In LogicMonitor, navigate to the Resources page, and select your API Management resource.

4. Click on the Raw Data tab where you will find the new metric and the aggregated values.

5. To view the request that LogicMonitor made to fetch the value of the new metric, click Poll Now and scroll to the Raw Request/Response section.

You will find the API request from LogicMonitor and the response from Azure Monitor as displayed in the following image:

In This Article