Create or update a diagnostics setting in Azure Monitor REST API

 

Updated: September 26, 2016

See Common parameters and headers for headers and parameters that are used by all requests related to diagnostics settings.

Method

Request URI

PUT

https://management.azure.com/{resource-id}/providers/microsoft.insights/diagnosticSettings/service?api-version={api-version}

Supported resources include Microsoft.StreamAnalytics, Microsoft.Cache and Microsoft.DataFactory.


 {
    properties": {
    "storageAccountId": "/subscriptions/s1/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/testStorageAcct",
    "serviceBusRuleId": "/subscriptions/s1/resourceGroups/rg1/providers/Microsoft.ServiceBus/namespaces/testNamespace/authorizationrules/RootManageSharedAccessKey",
    "workspaceId": "/subscriptions/s1/resourceGroups/rg1/providers/Microsoft.OperationalInsights/workspaces/myWorkspace",
    "metrics": [
        {
            "timeGrain": "PT1M",
            "enabled": true,
            "retentionPolicy": {
                "enabled": false,
                "days": 0
            }
        }
    ],
    "logs": [
        {
            "category": "NetworkSecurityGroupEvent",
            "enabled": true,
            "retentionPolicy": {
                "enabled": false,
                "days": 0
            },
            {
                "category": "NetworkSecurityGroupRuleCounter",
                "enabled": true,
                "retentionPolicy": {
                    "enabled": false,
                    "days": 0
                }
            }
        ]
    }
} 


                          

Element Name

Type

Description

storageAccountId

String

The resource ID of the storage account to which you would like to send Diagnostic Logs

serviceBusRuleId

String

The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: “{service bus resource ID}/authorizationrules/{key name}”.

workspaceId

String

The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs.

metrics

Complex Type

Array of metric time grains and their retention policies

timeGrain

String

The granularity of metrics that are captured in ISO 8601 duration format. Must be PT1M (one minute)

enabled

Boolean

Specifies whether collection of that metric or log category is enabled for this resource

retentionPolicy

Complex Type

Describes the retention policy for a metric or log category. Used for storage account option only.

days

Int

Number of days to retain the metrics or logs. A value of 0 will retain the logs indefinitely. Used for storage account option only.

logs

Complex Type

Array of log categories and their retention policies

category

String

Name of a Diagnostic Log category for a resource type. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation.

Status code: 200

Show: