Forum Discussion

JanLD8850's avatar
JanLD8850
Copper Contributor
Jun 20, 2024

Azure alert on multipel subscriptions

Hi all,

 

i am not sure if this is the rigt place, but here goes.

 

I am working on creating a monitoring solution, and are trying to create some dynamic alert rules.

I need them to look on a lot of subscriptions, but when use chose scope, you can only chose one subscription.

So i have exported the template and add'ed another subscription in the scopes section, but will it work?

 

This is what the properties section looks like in the template, it is looking on cpu usage over time:

"properties": {
                "description""Dynamic warning on CPU ussage",
                "severity"2,
                "enabled"true,
                "scopes": [
                    "/subscriptions/Sub1",
                    "/subscriptions/Sub2"
                ],
                "evaluationFrequency""PT15M",
                "windowSize""PT1H",
                "criteria": {
                    "allOf": [
                        {
                            "alertSensitivity""High",
                            "failingPeriods": {
                                "numberOfEvaluationPeriods"4,
                                "minFailingPeriodsToAlert"4
                            },
                            "name""Metric1",
                            "metricNamespace""microsoft.compute/virtualmachines",
                            "metricName""Percentage CPU",
                            "operator""GreaterOrLessThan",
                            "timeAggregation""Average",
                            "criterionType""DynamicThresholdCriterion"
                        }
                    ],
                    "odata.type""Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
                },
 
Any input is more than welcome 🙂
 
Regards
Jan L Dam
  • Gonzalo's avatar
    Gonzalo
    Copper Contributor

    Hi JanLD8850 

    That's because metrics has that restriction, alerts through metrics are easier to setup but hard to manage on time, because you'll need several rules which will do the same for different scopes. 

     

    You should take a look to azure monitoring with log analytics workspace, this way you can build your own alert rules through KQL, if you need to monitor cpu for 100 vm's you can setup a single rule for all virtual machines in that directory, or just filtered for the scope you need.

     

    Here's an example:

     

    InsightsMetrics 
    | where Origin == "vm.azm.ms" 
    | where Namespace == "Processor" and Name == "UtilizationPercentage" 
    | summarize CPUPercentageAverage = avg(Val) by bin(TimeGenerated, 15m), Computer, _ResourceId 

     

    Log search alert rules

    And another more complex rule:

     

    {
        let RuleGroupTags = dynamic(['Linux']);
        Perf | where ObjectName == 'Processor' and CounterName == '% Idle Time' and (InstanceName in ('_Total,'total'))
        | extend CpuUtilisation = (100 - CounterValue)   
        | join kind=inner hint.remote=left (arg("").Resources
            | where type =~ 'Microsoft.Compute/virtualMachines'
        | project _ResourceId=tolower(id), tags) on _ResourceId
        | project-away _ResourceId1
        | where  (tostring(tags.monitorRuleGroup) in (RuleGroupTags)) 
    }

     

    Query that filters virtual machines that need to be monitored

    Regards,





     

     



    • JanLD8850's avatar
      JanLD8850
      Copper Contributor
      Gonzalo

      Thank you for your reply.

      I have been using the log search version for a while, but am looking in to creating dynamic rules, in hope of getting an alert when something out of the ordinary is happening on the vm.

      I might not be an error if a cpu is running on 95% for an hour everyday, but if it starts to do it on times where it not usualy does it, i want an alert.

      I have found a workarround, with exporting the alertrule template, updaing the scope in the template and redeploy it, that seems to work but it is a bit of a pain when we deploys new subscriptions.

      Regards JanLD

  • IGcloudops74's avatar
    IGcloudops74
    Copper Contributor
    I Need help FROM YOU ALL, do we give away our AWS and Azure alert and monitor tool away for free FOREVER? 6 months and 5 developers of investment. PLEASE COMMENT AND SAY YES IF INTERESTED ??

    Free Alerts and Monitoring for AWS and Azure FOREVER - Our CloudOps DIY plug it in 5 mins :free_button:platform

    WHAT YOU GET - Cost, outage, availability, high CPU, Low memory, low storage, excessive queue requests for server, and more for mixed resources i.e. RDS, Azure SQL, virtual machines, app services, EC2 etc. :chart_decreasing:

    Get alerts in portal, email, push notifications, mobile. Soon to be Slack and Team and more via web hook :vibration_mode:

    WE ARE THINKING ON GIVING AWAY FREE FOREVER. THOUGHTS. IF YOU COMMENT AND LIKE WE WILL ADD YOU TO THE FREE FIRST ADOPTERS LIST or DM me. :admission_tickets:

Resources