az monitor diagnostic-settings

Manage service diagnostic settings.

Commands

az monitor diagnostic-settings categories Retrieve service diagnostic settings categories.
az monitor diagnostic-settings categories list Lists the diagnostic settings categories for the specified resource.
az monitor diagnostic-settings categories show Gets the diagnostic settings category for the specified resource.
az monitor diagnostic-settings create Create diagnostic settings for the specified resource.
az monitor diagnostic-settings delete Deletes existing diagnostic settings for the specified resource.
az monitor diagnostic-settings list Gets the active diagnostic settings list for the specified resource.
az monitor diagnostic-settings show Gets the active diagnostic settings for the specified resource.
az monitor diagnostic-settings update Update diagnostic settings.

az monitor diagnostic-settings create

Create diagnostic settings for the specified resource.

az monitor diagnostic-settings create --name
--resource
[--event-hub]
[--event-hub-rule]
[--logs]
[--metrics]
[--resource-group]
[--resource-namespace]
[--resource-parent]
[--resource-type]
[--storage-account]
[--subscription]
[--workspace]

Examples

Create diagnostic settings with EventHub.

az monitor diagnostic-settings create --resource {ID} -n {name}
                           --event-hub-rule {eventHubRuleID} --storage-account {storageAccount}
                           --logs '[
                             {
                               "category": "WorkflowRuntime",
                               "enabled": true,
                               "retentionPolicy": {
                                 "enabled": false,
                                 "days": 0
                               }
                             }
                           ]'
                           --metrics '[
                             {
                               "category": "WorkflowRuntime",
                               "enabled": true,
                               "retentionPolicy": {
                                 "enabled": false,
                                 "days": 0
                               }
                             }
                           ]'

Required Parameters

--name -n

The name of the diagnostic settings.

--resource

Name or ID of the target resource.

Optional Parameters

--event-hub

Name or ID an event hub. If none is specified, the default event hub will be selected.

--event-hub-rule

Name or ID of the event hub authorization rule.

--logs

JSON encoded list of logs settings. Use '@{file}' to load from a file.

--metrics

JSON encoded list of metric settings. Use '@{file}' to load from a file.

--resource-group -g

Name of the resource group for the Log Analytics and Storage Account when the name of the service instead of a full resource ID is given.

--resource-namespace

Target resource provider namespace.

--resource-parent

Target resource parent path, if applicable.

--resource-type

Target resource type. Can also accept namespace/type format (Ex: 'Microsoft.Compute/virtualMachines').

--storage-account

Name or ID of the storage account to send diagnostic logs to.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--workspace

Name or ID of the Log Analytics workspace to send diagnostic logs to.

az monitor diagnostic-settings delete

Deletes existing diagnostic settings for the specified resource.

az monitor diagnostic-settings delete --name
--resource
[--resource-group]
[--resource-namespace]
[--resource-parent]
[--resource-type]
[--subscription]

Required Parameters

--name -n

The name of the diagnostic setting.

--resource

Name or ID of the target resource.

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-namespace

Target resource provider namespace.

--resource-parent

Target resource parent path, if applicable.

--resource-type

Target resource type. Can also accept namespace/type format (Ex: 'Microsoft.Compute/virtualMachines').

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az monitor diagnostic-settings list

Gets the active diagnostic settings list for the specified resource.

az monitor diagnostic-settings list --resource
[--resource-group]
[--resource-namespace]
[--resource-parent]
[--resource-type]
[--subscription]

Required Parameters

--resource

Name or ID of the target resource.

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-namespace

Target resource provider namespace.

--resource-parent

Target resource parent path, if applicable.

--resource-type

Target resource type. Can also accept namespace/type format (Ex: 'Microsoft.Compute/virtualMachines').

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az monitor diagnostic-settings show

Gets the active diagnostic settings for the specified resource.

az monitor diagnostic-settings show --name
--resource
[--resource-group]
[--resource-namespace]
[--resource-parent]
[--resource-type]
[--subscription]

Required Parameters

--name -n

The name of the diagnostic setting.

--resource

Name or ID of the target resource.

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-namespace

Target resource provider namespace.

--resource-parent

Target resource parent path, if applicable.

--resource-type

Target resource type. Can also accept namespace/type format (Ex: 'Microsoft.Compute/virtualMachines').

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az monitor diagnostic-settings update

Update diagnostic settings.

az monitor diagnostic-settings update --name
--resource
[--add]
[--force-string]
[--remove]
[--resource-group]
[--resource-namespace]
[--resource-parent]
[--resource-type]
[--set]
[--subscription]

Required Parameters

--name -n

The name of the diagnostic setting.

--resource

Name or ID of the target resource.

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-namespace

Target resource provider namespace.

--resource-parent

Target resource parent path, if applicable.

--resource-type

Target resource type. Can also accept namespace/type format (Ex: 'Microsoft.Compute/virtualMachines').

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.