You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have more than one Automation accounts, or workspaces, in the output of the preceding commands, find the *Name*you need to configure and copy the value for *ResourceId*.
44
+
If you have more than one Automation account or workspace in the output of the preceding commands, find the name that you need to configure and copy the value for the resource ID.
45
45
46
-
If you need to find the *Name* of your Automation account, in the Azure portal select your Automation account from the **Automation account** blade and select **All settings**. From the **All settings** blade, under **Account Settings** select **Properties**. In the **Properties** blade, you can note these values.<br> .
46
+
1. In the Azure portal, select your Automation account from the **Automation account** blade and select **All settings**.
47
+
2. From the **All settings** blade, under **Account Settings**, select **Properties**.
48
+
3. In the **Properties** blade, note these values.<br> .
47
49
48
-
## Set up integration with Azure Monitor logs
49
50
50
-
1. On your computer, start **Windows PowerShell** from the **Start** screen.
51
-
2. Run the following PowerShell, and edit the value for the `[your resource id]` and `[resource id of the log analytics workspace]` with the values from the preceding step.
51
+
## Azure Monitor log records
52
+
53
+
Azure Automation diagnostics create two types of records in Azure Monitor logs, tagged as `AzureDiagnostics`. The tables in the next sections are examples of records that Azure Automation generates and the data types that appear in log search results.
54
+
55
+
### Job logs
56
+
57
+
| Property | Description |
58
+
| --- | --- |
59
+
| TimeGenerated |Date and time when the runbook job executed. |
60
+
| RunbookName_s |The name of the runbook. |
61
+
| Caller_s |The caller that initiated the operation. Possible values are either an email address or system for scheduled jobs. |
62
+
| Tenant_g | GUID that identifies the tenant for the caller. |
63
+
| JobId_g |GUID that identifies the runbook job. |
64
+
| ResultType |The status of the runbook job. Possible values are:<br>- New<br>- Created<br>- Started<br>- Stopped<br>- Suspended<br>- Failed<br>- Completed |
65
+
| Category | Classification of the type of data. For Automation, the value is JobLogs. |
66
+
| OperationName | The type of operation performed in Azure. For Automation, the value is Job. |
67
+
| Resource | The name of the Automation account |
68
+
| SourceSystem | System that Azure Monitor logs use to collect the data. The value is always Azure for Azure diagnostics. |
69
+
| ResultDescription |The runbook job result state. Possible values are:<br>- Job is started<br>- Job Failed<br>- Job Completed |
70
+
| CorrelationId |The correlation GUID of the runbook job. |
71
+
| ResourceId |The Azure Automation account resource ID of the runbook. |
72
+
| SubscriptionId | The Azure subscription GUID for the Automation account. |
73
+
| ResourceGroup | The name of the resource group for the Automation account. |
74
+
| ResourceProvider | The resource provider. The value is MICROSOFT.AUTOMATION. |
75
+
| ResourceType | The resource type. The value is AUTOMATIONACCOUNTS. |
76
+
77
+
### Job streams
78
+
| Property | Description |
79
+
| --- | --- |
80
+
| TimeGenerated |Date and time when the runbook job executed. |
81
+
| RunbookName_s |The name of the runbook. |
82
+
| Caller_s |The caller that initiated the operation. Possible values are either an email address or system for scheduled jobs. |
83
+
| StreamType_s |The type of job stream. Possible values are:<br>-Progress<br>- Output<br>- Warning<br>- Error<br>- Debug<br>- Verbose |
84
+
| Tenant_g | GUID that identifies the tenant for the caller. |
85
+
| JobId_g |GUID that identifies the runbook job. |
86
+
| ResultType |The status of the runbook job. Possible values are:<br>- In Progress |
87
+
| Category | Classification of the type of data. For Automation, the value is JobStreams. |
88
+
| OperationName | Type of operation performed in Azure. For Automation, the value is Job. |
89
+
| Resource | The name of the Automation account. |
90
+
| SourceSystem | System that Azure Monitor logs use to collect the data. The value is always Azure for Azure diagnostics. |
91
+
| ResultDescription |Description that includes the output stream from the runbook. |
92
+
| CorrelationId |The correlation GUID of the runbook job. |
93
+
| ResourceId |The Azure Automation account resource ID of the runbook. |
94
+
| SubscriptionId | The Azure subscription GUID for the Automation account. |
95
+
| ResourceGroup | The name of the resource group for the Automation account. |
96
+
| ResourceProvider | The resource provider. The value is MICROSOFT.AUTOMATION. |
97
+
| ResourceType | The resource type. The value is AUTOMATIONACCOUNTS. |
98
+
99
+
## Setting up integration with Azure Monitor logs
100
+
101
+
1. On your computer, start Windows PowerShell from the **Start** screen.
102
+
2. Run the following PowerShell commands, and edit the value for the `[your resource ID]` and `[resource ID of the log analytics workspace]` with the values from the preceding section.
52
103
53
104
```powershell-interactive
54
-
$workspaceId = "[resource id of the log analytics workspace]"
55
-
$automationAccountId = "[resource id of your automation account]"
105
+
$workspaceId = "[resource ID of the log analytics workspace]"
106
+
$automationAccountId = "[resource ID of your Automation account]"
After running this script, it may take an hour before you start to see records in Azure Monitor logs of new JobLogs or JobStreams being written.
111
+
After running this script, it can take an hour before you start to see records in Azure Monitor logs of new `JobLogs` or `JobStreams` being written.
61
112
62
113
To see the logs, run the following query in log analytics log search:
63
114
`AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION"`
64
115
65
116
### Verify configuration
66
117
67
-
To confirm that your Automation account is sending logs to your Log Analytics workspace, check that diagnostics are correctly configured on the Automation account by using the following PowerShell:
118
+
To confirm that your Automation account is sending logs to your Log Analytics workspace, check that diagnostics are correctly configured on the Automation account by using the following PowerShell command.
* Under *Logs*, the value for *Enabled* is *True*.
76
-
* The value of *WorkspaceId* is set to the ResourceId of your Log Analytics workspace.
77
-
78
-
## Azure Monitor log records
124
+
In the output, ensure that:
79
125
80
-
Diagnostics from Azure Automation creates two types of records in Azure Monitor logs and are tagged as **AzureDiagnostics**. The following queries use the upgraded query language to Azure Monitor logs. For information on common queries between legacy query language and the new Azure Kusto query language visit [Legacy to new Azure Kusto Query Language cheat sheet](https://docs.loganalytics.io/docs/Learn/References/Legacy-to-new-to-Azure-Log-Analytics-Language)
81
-
82
-
### Job Logs
83
-
84
-
| Property | Description |
85
-
| --- | --- |
86
-
| TimeGenerated |Date and time when the runbook job executed. |
87
-
| RunbookName_s |The name of the runbook. |
88
-
| Caller_s |Who initiated the operation. Possible values are either an email address or system for scheduled jobs. |
89
-
| Tenant_g | GUID that identifies the tenant for the Caller. |
90
-
| JobId_g |GUID that is the Id of the runbook job. |
91
-
| ResultType |The status of the runbook job. Possible values are:<br>- New<br>- Created<br>- Started<br>- Stopped<br>- Suspended<br>- Failed<br>- Completed |
92
-
| Category | Classification of the type of data. For Automation, the value is JobLogs. |
93
-
| OperationName | Specifies the type of operation performed in Azure. For Automation, the value is Job. |
94
-
| Resource | Name of the Automation account |
95
-
| SourceSystem | How Azure Monitor logs collected the data. Always *Azure* for Azure diagnostics. |
96
-
| ResultDescription |Describes the runbook job result state. Possible values are:<br>- Job is started<br>- Job Failed<br>- Job Completed |
97
-
| CorrelationId |GUID that is the Correlation Id of the runbook job. |
98
-
| ResourceId |Specifies the Azure Automation account resource id of the runbook. |
99
-
| SubscriptionId | The Azure subscription Id (GUID) for the Automation account. |
100
-
| ResourceGroup | Name of the resource group for the Automation account. |
101
-
| ResourceProvider | MICROSOFT.AUTOMATION |
102
-
| ResourceType | AUTOMATIONACCOUNTS |
103
-
104
-
105
-
### Job Streams
106
-
| Property | Description |
107
-
| --- | --- |
108
-
| TimeGenerated |Date and time when the runbook job executed. |
109
-
| RunbookName_s |The name of the runbook. |
110
-
| Caller_s |Who initiated the operation. Possible values are either an email address or system for scheduled jobs. |
111
-
| StreamType_s |The type of job stream. Possible values are:<br>-Progress<br>- Output<br>- Warning<br>- Error<br>- Debug<br>- Verbose |
112
-
| Tenant_g | GUID that identifies the tenant for the Caller. |
113
-
| JobId_g |GUID that is the Id of the runbook job. |
114
-
| ResultType |The status of the runbook job. Possible values are:<br>- In Progress |
115
-
| Category | Classification of the type of data. For Automation, the value is JobStreams. |
116
-
| OperationName | Specifies the type of operation performed in Azure. For Automation, the value is Job. |
117
-
| Resource | Name of the Automation account |
118
-
| SourceSystem | How Azure Monitor logs collected the data. Always *Azure* for Azure diagnostics. |
119
-
| ResultDescription |Includes the output stream from the runbook. |
120
-
| CorrelationId |GUID that is the Correlation Id of the runbook job. |
121
-
| ResourceId |Specifies the Azure Automation account resource id of the runbook. |
122
-
| SubscriptionId | The Azure subscription Id (GUID) for the Automation account. |
123
-
| ResourceGroup | Name of the resource group for the Automation account. |
124
-
| ResourceProvider | MICROSOFT.AUTOMATION |
125
-
| ResourceType | AUTOMATIONACCOUNTS |
126
+
* Under `Logs`, the value for `Enabled` is True.
127
+
*`WorkspaceId` is set to the `ResourceId` value for your Log Analytics workspace.
126
128
127
129
## Viewing Automation Logs in Azure Monitor logs
128
130
129
-
Now that you started sending your Automation job logs to Azure Monitor logs, let’s see what you can do with these logs inside Azure Monitor logs.
131
+
Now that you started sending your Automation job logs to Azure Monitor logs, let's see what you can do with these logs inside Azure Monitor logs.
130
132
131
133
To see the logs, run the following query:
132
134
`AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION"`
133
135
134
136
### Send an email when a runbook job fails or suspends
137
+
135
138
One of the top customer asks is for the ability to send an email or a text when something goes wrong with a runbook job.
136
139
137
-
To create an alert rule, you start by creating a log search for the runbook job records that should invoke the alert. Click the **Alert** button to create and configure the alert rule.
140
+
To create an alert rule, start by creating a log search for the runbook job records that should invoke the alert. Click the **Alert** button to create and configure the alert rule.
138
141
139
142
1. From the Log Analytics workspace Overview page, click **View logs**.
140
-
2. Create a log search query for your alert by typing the following search into the query field: `AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed" or ResultType == "Suspended")`You can also group by the RunbookName by using: `AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed" or ResultType == "Suspended") | summarize AggregatedValue = count() by RunbookName_s`
143
+
2. Create a log search query for your alert by typing the following search into the query field: `AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed" or ResultType == "Suspended")`<br><br>You can also group by the runbook name by using: `AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and (ResultType == "Failed" or ResultType == "Suspended") | summarize AggregatedValue = count() by RunbookName_s`
141
144
142
-
If you set up logs from more than one Automation account or subscription to your workspace, you can group your alerts by subscription and Automation account. Automation account name can be found in the Resource field in the search of JobLogs.
145
+
If you set up logs from more than one Automation account or subscription to your workspace, you can group your alerts by subscription and Automation account. Automation account name can be found in the `Resource` field in the search of `JobLogs`.
143
146
3. To open the **Create rule** screen, click **+ New Alert Rule** at the top of the page. For more information on the options to configure the alert, see [Log alerts in Azure](../azure-monitor/platform/alerts-unified-log.md).
144
147
145
148
### Find all jobs that have completed with errors
146
-
In addition to alerting on failures, you can find when a runbook job has a non-terminating error. In these cases PowerShell produces an error stream, but the non-terminating errors don't cause your job to suspend or fail.
149
+
150
+
In addition to alerting on failures, you can find when a runbook job has a non-terminating error. In these cases, PowerShell produces an error stream, but the non-terminating errors don't cause your job to suspend or fail.
147
151
148
152
1. In your Log Analytics workspace, click **Logs**.
149
-
2. In the query field, type `AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobStreams" and StreamType_s == "Error" | summarize AggregatedValue = count() by JobId_g` and then click the **Search** button.
153
+
2. In the query field, type `AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobStreams" and StreamType_s == "Error" | summarize AggregatedValue = count() by JobId_g`.
154
+
3. Click the **Search** button.
150
155
151
156
### View job streams for a job
152
-
When you're debugging a job, you may also want to look into the job streams. The following query shows all the streams for a single job with GUID 2ebd22ea-e05e-4eb9-9d76-d73cbd4356e0:
157
+
158
+
When you're debugging a job, you might also want to look into the job streams. The following query shows all the streams for a single job with GUID 2ebd22ea-e05e-4eb9-9d76-d73cbd4356e0:
153
159
154
160
`AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobStreams" and JobId_g == "2ebd22ea-e05e-4eb9-9d76-d73cbd4356e0" | sort by TimeGenerated asc | project ResultDescription`
155
161
156
162
### View historical job status
157
-
Finally, you may want to visualize your job history over time. You can use this query to search for the status of your jobs over time.
163
+
164
+
Finally, you might want to visualize your job history over time. You can use this query to search for the status of your jobs over time.
158
165
159
166
`AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and ResultType != "started" | summarize AggregatedValue = count() by ResultType, bin(TimeGenerated, 1h)`
160
167
<br> <br>
161
168
162
-
## Remove diagnostic settings
169
+
## Removing diagnostic settings
163
170
164
-
To remove the diagnostic setting from the Automation Account, run the following commands:
171
+
To remove the diagnostic setting from the Automation account, run the following command:
165
172
166
173
```powershell-interactive
167
-
$automationAccountId = "[resource id of your automation account]"
174
+
$automationAccountId = "[resource ID of your Automation account]"
0 commit comments