Diagnostic Settings - Create Or Update
Creates or updates diagnostic settings for the specified resource.
PUT https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}?api-version=2021-05-01-preview
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
name
|
path | True |
string |
The name of the diagnostic setting. |
resource
|
path | True |
string |
The identifier of the resource. |
api-version
|
query | True |
string |
The API version to use for this operation. |
Request Body
Name | Type | Description |
---|---|---|
properties.eventHubAuthorizationRuleId |
string |
The resource Id for the event hub authorization rule. |
properties.eventHubName |
string |
The name of the event hub. If none is specified, the default event hub will be selected. |
properties.logAnalyticsDestinationType |
string |
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: _. Possible values are: Dedicated and null (null is default.) |
properties.logs |
The list of logs settings. |
|
properties.marketplacePartnerId |
string |
The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs. |
properties.metrics |
The list of metric settings. |
|
properties.serviceBusRuleId |
string |
The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. |
properties.storageAccountId |
string |
The resource ID of the storage account to which you would like to send Diagnostic Logs. |
properties.workspaceId |
string |
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 |
Responses
Name | Type | Description |
---|---|---|
200 OK |
Successful request to create a diagnostic setting |
|
Other Status Codes |
Error response describing why the operation failed. |
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name | Description |
---|---|
user_impersonation | impersonate your user account |
Examples
Creates or Updates the diagnostic setting |
Creates or Updates the diagnostic setting for category |
Creates or Updates the diagnostic setting
Sample request
PUT https://management.azure.com/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/Microsoft.Insights/diagnosticSettings/mysetting?api-version=2021-05-01-preview
{
"properties": {
"storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1",
"workspaceId": "",
"eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule",
"eventHubName": "myeventhub",
"marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1",
"metrics": [
{
"category": "WorkflowMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logs": [
{
"categoryGroup": "allLogs",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logAnalyticsDestinationType": "Dedicated"
}
}
Sample response
{
"id": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/microsoft.insights/diagnosticSettings/mysetting",
"type": "Microsoft.Insights/diagnosticSettings",
"name": "mysetting",
"properties": {
"storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1",
"workspaceId": "",
"eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule",
"eventHubName": "myeventhub",
"marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1",
"metrics": [
{
"category": "WorkflowMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logs": [
{
"categoryGroup": "allLogs",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logAnalyticsDestinationType": "Dedicated"
}
}
Creates or Updates the diagnostic setting for category
Sample request
PUT https://management.azure.com/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/providers/Microsoft.Insights/diagnosticSettings/mysetting?api-version=2021-05-01-preview
{
"properties": {
"storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1",
"workspaceId": "",
"eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule",
"eventHubName": "myeventhub",
"marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1",
"metrics": [
{
"category": "WorkflowMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logs": [
{
"category": "WorkflowRuntime",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logAnalyticsDestinationType": "Dedicated"
}
}
Sample response
{
"id": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6/diagnosticSettings/mysetting",
"type": "",
"name": "mysetting",
"properties": {
"storageAccountId": "/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1",
"workspaceId": "",
"eventHubAuthorizationRuleId": "/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule",
"eventHubName": "myeventhub",
"marketplacePartnerId": "/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1",
"metrics": [
{
"category": "WorkflowMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logs": [
{
"category": "WorkflowRuntime",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"logAnalyticsDestinationType": "Dedicated"
}
}
Definitions
Name | Description |
---|---|
created |
The type of identity that created the resource. |
Diagnostic |
The diagnostic setting resource. |
Error |
Describes the format of Error response. |
Log |
Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. |
Metric |
Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. |
Retention |
Specifies the retention policy for the log. |
system |
Metadata pertaining to creation and last modification of the resource. |
createdByType
The type of identity that created the resource.
Name | Type | Description |
---|---|---|
Application |
string |
|
Key |
string |
|
ManagedIdentity |
string |
|
User |
string |
DiagnosticSettingsResource
The diagnostic setting resource.
Name | Type | Description |
---|---|---|
id |
string |
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
name |
string |
The name of the resource |
properties.eventHubAuthorizationRuleId |
string |
The resource Id for the event hub authorization rule. |
properties.eventHubName |
string |
The name of the event hub. If none is specified, the default event hub will be selected. |
properties.logAnalyticsDestinationType |
string |
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: _. Possible values are: Dedicated and null (null is default.) |
properties.logs |
The list of logs settings. |
|
properties.marketplacePartnerId |
string |
The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic Logs. |
properties.metrics |
The list of metric settings. |
|
properties.serviceBusRuleId |
string |
The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. |
properties.storageAccountId |
string |
The resource ID of the storage account to which you would like to send Diagnostic Logs. |
properties.workspaceId |
string |
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 |
systemData |
The system metadata related to this resource. |
|
type |
string |
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" |
ErrorResponse
Describes the format of Error response.
Name | Type | Description |
---|---|---|
code |
string |
Error code |
message |
string |
Error message indicating why the operation failed. |
LogSettings
Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log.
Name | Type | Description |
---|---|---|
category |
string |
Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. |
categoryGroup |
string |
Name of a Diagnostic Log category group for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. |
enabled |
boolean |
a value indicating whether this log is enabled. |
retentionPolicy |
the retention policy for this log. |
MetricSettings
Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric.
Name | Type | Description |
---|---|---|
category |
string |
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 |
a value indicating whether this category is enabled. |
retentionPolicy |
the retention policy for this category. |
|
timeGrain |
string |
the timegrain of the metric in ISO8601 format. |
RetentionPolicy
Specifies the retention policy for the log.
Name | Type | Description |
---|---|---|
days |
integer |
the number of days for the retention in days. A value of 0 will retain the events indefinitely. |
enabled |
boolean |
a value indicating whether the retention policy is enabled. |
systemData
Metadata pertaining to creation and last modification of the resource.
Name | Type | Description |
---|---|---|
createdAt |
string |
The timestamp of resource creation (UTC). |
createdBy |
string |
The identity that created the resource. |
createdByType |
The type of identity that created the resource. |
|
lastModifiedAt |
string |
The timestamp of resource last modification (UTC) |
lastModifiedBy |
string |
The identity that last modified the resource. |
lastModifiedByType |
The type of identity that last modified the resource. |