microsoft.insights diagnosticSettings template reference

Template format

To create a microsoft.insights/diagnosticSettings resource, add the following JSON to the resources section of your template.

{
  "name": "string",
  "type": "microsoft.insights/diagnosticSettings",
  "apiVersion": "2017-05-01-preview",
  "location": "string",
  "properties": {
    "storageAccountId": "string",
    "serviceBusRuleId": "string",
    "eventHubAuthorizationRuleId": "string",
    "eventHubName": "string",
    "metrics": [
      {
        "timeGrain": "string",
        "category": "string",
        "enabled": "boolean",
        "retentionPolicy": {
          "enabled": "boolean",
          "days": "integer"
        }
      }
    ],
    "logs": [
      {
        "category": "string",
        "enabled": "boolean",
        "retentionPolicy": {
          "enabled": "boolean",
          "days": "integer"
        }
      }
    ],
    "workspaceId": "string",
    "logAnalyticsDestinationType": "string"
  }
}

Property values

The following tables describe the values you need to set in the schema.

microsoft.insights/diagnosticSettings object

Name Type Required Value
name string Yes The name of the diagnostic setting.
type enum Yes microsoft.insights/diagnosticSettings
apiVersion enum Yes 2017-05-01-preview
location string No Location of the resource
properties object Yes Properties of a Subscription Diagnostic Settings Resource. - SubscriptionDiagnosticSettings object

SubscriptionDiagnosticSettings object

Name Type Required Value
storageAccountId string No The resource ID of the storage account to which you would like to send Diagnostic Logs.
serviceBusRuleId string No The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility.
eventHubAuthorizationRuleId string No The resource Id for the event hub authorization rule.
eventHubName string No The name of the event hub. If none is specified, the default event hub will be selected.
metrics array No The list of metric settings. - MetricSettings object
logs array No The list of logs settings. - SubscriptionLogSettings object
workspaceId string No The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2
logAnalyticsDestinationType string No A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: <normalized service identity>_<normalized category name>. Possible values are: Dedicated and null (null is default.)

MetricSettings object

Name Type Required Value
timeGrain string No the timegrain of the metric in ISO8601 format.
category string No Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation.
enabled boolean Yes a value indicating whether this category is enabled.
retentionPolicy object No the retention policy for this category. - RetentionPolicy object

SubscriptionLogSettings object

Name Type Required Value
category string No Name of a Subscription Diagnostic Log category for a resource type this setting is applied to.
enabled boolean Yes a value indicating whether this log is enabled.
retentionPolicy object No the retention policy for this log. - RetentionPolicy object

RetentionPolicy object

Name Type Required Value
enabled boolean Yes a value indicating whether the retention policy is enabled.
days integer Yes the number of days for the retention in days. A value of 0 will retain the events indefinitely.

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
Create Recovery Services Vault and Enable Diagnostics

Deploy to Azure
This template creates a Recovery Services Vault and enables diagnostics for Azure Backup. This also deploys storage account and oms workspace.
Create a Redis Cache using a template

Deploy to Azure
This template creates an Azure Redis Cache with diagnostics data kept in a storage account.
Create and monitor API Management instance with Operations Management Suite (OMS) - Log Analytics

Deploy to Azure
This template creates an instance of Azure API Management service and OMS workspace and sets up monitoring for your API Management service with Operations Management Suite - Log Analytics
Create Azure Front Door in front of Azure API Management

Deploy to Azure
This sample demonstrates how to use Azure Front Door as a global load balancer in front of Azure API Management.
Create Key Vault with logging enabled

Deploy to Azure
This template creates an Azure Key Vault and an Azure Storage account that is used for logging. It optionally creates resource locks to protect your Key Vault and storage resources.
Create a Premium Redis Cache with clustering

Deploy to Azure
This template shows how to configure clustering in a premium Azure Redis Cache instance.
Create Premium Redis Cache with data persistence

Deploy to Azure
This template shows how to configure persistence in a premium Azure Redis Cache instance.
Azure SQL Server with Auditing written to Event Hub

Deploy to Azure
This template allows you to deploy an Azure SQL server with Auditing enabled to write audit logs to Event Hub
Azure SQL Server with Auditing written to Log Analitics

Deploy to Azure
This template allows you to deploy an Azure SQL server with Auditing enabled to write audit logs to Log Analitics (OMS workspace)