Gallery › Monitoring › Azure Community Policy
Log Analytics Workspace require retention in days
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
Azure Log Analytics should have retention set to the specified number of days
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 53 lines
{
"name": "25b5146e-af5c-4229-9bad-2f009ef7a453",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Log Analytics Workspace require retention in days",
"description": "Azure Log Analytics should have retention set to the specified number of days",
"metadata": {
"category": "Monitoring",
"version": "1.0.0"
},
"mode": "Indexed",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
},
"retentionInDays": {
"type": "Integer",
"metadata": {
"displayName": "Retention in days",
"description": "This defines how long logs should be retained for"
},
"defaultValue": 90
},
},
"policyRule": {
"if": {
"allOf": [
{
"equals": "Microsoft.OperationalInsights/workspaces",
"field": "type"
},
{
"equals": "[parameters('retentionInDays')]",
"field": "microsoft.operationalinsights/workspaces/retentionInDays"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw25b5146e-af5c-4229-9bad-2f009ef7a453.bylaw.ps1 · 33 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '25b5146e-af5c-4229-9bad-2f009ef7a453' {
Properties @{
DisplayName = 'Log Analytics Workspace require retention in days'
Description = 'Azure Log Analytics should have retention set to the specified number of days'
Category = 'Monitoring'
Version = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Parameter RetentionInDays @{
Type = 'Integer'
Default = 90
DisplayName = 'Retention in days'
Description = 'This defines how long logs should be retained for'
}
Resource 'Microsoft.OperationalInsights/workspaces' {
Require 'retentionInDays is not the RetentionInDays parameter' {
Field retentionInDays | Must -Not -Be (Param RetentionInDays) -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/Monitoring/log-analytics-workspace-require-retention-in-days/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw