Skip to content

Commit 81a7ce4

Browse files
authored
Merge pull request #110174 from BethWilke/branch7
Fixing broken links
2 parents 22d33ab + 3300cb7 commit 81a7ce4

File tree

2 files changed

+109
-102
lines changed

2 files changed

+109
-102
lines changed

articles/automation/automation-manage-send-joblogs-log-analytics.md

Lines changed: 82 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -25,146 +25,153 @@ To start sending your Automation logs to Azure Monitor logs, you need:
2525

2626
* The latest release of [Azure PowerShell](https://docs.microsoft.com/powershell/azureps-cmdlets-docs/).
2727
* A Log Analytics workspace. For more information, see [Get started with Azure Monitor logs](../log-analytics/log-analytics-get-started.md).
28-
* The ResourceId for your Azure Automation account.
28+
* The resource ID for your Azure Automation account.
2929

30-
To find the ResourceId for your Azure Automation account:
30+
Use the following command to find the resource ID for your Azure Automation account:
3131

3232
```powershell-interactive
3333
# Find the ResourceId for the Automation Account
3434
Get-AzResource -ResourceType "Microsoft.Automation/automationAccounts"
3535
```
3636

37-
To find the ResourceId for your Log Analytics workspace, run the following PowerShell:
37+
To find the resource ID for your Log Analytics workspace, run the following PowerShell command:
3838

3939
```powershell-interactive
4040
# Find the ResourceId for the Log Analytics workspace
4141
Get-AzResource -ResourceType "Microsoft.OperationalInsights/workspaces"
4242
```
4343

44-
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.
4545

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> ![Automation Account properties](media/automation-manage-send-joblogs-log-analytics/automation-account-properties.png).
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> ![Automation account properties](media/automation-manage-send-joblogs-log-analytics/automation-account-properties.png).
4749

48-
## Set up integration with Azure Monitor logs
4950

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.
52103

53104
```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]"
56107
57108
Set-AzDiagnosticSetting -ResourceId $automationAccountId -WorkspaceId $workspaceId -Enabled 1
58109
```
59110

60-
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.
61112

62113
To see the logs, run the following query in log analytics log search:
63114
`AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION"`
64115

65116
### Verify configuration
66117

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.
68119

69120
```powershell-interactive
70121
Get-AzDiagnosticSetting -ResourceId $automationAccountId
71122
```
72123

73-
In the output ensure that:
74-
75-
* 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:
79125

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.
126128

127129
## Viewing Automation Logs in Azure Monitor logs
128130

129-
Now that you started sending your Automation job logs to Azure Monitor logs, lets 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.
130132

131133
To see the logs, run the following query:
132134
`AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION"`
133135

134136
### Send an email when a runbook job fails or suspends
137+
135138
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.
136139

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.
138141

139142
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`
141144

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`.
143146
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).
144147

145148
### 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.
147151

148152
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.
150155

151156
### 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:
153159

154160
`AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobStreams" and JobId_g == "2ebd22ea-e05e-4eb9-9d76-d73cbd4356e0" | sort by TimeGenerated asc | project ResultDescription`
155161

156162
### 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.
158165

159166
`AzureDiagnostics | where ResourceProvider == "MICROSOFT.AUTOMATION" and Category == "JobLogs" and ResultType != "started" | summarize AggregatedValue = count() by ResultType, bin(TimeGenerated, 1h)`
160167
<br> ![Log Analytics Historical Job Status Chart](media/automation-manage-send-joblogs-log-analytics/historical-job-status-chart.png)<br>
161168

162-
## Remove diagnostic settings
169+
## Removing diagnostic settings
163170

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:
165172

166173
```powershell-interactive
167-
$automationAccountId = "[resource id of your automation account]"
174+
$automationAccountId = "[resource ID of your Automation account]"
168175
169176
Remove-AzDiagnosticSetting -ResourceId $automationAccountId
170177
```

0 commit comments

Comments
 (0)