Skip to content

Commit edc199c

Browse files
committed
Merge branch 'DocDB-CreateDiagnosticSettingsThroughARMTemplate' of https://github.com/samahana/azure-docs into cosmos-monitor-resource-logs-arm-template
2 parents 8e727a8 + ed57fa6 commit edc199c

File tree

1 file changed

+194
-0
lines changed

1 file changed

+194
-0
lines changed

articles/cosmos-db/monitor-resource-logs.md

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,200 @@ Use the [Azure Monitor REST API](/rest/api/monitor/diagnosticsettings/createorup
184184
}
185185
```
186186
187+
### [ARM Template](#tab/arm-template)
188+
189+
Use the [ARM template](https://learn.microsoft.com/en-us/azure/azure-monitor/resource-manager-samples?tabs=powershell) to create a diagnostic setting .
190+
191+
> [!NOTE]
192+
> We recommend setting the **logAnalyticsDestinationType** property to **Dedicated** for enabling resource specific tables.
193+
194+
1. Create the following Template file for your ComsosDB resource.
195+
196+
```json
197+
{
198+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
199+
"contentVersion": "1.0.0.0",
200+
"parameters": {
201+
"settingName": {
202+
"type": "string",
203+
"metadata": {
204+
"description": "The name of the diagnostic setting."
205+
}
206+
},
207+
"dbName": {
208+
"type": "string",
209+
"metadata": {
210+
"description": "The name of the database."
211+
}
212+
},
213+
"workspaceId": {
214+
"type": "string",
215+
"metadata": {
216+
"description": "The resource Id of the workspace."
217+
}
218+
},
219+
"storageAccountId": {
220+
"type": "string",
221+
"metadata": {
222+
"description": "The resource Id of the storage account."
223+
}
224+
},
225+
"eventHubAuthorizationRuleId": {
226+
"type": "string",
227+
"metadata": {
228+
"description": "The resource Id of the event hub authorization rule."
229+
}
230+
},
231+
"eventHubName": {
232+
"type": "string",
233+
"metadata": {
234+
"description": "The name of the event hub."
235+
}
236+
}
237+
},
238+
"resources": [{
239+
"type": "Microsoft.Insights/diagnosticSettings",
240+
"apiVersion": "2021-05-01-preview",
241+
"scope": "[format('Microsoft.DocumentDB/databaseAccounts/{0}', parameters('dbName'))]",
242+
"name": "[parameters('settingName')]",
243+
"properties": {
244+
"workspaceId": "[parameters('workspaceId')]",
245+
"storageAccountId": "[parameters('storageAccountId')]",
246+
"eventHubAuthorizationRuleId": "[parameters('eventHubAuthorizationRuleId')]",
247+
"eventHubName": "[parameters('eventHubName')]",
248+
"logAnalyticsDestinationType": "[parameters('logAnalyticsDestinationType')]",
249+
"logs": [{
250+
"category": "DataPlaneRequests",
251+
"categoryGroup": null,
252+
"enabled": true,
253+
"retentionPolicy": {
254+
"days": 0,
255+
"enabled": false
256+
}
257+
},
258+
{
259+
"category": "MongoRequests",
260+
"categoryGroup": null,
261+
"enabled": false,
262+
"retentionPolicy": {
263+
"days": 0,
264+
"enabled": false
265+
}
266+
},
267+
{
268+
"category": "QueryRuntimeStatistics",
269+
"categoryGroup": null,
270+
"enabled": true,
271+
"retentionPolicy": {
272+
"days": 0,
273+
"enabled": false
274+
}
275+
},
276+
{
277+
"category": "PartitionKeyStatistics",
278+
"categoryGroup": null,
279+
"enabled": true,
280+
"retentionPolicy": {
281+
"days": 0,
282+
"enabled": false
283+
}
284+
},
285+
{
286+
"category": "PartitionKeyRUConsumption",
287+
"categoryGroup": null,
288+
"enabled": true,
289+
"retentionPolicy": {
290+
"days": 0,
291+
"enabled": false
292+
}
293+
},
294+
{
295+
"category": "ControlPlaneRequests",
296+
"categoryGroup": null,
297+
"enabled": true,
298+
"retentionPolicy": {
299+
"days": 0,
300+
"enabled": false
301+
}
302+
},
303+
{
304+
"category": "CassandraRequests",
305+
"categoryGroup": null,
306+
"enabled": false,
307+
"retentionPolicy": {
308+
"days": 0,
309+
"enabled": false
310+
}
311+
},
312+
{
313+
"category": "GremlinRequests",
314+
"categoryGroup": null,
315+
"enabled": false,
316+
"retentionPolicy": {
317+
"days": 0,
318+
"enabled": false
319+
}
320+
},
321+
{
322+
"category": "TableApiRequests",
323+
"categoryGroup": null,
324+
"enabled": false,
325+
"retentionPolicy": {
326+
"days": 0,
327+
"enabled": false
328+
}
329+
}
330+
],
331+
"metrics": [{
332+
"timeGrain": null,
333+
"enabled": false,
334+
"retentionPolicy": {
335+
"days": 0,
336+
"enabled": false
337+
},
338+
"category": "Requests"
339+
}]
340+
}
341+
}]
342+
}
343+
344+
```
345+
346+
1. Create the following Parameter file for your CosmosDB resource.
347+
348+
```json
349+
{
350+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
351+
"contentVersion": "1.0.0.0",
352+
"parameters": {
353+
"settingName": {
354+
"value": "{DIAGNOSTIC_SETTING_NAME}"
355+
},
356+
"dbName": {
357+
"value": "{ACCOUNT_NAME}"
358+
},
359+
"workspaceId": {
360+
"value": "/subscriptions/{SUBSCRIPTION_ID}/resourcegroups/{RESOURCE_GROUP}/providers/microsoft.operationalinsights/workspaces/{WORKSPACE_NAME}"
361+
},
362+
"storageAccountId": {
363+
"value": "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP}/providers/Microsoft.Storage/storageAccounts/{STORAGE_ACCOUNT_NAME}"
364+
},
365+
"eventHubAuthorizationRuleId": {
366+
"value": "/subscriptions/{SUBSCRIPTION_ID}/resourcegroups{RESOURCE_GROUP}/providers/Microsoft.EventHub/namespaces/{EVENTHUB_NAMESPACE}/authorizationrules/{EVENTHUB_POLICY_NAME}"
367+
},
368+
"eventHubName": {
369+
"value": "{EVENTHUB_NAME}"
370+
},
371+
"logAnalyticsDestinationType":{
372+
"value": "Dedicated"
373+
}
374+
}
375+
}
376+
```
377+
378+
379+
1. Deploy the template by using any [deployment method for Resource Manager templates](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-portal).
380+
187381
---
188382
189383
## Enable full-text query for logging query text

0 commit comments

Comments
 (0)