Forum Discussion
JanLD8850
Jun 20, 2024Copper Contributor
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 lo...
Gonzalo
Jul 02, 2024Copper 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
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
Jul 02, 2024Copper 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
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