Background:
I have an Automation Account with one Runbook configured.
The runbook initiates a job which is a one PowerShell line that is syntactically wrong on purpose (Write-Hos "Hello error").
The typical result of this runbook running is a job with the following details:
I have one "Diagnostic setting" rule that is forwarding JobLogs, JobStreams, and Metrics to a Log Analytics Workspace.
I am using a system-assigned identity for this setup with no additional configuration to this identity other than enabling it when the automation account was created.
The problem
The ultimate goal is run this built-in query Runbook completed successfully with errors which will list all runbook jobs that are Completed (Job status = "Complete") but the job encountered errors. (To my understanding "Job Streams" refer to the detailed logs generated during the execution of a runbook job. Which is different than the "Job Status")
This is the query details as per Azure built-in Runbook completed successfully with errors query:
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobStreams" and StreamType_s == "Error"
| project TimeGenerated , RunbookName_s , StreamType_s , _ResourceId , ResultDescription , JobId_g
This however, doesn't return any data. After investigating the issue, I think the problem lies with the fact that the "AzureDiagnostics" table which stores this data, simply doesn't have it:
- I don't have any columns for job streams, such as
StreamType_s. - I don't have a value of "JobStreams" for the
Categorycolumn.
I am not sure what am I missing.


Use below
KQLquery that provides the details about the completed runbook job status with errors.Path:
Automation account >> Monitoring >> Logs >> Automation JobsUse below query if you want to retrieve only the job logs with result type as failed.
Refer MSDoc for the relevant information.