Search code examples
azureazure-resource-managerazure-monitoring

Azure monitoring: MetricsAlert vs AlertRules, can't see AlertRules in Monitor


I have an ARM template with these two monitoring types:

  1. Microsoft.Insights/alertrules
  2. microsoft.insights/metricAlerts

The Microsoft.Insights/alertrules looks like this:

{
  "apiVersion": "2014-04-01",
  "name": "[concat('CPUHigh ', parameters('hostingPlanName'))]",
  "type": "Microsoft.Insights/alertrules",
  "location": "[resourceGroup().location]",
  "dependsOn": [
    "[resourceId('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
  ],
  "tags": {
    "[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
    "displayName": "CPUHighAlertRule"
  },
  "properties": {
    "name": "[concat('CPUHigh ', parameters('hostingPlanName'))]",
    "description": "[concat('The average CPU is high across all the instances of ', parameters('hostingPlanName'))]",
    "isEnabled": true,
    "condition": {
      "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
      "dataSource": {
        "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
        "resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
        "metricName": "CpuPercentage"
      },
      "operator": "GreaterThan",
      "threshold": 90,
      "windowSize": "PT15M"
    },
    "action": {
      "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
      "sendToServiceOwners": true,
      "customEmails": []
    }
  }
}

And the microsoft.insights/metricAlerts looks like this

   {
      "type": "microsoft.insights/metricAlerts",
      "apiVersion": "2018-03-01",
      "name": "CreatedThisFromARM",
      "location": "global",
      "properties": {
        "description": "Created this from ARM. Does it show up or not?",
        "severity": 3,
        "enabled": true,
        "scopes": [
          "/subscriptions/4ec6f523-de5f-4e8a-a6e7-45e4f53170df/resourceGroups/AzureResourceGroup4/providers/Microsoft.Web/serverFarms/plantestmonitor"
        ],
        "evaluationFrequency": "PT1M",
        "windowSize": "PT5M",
        "criteria": {
          "allOf": [
            {
              "criterionType": "StaticThresholdCriterion",
              "name": "MemoryFromARM",
              "metricName": "MemoryPercentage",
              "dimensions": [],
              "operator": "GreaterThan",
              "threshold": 90,
              "timeAggregation": "Average"
            }
          ],
          "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
        },
        "actions": []
      }
    }

When I enter my monitor tab I can see microsoft.insights/metricAlerts but not the Microsoft.Insights/alertrules. I would expect to see both. If I go to the Insights (preview) tab under the Monitoring menu of the resource group, I can see both.

I am wrong in my opinion that i should see both types under the Monitor --> Alerts? Or?

Maybe I am not understanding the difference between the two clearly enough (and my google foo hasn't been able to bring me to some doc that describe it for me). Maybe I am misunderstanding the two concepts?


Solution

  • After a while the alertRule is appearing in the classic alerts section that is referred to when entering "Alerts" in monitor. So I can see both from the Monitor. You just have to wait a bit.

    As I can see the "Alerts(Classic) will be retired on August 31st. Use the voluntary migration tool to upgrade to the faster, simpler, and more scalable metric alerts platform", so the classic alerts must be Microsoft.Insights/alertrules. So metricAlerts is the future of Azure monitoring. Please correct me if I am wrong.