Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "$schema": "https://raw.githubusercontent.com/Azure/enterprise-azure-policy-as-code/main/Schemas/policy-definition-schema.json",
- "name": "Deploy_WSF_MemoryPercentage_Alert",
- "properties": {
- "displayName": "AMBA - Deploy App Service Plan Memory Percentage Alert",
- "description": "Policy to audit/deploy App Service Plan Memory Percentage Alert",
- "mode": "All",
- "metadata": {
- "version": "1.1.0",
- "source": "https://github.com/Azure/azure-monitor-baseline-alerts/",
- "Category": "Web Services",
- "_deployed_by_amba": "True"
- },
- "parameters": {
- "evaluationFrequency": {
- "allowedValues": [
- "PT1M",
- "PT5M",
- "PT15M",
- "PT30M",
- "PT1H"
- ],
- "defaultValue": "PT5M",
- "metadata": {
- "description": "Evaluation frequency for the alert",
- "displayName": "Evaluation Frequency"
- },
- "type": "String"
- },
- "autoMitigate": {
- "allowedValues": [
- "true",
- "false"
- ],
- "defaultValue": "true",
- "metadata": {
- "description": "Auto Mitigate for the alert",
- "displayName": "Auto Mitigate"
- },
- "type": "String"
- },
- "windowSize": {
- "allowedValues": [
- "PT1M",
- "PT5M",
- "PT15M",
- "PT30M",
- "PT1H",
- "PT6H",
- "PT12H",
- "P1D"
- ],
- "defaultValue": "PT5M",
- "metadata": {
- "description": "Window size for the alert",
- "displayName": "Window Size"
- },
- "type": "String"
- },
- "enabled": {
- "allowedValues": [
- "true",
- "false"
- ],
- "defaultValue": "true",
- "metadata": {
- "description": "Alert state for the alert",
- "displayName": "Alert State"
- },
- "type": "String"
- },
- "severity": {
- "allowedValues": [
- "0",
- "1",
- "2",
- "3",
- "4"
- ],
- "defaultValue": "2",
- "metadata": {
- "description": "Severity of the Alert",
- "displayName": "Severity"
- },
- "type": "String"
- },
- "threshold": {
- "defaultValue": "85",
- "metadata": {
- "description": "Threshold for the alert",
- "displayName": "Threshold"
- },
- "type": "String"
- },
- "monitorDisable": {
- "defaultValue": "MonitorDisable",
- "metadata": {
- "description": "Tag name to disable monitoring resource. Set to true if monitoring should be disabled",
- "displayName": "Effect"
- },
- "type": "String"
- },
- "effect": {
- "allowedValues": [
- "deployIfNotExists",
- "disabled"
- ],
- "defaultValue": "deployIfNotExists",
- "metadata": {
- "description": "Effect of the policy",
- "displayName": "Effect"
- },
- "type": "String"
- }
- },
- "policyRule": {
- "if": {
- "allOf": [
- {
- "equals": "Microsoft.Web/serverfarms",
- "field": "type"
- },
- {
- "field": "[concat('tags[', parameters('MonitorDisable'), ']')]",
- "notEquals": "true"
- }
- ]
- },
- "then": {
- "effect": "[parameters('effect')]",
- "details": {
- "type": "Microsoft.Insights/metricAlerts",
- "roleDefinitionIds": [
- "/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
- ],
- "existenceCondition": {
- "allOf": [
- {
- "equals": "Microsoft.Web/serverfarms",
- "field": "Microsoft.Insights/metricAlerts/criteria.Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria.allOf[*].metricNamespace"
- },
- {
- "equals": "MemoryPercentage",
- "field": "Microsoft.Insights/metricAlerts/criteria.Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria.allOf[*].metricName"
- },
- {
- "equals": "[concat(subscription().id, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Web/serverfarms/', field('fullName'))]",
- "field": "Microsoft.Insights/metricalerts/scopes[*]"
- },
- {
- "equals": "[parameters('enabled')]",
- "field": "Microsoft.Insights/metricAlerts/enabled"
- },
- {
- "equals": "[parameters('evaluationFrequency')]",
- "field": "Microsoft.Insights/metricAlerts/evaluationFrequency"
- },
- {
- "equals": "[parameters('windowSize')]",
- "field": "Microsoft.Insights/metricAlerts/windowSize"
- },
- {
- "equals": "[parameters('severity')]",
- "field": "Microsoft.Insights/metricalerts/severity"
- },
- {
- "equals": "[parameters('autoMitigate')]",
- "field": "Microsoft.Insights/metricAlerts/autoMitigate"
- },
- {
- "equals": "Average",
- "field": "Microsoft.Insights/metricAlerts/criteria.Microsoft-Azure-Monitor-SingleResourceMultipleMetricCriteria.allOf[*].timeAggregation"
- },
- {
- "equals": "GreaterThan",
- "field": "Microsoft.Insights/metricAlerts/criteria.Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria.allOf[*].StaticThresholdCriterion.operator"
- },
- // {
- // "equals": "[parameters('threshold')]",
- // "field": "Microsoft.Insights/metricAlerts/criteria.Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria.allOf[*].StaticThresholdCriterion.threshold"
- // },
- {
- "equals": "[if(contains(field('tags'), 'Custom_Alert_Memory_Threshold'), field('tags.Custom_Alert_Memory_Threshold'), parameters('threshold'))]",
- "field": "Microsoft.Insights/metricAlerts/criteria.Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria.allOf[*].StaticThresholdCriterion.threshold"
- }
- ]
- },
- "deployment": {
- "properties": {
- "parameters": {
- "resourceId": {
- "value": "[field('id')]"
- },
- "evaluationFrequency": {
- "value": "[parameters('evaluationFrequency')]"
- },
- "autoMitigate": {
- "value": "[parameters('autoMitigate')]"
- },
- "windowSize": {
- "value": "[parameters('windowSize')]"
- },
- "enabled": {
- "value": "[parameters('enabled')]"
- },
- "severity": {
- "value": "[parameters('severity')]"
- },
- "threshold": {
- "value": "[if(contains(field('tags'), 'Custom_Alert_Memory_Threshold'), field('tags.Custom_Alert_Memory_Threshold'), parameters('threshold'))]"
- },
- "resourceName": {
- "value": "[field('name')]"
- }
- },
- "template": {
- "parameters": {
- "resourceId": {
- "metadata": {
- "description": "Resource ID of the resource emitting the metric that will be used for the comparison",
- "displayName": "resourceId"
- },
- "type": "String"
- },
- "evaluationFrequency": {
- "type": "String"
- },
- "autoMitigate": {
- "type": "String"
- },
- "windowSize": {
- "type": "String"
- },
- "enabled": {
- "type": "String"
- },
- "severity": {
- "type": "String"
- },
- "threshold": {
- "type": "String"
- },
- "resourceName": {
- "metadata": {
- "description": "Name of the resource",
- "displayName": "resourceName"
- },
- "type": "String"
- }
- },
- "contentVersion": "1.0.0.0",
- "resources": [
- {
- "type": "Microsoft.Insights/metricAlerts",
- "properties": {
- "description": "Metric Alert for App Service Plan Memory Percentage",
- "evaluationFrequency": "[parameters('evaluationFrequency')]",
- "autoMitigate": "[parameters('autoMitigate')]",
- "parameters": {
- "evaluationFrequency": {
- "value": "[parameters('evaluationFrequency')]"
- },
- "autoMitigate": {
- "value": "[parameters('autoMitigate')]"
- },
- "windowSize": {
- "value": "[parameters('windowSize')]"
- },
- "enabled": {
- "value": "[parameters('enabled')]"
- },
- "severity": {
- "value": "[parameters('severity')]"
- },
- "threshold": {
- "value": "[parameters('threshold')]"
- }
- },
- "windowSize": "[parameters('windowSize')]",
- "enabled": "[parameters('enabled')]",
- "severity": "[parameters('severity')]",
- "criteria": {
- "allOf": [
- {
- "threshold": "[parameters('threshold')]",
- "timeAggregation": "Average",
- "name": "MemoryPercentage",
- "operator": "GreaterThan",
- "metricNamespace": "Microsoft.Web/serverfarms",
- "criterionType": "StaticThresholdCriterion",
- "metricName": "MemoryPercentage"
- }
- ],
- "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
- },
- "scopes": [
- "[parameters('resourceId')]"
- ]
- },
- "apiVersion": "2018-03-01",
- "location": "global",
- "name": "[concat('AMBA-', parameters('resourceName'), '-MemoryPercentage')]",
- "tags": {
- "_deployed_by_amba": true
- }
- }
- ],
- "variables": {},
- "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
- },
- "mode": "incremental"
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement