Filtering and splitting are disabled for custom metrics in metric explorer

Jonathan Sanders 20 Reputation points
2025-03-11T14:21:29.71+00:00

I am sending a custom metric 'numUsed' every minute from an App Service application which tells me the number of open database connections I have. The numUsed appears in the metrics explorer of the application insights instance, but the options to 'filter' or 'split' are greyed out. I need to be able to split the numUsed by the instance id (which is also labelled COMPUTERNAME in the App Service env vars), as I have multiple instances which each manage their own connection pool.

I have tried adding 'computerName' as a common property on the Application Insights client. I can see this appears as a custom dimension on this numUsed when I view this metric in the log tables. From there, I can use a KQL query and a chart to visualise my numUsed split by instance id, but I don't see why I can't do this in the metrics explorer.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,502 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 29,701 Reputation points MVP
    2025-03-11T16:47:27.1+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    The reason why filtering and splitting are disabled for your custom metric (numUsed) in Azure Metrics Explorer is likely due to how custom metrics are structured and ingested into Application Insights. Here’s what’s happening and how to resolve it:

    Understanding Why Filtering/Splitting is Disabled

    Custom Metrics in Metrics Explorer Need Dimensions

    • Azure Metrics Explorer supports filtering and splitting only if the custom metric is ingested with dimensions at the time of tracking.
      • A custom dimension (like computerName) added via TelemetryClient.Context.Properties is only available in Log Analytics, not as a native metric dimension.
      Common Properties vs. Metric Dimensions
      - When you add `computerName` as a common property, it does not make it a first-class metric dimension.
      
         - Metrics Explorer can only filter/split on dimensions that were included when tracking the metric.
      

    Solution: Send computerName as a Dimension

    To allow filtering/splitting in Metrics Explorer, you need to send computerName as a dimension when tracking the metric.

    Step 1: Modify How You Send the Metric

    Instead of using TelemetryClient.TrackMetric(name, value), use MetricIdentifier and dimensions.

    Step 2: Validate in Metrics Explorer

    • Wait for 5-10 minutes after deployment.
    • Go to Azure Portal > Application Insights > Metrics Explorer.
    • Select the numUsed metric and check if computerName appears under "Split By".

    Alternative: Use KQL (If You Stick With Logs)

    If you want to continue using KQL, you can achieve similar results with this query:

    customMetrics | where name == "numUsed" | extend instanceId = tostring(customDimensions["computerName"]) | summarize avg(numUsed) by bin(timestamp, 1m), instanceId | render timechart

    Note:

    1. If the metric appears in Log Analytics with computerName but not in Metrics Explorer, it means computerName was not sent as a metric dimension.
    2. Once sent correctly, filtering and splitting in Metrics Explorer should work without needing KQL.

    Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.