I am looking for ARM template that will help to configure (Log Analytics) diagnostic setting. Have search few templates but no hope. Tried by export template and also with Resource Explorer didn't find the diagnostic setting configurations. Please share your idea
Here is the ARM template which i am trying
"apiVersion": "2015-07-01",
"name": "[concat(parameters('applicationGateways_name'), '/Microsoft.Insights/service')]",
"type": "Microsoft.Network/applicationGateways/providers/diagnosticsettings",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/ApplicationGateways/', parameters('applicationGateways_name'))]"
],
"properties":{
"name":"DiagService",
"workspaceId":"[variables('workspaceId')]",
"logs":[
{
Where as for "type": "Microsoft.Network/applicationGateways/providers/diagnosticsettings" not deducting
I am trying to add in the existing workspace
it worked with the following changes
{
"apiVersion": "2017-05-01-preview",
"name": "[concat(parameters('applicationGatewayName'), '/Microsoft.Insights/diagnosticSettings')]",
"type":"Microsoft.Network/applicationGateways/providers/diagnosticSettings",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/ApplicationGateways/', parameters('applicationGatewayName'))]"
],
"properties":{
"name":"Diag",
"workspaceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/microsoft.operationalinsights/workspaces/', parameters('workspaceId'))]",
"logs":[
{
"category": "ApplicationGatewayAccessLog",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "ApplicationGatewayPerformanceLog",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "ApplicationGatewayFirewallLog",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
Please NOTE Here I have used common workspace which created earlier
The ARM template is missing what kind of logs/metrics to send to the workspace. Try adding this in your section:
"logs": [
{
"category": "ApplicationGatewayAccessLog",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "ApplicationGatewayPerformanceLog",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "ApplicationGatewayFirewallLog",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"metrics": [
{
"category": "AllMetrics",
"timeGrain": "PT1M",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
Edit the retention as needed.
Related
When I am enabling the diagonstic setting fromt the azure portal for ADF & Azuresql, in the ARM template I am not able to find anything in ARM with respect to diagonstic setting.Similar way for keyvault and sql I need the ARM template for enabling the diagonstic setting.
I tried from my side for ADF since I new to ARM template I am not able to find the method for enabling the diagonstic setting.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"factoryName": {
"type": "string",
"metadata": {
"description": "The name of the Data Factory"
}
}
},
"resources": [
{
"type": "Microsoft.DataFactory/factories",
"apiVersion": "2018-06-01",
"name": "[parameters('factoryName')]",
"location": "[resourceGroup().location]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
},
"resources": [
{
"type": "Microsoft.DataFactory/factories/providers/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "[concat(parameters('factoryName'),'/microsoft.insights/', parameters('settingName'))]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.DataFactory/factories/', parameters('factoryName'))]"
],
"properties": {
"name": "[parameters('DS03')]",
"workspaceId": "[/subscriptions/3xxxxx-xxxxx-x-xxxx--xx/resourceGroups/BDAZxfdfG01]"
}
}
]
}
]
}
The ARM template above is creating the diagnostic settings; however it is not actually configuring the logging of anything. Add the following for all Data Factory metrics after your workspaceID property.
"logAnalyticsDestinationType": "Dedicated",
"logs": [
{
"category": "PipelineRuns",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "TriggerRuns",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "ActivityRuns",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"metrics": [
{
"category": "AllMetrics",
"timeGrain": "PT1M",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
Besides configuring the diagnostic settings what metrics and diagnostics must be select to send to log analytics. These fields align to those on the diagnostic blade:
The "logAnalyticsDestinationType": "Dedicated" is to ensure the logs go to their own table as opposed to the default AzureDiagnostic table. There is documented limitation in the original table.
When i try to deploy/enable diagnostic settings on Azure Firewall through ARM template. Though i get error.
I'm following this link
code snippet which i'm using:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {
"workspaceId": "[Concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.OperationalInsights/workspaces/', 'Fw-LA')]"
},
"resources": [
{
"type": "Microsoft.Network/azureFirewalls/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "[concat('FWHM/','Microsoft.Insights/', 'dignostic')]",
"properties": {
"name": "diagnostic",
"workspaceId": "[variables('workspaceId')]",
"logs": [
{
"category": "AzureFirewallApplicationRule",
"enabled": true,
"retentionPolicy": {
"days": 10,
"enabled": false
}
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
]
}
this:
"type": "Microsoft.Network/azureFirewalls/diagnosticSettings",
should be this instead:
"type": "Microsoft.Network/azureFirewalls/providers/diagnosticSettings",
read the article you linked carefully
I would like to enable diagnostics for Azure Datafactory using ARM-Template.
I have found this post and then I try to test my code:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": {},
"resources": [
{
"name": "test-adf2-we",
"type": "Microsoft.DataFactory/factories",
"apiVersion": "2018-06-01",
"location": "West Europe",
"identity": {
"type": "SystemAssigned"
}
},
{
"name": "test-ala-we",
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2015-11-01-preview",
"location": "West Europe"
},
{
"type": "microsoft.datafactory/factories/providers/diagnosticsettings",
"name": "[concat('test-adf2-we','/Microsoft.Insights/diagnostics')]",
"location": "West Europe",
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "diagnostics",
"storageAccountId": null,
"eventHubAuthorizationRuleId": null,
"eventHubName": null,
"workspaceId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/test-arm/providers/Microsoft.OperationalInsights/test-ala-we"
"logs": [
{
"category": "PipelineRuns",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "TriggerRuns",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "ActivityRuns",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"metrics": [
{
"category": "AllMetrics",
"timeGrain": "PT1M",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
}
After running this code. I get this error:
Template deployment returned the following errors:
Resource microsoft.datafactory/factories/providers/diagnosticsettings 'test-adf2-we/Microsoft.Insights/diagnostics' failed with message '{
"code": "BadRequest",
"message": "\"Resource type 'microsoft.operationalinsights/test-ala-we' is invalid for property 'properties.workspaceId'. Expected types are 'microsoft.operationalinsights/workspaces'\""
}'
could you help me to fix this problem?
Be sure to add
"logAnalyticsDestinationType": "Dedicated"
Otherwise Log Analytics will write to the Default AzureDiagnostic Tables. This is Microsoft Best Practice when using Log Analytics since there is a hard stop at 500 columns in the AzureDiagnostics table. Once the 500 column threshold is met records won't be inserted into the table.
your resourceId is wrong, fix it like so:
"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/test-arm/providers/Microsoft.OperationalInsights/workspaces/test-ala-we"
you left out workspaces (and this is what the error is telling you).
I'm using Azure RM Template deployments with a Visual Studio 2017 Resource Group project to deploy IoTHub instance with diagnostics settings in Log Analytics.
Deploying IoTHub alone is successful, the problem is with deployment of the Diagnostics Settings template.
I'm following the instructions for deploying Diagnostics Settings as Non-Compute resource template
The strange error that I receive is the following:
Error: Code=InvalidTemplate; Message=Deployment template validation
failed: 'The template resource 'Microsoft.Insights/BasicDiagnostics'
for type 'providers/diagnosticSettings' at line '69' and column '9'
has incorrect segment lengths. A nested resource type must have
identical number of segments as its resource name. A root resource
type must have segment length one greater than its resource name.
Why does it fail like this, even though I follow the documentation with the provided example?
Here are my template definitions:
"resources": [
{
"type": "Microsoft.Devices/IotHubs",
"sku": {
"name": "[parameters('sku.name')]",
"capacity": "[parameters('sku.units')]"
},
"name": "[parameters('iothubname')]",
"apiVersion": "2018-04-01",
"location": "[resourceGroup().location]",
"properties": {
"eventHubEndpoints": {
"events": {
"retentionTimeInDays": "[parameters('endpoints.events.retention')]",
"partitionCount": "[parameters('endpoints.events.partitions')]"
},
"operationsMonitoringEvents": {
"retentionTimeInDays": "[parameters('endpoints.operationsMonitoringEvents.retention')]",
"partitionCount": "[parameters('endpoints.operationsMonitoringEvents.partitions')]"
}
},
"features": "[parameters('features')]"
}
},
{
"type": "providers/diagnosticSettings",
"name": "[concat('Microsoft.Insights/', parameters('iotHub.diagnostics.settingName'))]",
"dependsOn": [
"[resourceId('Microsoft.Devices/IoTHubs', parameters('iothubname'))]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "[parameters('iotHub.diagnostics.settingName')]",
"workspaceId": "[parameters('iotHub.diagnostics.workspaceId')]",
"logs": [
{
"category": "Connections",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "Configurations",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "D2CTwinOperations",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
},
{
"category": "C2DTwinOperations",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
]
}
}
]
Any help much appreciated!
this needs to be a sub resource of the IOT hub, not a separate resource.
{
"type": "Microsoft.Devices/IotHubs",
"sku": {
"name": "[parameters('sku.name')]",
"capacity": "[parameters('sku.units')]"
},
"name": "[parameters('iothubname')]",
"apiVersion": "2018-04-01",
"location": "[resourceGroup().location]",
"properties": {
xxx
},
"features": "[parameters('features')]",
"resources": [
{
"type": "providers/diagnosticsSettings",
xxx
}
]
}
},
I am trying to setup enable diagnostics logs for app service using portal, which is working fine as below :
The same settings i am trying create using ARM Template but it is not working.
My ARM Template looks like below :
Is there anything wrong with settings or any other ways to enable logs ?
Anyone help is appreciated.
Regards,
Dipti Mamidala
In the resources array of the resource for which you want to enable Diagnostic Logs, add a resource of type [resource namespace]/providers/diagnosticSettings.
Example :
"resources": [
{
"type": "providers/diagnosticSettings",
"name": "[concat('Microsoft.Insights/', parameters('settingName'))]",
"dependsOn": [
"[/*resource Id for which Diagnostic Logs will be enabled>*/]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "[parameters('settingName')]",
"storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]",
"eventHubAuthorizationRuleId": "[parameters('eventHubAuthorizationRuleId')]",
"eventHubName": "[parameters('eventHubName')]",
"workspaceId": "[parameters('workspaceId')]",
"logs": [
{
"category": "/* log category name */",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
]
Read more here in documentation
Update : To set the value of Web Server logging use the below example
"properties": {
"applicationLogs": {
"Storage": {
"level": "Verbose"
}
},
"httpLogs": {
"fileSystem": {
}
}
}
If you want Storage or fileSystem use any one of above
I got this working by setting the httpLogs and httpLoggingEnabled properties.
This is the config resource nested within a site resource:
"resources": [
{
"apiVersion": "2018-02-01",
"type": "config",
"name": "logs",
"dependsOn": [
"[concat('Microsoft.Web/sites/', parameters('name'))]"
],
"properties": {
"applicationLogs": {
"azureBlobStorage": {
"level": "information",
"retentionInDays": 15
}
},
"httpLogs": {
"fileSystem": {
"retentioninMb": 35,
"retentioninDays": 15,
"enabled": true
}
},
"requestTracingEnabled": true,
"requestTracingExpirationTime": "9999-12-31T23:59:00Z",
"remoteDebuggingEnabled": false,
"httpLoggingEnabled": true,
"logsDirectorySizeLimit": 34,
"detailedErrorLoggingEnabled": true
}
}
]