0
votes

I'm trying to create an alert for an App Insights custom metric on Azure.

e.g. alert if the "My Metric" metric is greater than 40 for 5 minutes.

According to Custom metrics in Azure Monitor this should be possible.

After they're published to Azure Monitor, you can browse, query, and alert on custom metrics for your Azure resources and applications side by side with the standard metrics emitted by Azure.

I created the metric with this code using the App Insights Python SDK (see Usage).

from applicationinsights import TelemetryClient
tc = TelemetryClient('<YOUR INSTRUMENTATION KEY GOES HERE>')
tc.track_metric('My Metric', 42)
tc.flush()

I can view the custom metric I created. It's the lone blue bar in the screenshot of the Metrics screen in the Azure portal.

Metrics

However, when I click on the New rule alert button on that screen, I'm taken to the Create rule screen but it displays the following error.

Alerts configuration via Metrics not supported if selection includes multiple resources or more than two metric signals. Please modify your selection and try again or create the rule below. Please click to see the list of supported resources.

AFAIK, I'm only using one resource (the App Insights "Dev" resource) and one metric signal (the "My Metric" metric) as you can see from the screenshot.

Any ideas on what I've done wrong or what I'm missing and how I can correct it?

I'm pretty new to Azure so I'm also open to suggestions on others way of alerting on a custom metric.

2

2 Answers

1
votes

Please follow the steps below:

  1. Nav to azure portal -> Monitor -> Metrics -> Add metric. Note that in the dropdown box "METRIC NAMESPACE" -> select azure.applicationinsights under CUSTOM:

enter image description here

  1. Then in the "METRIC" dropdown box, select your custom metric like "my metric", then click the "New alert rule":

enter image description here

  1. In the "create rule" page, under CONDITION section, click the link in the screenshot below, then fill in necessary info and click Done button:

enter image description here

0
votes

Another approach to this is to create Alerts based on Analytics query using Custom log search (see also Create, view, and manage log alerts using Azure Monitor) but I prefer the answer I accepted as it's significantly simpler.