This project is intended to help to create and deploy Azure Alerts for log analitycs queries and Azure Action Groups using code. The Alerts and Action Group creation is very boring task especially if is done manually. To let simplify the creation and managibility using code, the best way to create and manage is to use ARM template (Terraform support for log analitycs queries is not in place yet).
The project is based on Azure Resource Manager (ARM) template and it is composed by two couples of files (one for deployment template and one for deployment parameter):
- One couple to create the Action Groups resources to assign to the alerts.
- One couple to create the Alerts resources.
Once the Alerts and the Action Group have been designed, it's enought customize the parameters files to easily deploy the resources.
First of all it's necessary to define the Action Groups. The action Group parameter file has one parameter names actionGrp, this parameter is an array of objects and it's possible to define in the array more than one Action Group to create in that Subscription/ResourceGroup. The actionGrp parameter has six fields:
- Name - of the Action Group
- Shortname - of the Action Group
- Status - of Action Group (Can be true for enabled or false for disabled)
- smsReceivers - it's an array of objects and you can define more than one smsReceivers
- emailReceivers - it's an array of objects and you can define more than one emailReceivers
- webhookReceivers - it's an array of objects and you can define more than one webhookReceivers
Then it's necessary to define the Alerts. The Alerts parameter file has one parameter names alerts, this parameter is an array of objects and it's possible to define in the array more than one Alert to create in that Subscription/ResourceGroup. The alerts parameter has fortheen fields:
- alertLocation - Region which create the alert in
- alertName - name of the alert
- alertDescription - alertDescription
- alertStatus - status of alert (Can be true for enabled or false for disabled)
- alertSourceQuery - kusto query
- alertSourceSourceId - ID of the log analitycs workspace to query
- alertScheduleFrequency - Frequency
- alertScheduleTime - Time
- alertActionsSeverityLevel - Severity alert
- alertTriggerOperator - Trigger operator for query result
- alertTriggerThreshold - Trigger threshold
- actionGrpName - Action Group name (eventually defined in the Action Group parameter file), the Action Group must be already created otherwise you get error, you don't need to provide the Action Group ID but only the name, the ARM template will automatically search for it in the subscription.
- actionGrpSubject - Email Subject
- actionGrpWebhook - Additional field to the webhook Payload, if yu don't want enable this, you can leave the field empty. Don't remove the field because the template will generate an error.
These templates are not be able to deploy alerts and action group in different subscription using the same parameters file. To deploy them in different subscription it's necessary a parameter file for each subscription to deploy resource with.