Hi @Murali R
I suggest going the REST API route and creating an alert. You can use the following API endpoint to create an alert rule:
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/metricAlerts/{ruleName}?api-version=2018-03-01-preview
Replace {subscriptionId}
with the subscription ID, {resourceGroupName}
with the name of the resource group containing the Application Gateway, and {ruleName}
with a unique name for the alert rule. For the request body, specify the details of the alert, including the metric to monitor, threshold, and action to take. Here's an example request body:
{
"location": "global",
"properties": {
"description": "Alert rule for Application Gateway health status",
"severity": 2,
"enabled": true,
"condition": {
"odata.type": "Microsoft.Azure.Management.Monitor.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Monitor.Models.RuleMetricDataSource",
"resourceUri": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}",
"metricNamespace": "Microsoft.Network/applicationGateways/backendHealth",
"metricName": "health",
"aggregation": {
"odata.type": "Microsoft.Azure.Management.Monitor.Models.RuleMetricAggregation",
"operator": "Count",
"threshold": 1
}
},
"operator": "GreaterThan",
"threshold": 0,
"windowSize": "PT5M"
},
"actions": [
{
"odata.type": "Microsoft.Azure.Management.Monitor.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": []
}
]
}
}
In this example, the alert rule is configured to monitor the health status of the Application Gateway and trigger an email notification when the health status is unhealthy. Make any necessary modifications to meet your specific requirements.