Skip to content

Commit 9dcf023

Browse files
authored
Merge pull request #225995 from bwren/logs-api-fix
Update to Logs Ingestion API walkthrough
2 parents 7a07d8f + 561de27 commit 9dcf023

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed
79 KB
Loading
-25.5 KB
Loading

articles/azure-monitor/logs/tutorial-logs-ingestion-api.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: 'Tutorial: Send data to Azure Monitor Logs using REST API (Resource Manager templates)'
33
description: Tutorial on how to send data to a Log Analytics workspace in Azure Monitor by using the REST API Azure Resource Manager template version.
44
ms.topic: tutorial
5-
ms.date: 07/15/2022
5+
ms.date: 02/01/2023
66
---
77

88
# Tutorial: Send data to Azure Monitor Logs using REST API (Resource Manager templates)
@@ -90,9 +90,14 @@ Use the **Tables - Update** API to create the table with the following PowerShel
9090
"description": "Additional message properties"
9191
},
9292
{
93-
"name": "ExtendedColumn",
93+
"name": "CounterName",
9494
"type": "string",
95-
"description": "An additional column extended at ingestion time"
95+
"description": "Name of the counter"
96+
},
97+
{
98+
"name": "CounterValue",
99+
"type": "real",
100+
"description": "Value collected for the counter"
96101
}
97102
]
98103
}
@@ -180,7 +185,7 @@ A [DCE](../essentials/data-collection-endpoint-overview.md) is required to accep
180185
:::image type="content" source="media/tutorial-logs-ingestion-api/data-collection-endpoint-json.png" lightbox="media/tutorial-logs-ingestion-api/data-collection-endpoint-json.png" alt-text="Screenshot that shows the DCE resource ID.":::
181186
182187
## Create a data collection rule
183-
The [DCR](../essentials/data-collection-rule-overview.md) defines the schema of data that's being sent to the HTTP endpoint. It also defines the transformation that will be applied to it. The DCR also defines the destination workspace and table the transformed data will be sent to.
188+
The [DCR](../essentials/data-collection-rule-overview.md) defines the schema of data that's being sent to the HTTP endpoint and the [transformation](../essentials/data-collection-transformations.md) that will be applied to it before it's sent to the workspace. The DCR also defines the destination workspace and table the transformed data will be sent to.
184189
185190
1. In the Azure portal's search box, enter **template** and then select **Deploy a custom template**.
186191
@@ -199,7 +204,7 @@ The [DCR](../essentials/data-collection-rule-overview.md) defines the schema of
199204
- `dataCollectionEndpointId`: Identifies the Resource ID of the data collection endpoint.
200205
- `streamDeclarations`: Defines the columns of the incoming data.
201206
- `destinations`: Specifies the destination workspace.
202-
- `dataFlows`: Matches the stream with the destination workspace and specifies the transformation query and the destination table.
207+
- `dataFlows`: Matches the stream with the destination workspace and specifies the transformation query and the destination table. The output of the destination query is what will be sent to the destination table.
203208
204209
```json
205210
{
@@ -214,12 +219,6 @@ The [DCR](../essentials/data-collection-rule-overview.md) defines the schema of
214219
},
215220
"location": {
216221
"type": "string",
217-
"defaultValue": "westus2",
218-
"allowedValues": [
219-
"westus2",
220-
"eastus2",
221-
"eastus2euap"
222-
],
223222
"metadata": {
224223
"description": "Specifies the location in which to create the Data Collection Rule."
225224
}
@@ -279,7 +278,7 @@ The [DCR](../essentials/data-collection-rule-overview.md) defines the schema of
279278
"destinations": [
280279
"clv2ws1"
281280
],
282-
"transformKql": "source | extend jsonContext = parse_json(AdditionalContext) | project TimeGenerated = Time, Computer, AdditionalContext = jsonContext, ExtendedColumn=tostring(jsonContext.CounterName)",
281+
"transformKql": "source | extend jsonContext = parse_json(AdditionalContext) | project TimeGenerated = Time, Computer, AdditionalContext = jsonContext, CounterName=tostring(jsonContext.CounterName), CounterValue=jsonContext.CounterValue",
283282
"outputStream": "Custom-MyTable_CL"
284283
}
285284
]
@@ -305,9 +304,9 @@ The [DCR](../essentials/data-collection-rule-overview.md) defines the schema of
305304
306305
:::image type="content" source="media/tutorial-workspace-transformations-api/data-collection-rule-details.png" lightbox="media/tutorial-workspace-transformations-api/data-collection-rule-details.png" alt-text="Screenshot that shows DCR details.":::
307306
308-
1. Copy the **Resource ID** for the DCR. You'll use it in the next step.
307+
1. Copy the **Immutable ID** for the DCR. You'll use it in a later step when you send sample data using the API.
309308
310-
:::image type="content" source="media/tutorial-workspace-transformations-api/data-collection-rule-json-view.png" lightbox="media/tutorial-workspace-transformations-api/data-collection-rule-json-view.png" alt-text="Screenshot that shows DCR JSON view.":::
309+
:::image type="content" source="media/tutorial-logs-ingestion-api/data-collection-rule-json-view.png" lightbox="media/tutorial-workspace-transformations-api/data-collection-rule-json-view.png" alt-text="Screenshot that shows DCR JSON view.":::
311310
312311
> [!NOTE]
313312
> All the properties of the DCR, such as the transformation, might not be displayed in the Azure portal even though the DCR was successfully created with those properties.
@@ -357,6 +356,7 @@ The following PowerShell code sends data to the endpoint by using HTTP REST fund
357356
#information needed to send data to the DCR endpoint
358357
$dcrImmutableId = "dcr-000000000000000"; #the immutableId property of the DCR object
359358
$dceEndpoint = "https://my-dcr-name.westus2-1.ingest.monitor.azure.com"; #the endpoint property of the Data Collection Endpoint object
359+
$streamName = "Custom-MyTableRawData"; #name of the stream in the DCR that represents the destination table
360360
361361
##################
362362
### Step 1: Obtain a bearer token used later to authenticate against the DCE.
@@ -404,7 +404,7 @@ The following PowerShell code sends data to the endpoint by using HTTP REST fund
404404
##################
405405
$body = $staticData;
406406
$headers = @{"Authorization"="Bearer $bearerToken";"Content-Type"="application/json"};
407-
$uri = "$dceEndpoint/dataCollectionRules/$dcrImmutableId/streams/Custom-MyTableRawData?api-version=2021-11-01-preview"
407+
$uri = "$dceEndpoint/dataCollectionRules/$dcrImmutableId/streams/$($streamName)?api-version=2021-11-01-preview"
408408
409409
$uploadResponse = Invoke-RestMethod -Uri $uri -Method "Post" -Body $body -Headers $headers
410410
```

0 commit comments

Comments
 (0)