Framework/Configurations/AlertMonitoring/AzSDK.AM.OMS.Alerts.json

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
   "parameters": {
      "omsWorkspaceLocation": {
         "type": "string",
         "defaultValue": ""
      },
      "omsResourcegroup": {
         "type": "string",
         "defaultValue": ""
      },
      "omsSubscriptionId": {
         "type": "string",
         "defaultValue": ""
      },
      "omsWorkspaceName": {
         "type": "string",
         "defaultValue": ""
      },
      "omsWorkspaceApiVersion": {
         "type": "string",
         "defaultValue": "2015-11-01-preview"
      },
      "alertEmailsPointOfContact": {
         "type": "array",
         "defaultValue": ""
      },
      "appName": {
         "type": "string",
         "defaultValue": ""
      },
      "applicationSubscriptionName": {
         "type": "string",
         "defaultValue": ""
      },
      "uniqueId": {
         "type": "string",
         "defaultValue": ""
      }
   },
   "variables": {
      "SearchCategory": "AzSDK_Alerts",
 
      "SearchQuery_Dist_Alert": "[concat('AzSDK_CriticalAlerts_By_', parameters('appName'), parameters('uniqueId'))]",
      "SearchQuery_Dist_Alert_Sch": "[concat(variables('SearchQuery_Dist_Alert'),'_Schedule')]",
      "SearchQuery_Dist_Alert_Name": "[concat(variables('SearchQuery_Dist_Alert'),'_Schedule')]"
   },
   "resources": [
      {
         "name": "[concat(parameters('omsWorkspaceName'), '/', variables('SearchQuery_Dist_Alert'))]",
         "type": "Microsoft.OperationalInsights/workspaces/savedSearches",
         "apiVersion": "2015-03-20",
         "location": "[resourceGroup().location]",
         "dependsOn": [],
         "properties": {
            "Category": "[variables('SearchCategory')]",
            "DisplayName": "[variables('SearchQuery_Dist_Alert')]",
            "Query": "[concat('Type=AzSDK_CL ControlStatus_s=Failed (ControlSeverity_s=High OR ControlSeverity_s=Critical) SubscriptionName_s=\"',parameters('applicationSubscriptionName'),'\"')]",
            "Version": "1"
         }
      },
      {
         "name": "[concat(parameters('omsWorkspaceName'), '/', variables('SearchQuery_Dist_Alert'), '/', variables('SearchQuery_Dist_Alert_Sch'))]",
         "type": "Microsoft.OperationalInsights/workspaces/savedSearches/schedules",
         "apiVersion": "2015-03-20",
         "location": "[resourceGroup().location]",
         "dependsOn": [
            "[resourceId('Microsoft.OperationalInsights/workspaces/savedSearches', parameters('omsWorkspaceName'), variables('SearchQuery_Dist_Alert'))]"
         ],
         "properties": {
            "Interval": 5,
            "QueryTimeSpan": 5,
            "Active": "true"
         }
      },
      {
         "name": "[concat(parameters('omsWorkspaceName'), '/', variables('SearchQuery_Dist_Alert'), '/', variables('SearchQuery_Dist_Alert_Sch'), '/', variables('SearchQuery_Dist_Alert_Name'))]",
         "type": "Microsoft.OperationalInsights/workspaces/savedSearches/schedules/actions",
         "apiVersion": "2015-03-20",
         "location": "[resourceGroup().location]",
         "dependsOn": [
            "[resourceId('Microsoft.OperationalInsights/workspaces/savedSearches/schedules', parameters('omsWorkspaceName'), variables('SearchQuery_Dist_Alert'), variables('SearchQuery_Dist_Alert_Sch'))]"
         ],
         "properties": {
            "Type": "Alert",
            "Name": "[variables('SearchQuery_Dist_Alert')]",
            "Threshold": {
               "Operator": "gt",
               "Value": 0
            },
            "EmailNotification": {
               "Recipients": "[parameters('alertEmailsPointOfContact')]",
               "Subject": "This is setup through ARM",
               "Attachment": "None"
            },
            "Version": 1
         }
      }
   ]
}