Forum Discussion
Work Space Register - Query Shutdown-Start-VMs-By-Resource-Group Errors
- May 13, 2019
you can check your runbook status with
AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" | summarize count() by ResultType
You then probably want to alter this to just look at "Failed" and maybe the specific runbook name?
AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed" or ResultType == "Stopped" or ResultType == "Suspended" or ResultType == "Pending" or ResultType == "Started") | project TimeGenerated , RunbookName_s , ResultType , Resource
So for use in an Azure Monitor Alert it would be something like this:
AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed") // and RunbookName_s == "Shutdown-Start-VMs-By-Resource-Group" | summarize count() by ResultType
You can force a value to be 0 or 1 by changing the last line to
AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed") // and RunbookName_s == "Shutdown-Start-VMs-By-Resource-Group" | summarize count() by ResultType | where count_ > 1 // put in your own threshold here | extend AggregatedValue = 1 // set this to One/1 if the threshold is breached
you can check your runbook status with
AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" | summarize count() by ResultType
You then probably want to alter this to just look at "Failed" and maybe the specific runbook name?
AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed" or ResultType == "Stopped" or ResultType == "Suspended" or ResultType == "Pending" or ResultType == "Started") | project TimeGenerated , RunbookName_s , ResultType , Resource
So for use in an Azure Monitor Alert it would be something like this:
AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed") // and RunbookName_s == "Shutdown-Start-VMs-By-Resource-Group" | summarize count() by ResultType
You can force a value to be 0 or 1 by changing the last line to
AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed") // and RunbookName_s == "Shutdown-Start-VMs-By-Resource-Group" | summarize count() by ResultType | where count_ > 1 // put in your own threshold here | extend AggregatedValue = 1 // set this to One/1 if the threshold is breached
CliveWatson thank´s for your answer . I verify and send the comments later.
- alejandro_contrerasMay 14, 2019Copper Contributor
@Clive Watson The query´s they work perfect , but in the Registre of Work Space only show me last day. I modify the time range for last 7 seven days but not function. For solution i need show me more days in the query´s.