In this first part of this blog series, we introduced our solution for ping monitoring within Azure Monitor via Log Analytics and Azure Automation. In this blog post, we will showcase how we can query the data in Log Analytics, generate alerts in Azure Monitor for ping failures and how we can visualize this information.
Once we have had ping failures with the solution shown in the first blog post we can now see the results of this with the following query:
Name_s, TimeGenerated, LastHeartbeat_s
The query below gives only specific systems which have not responded to the ping test and when these systems last responded successfully.
| project Name_s, LastHeartbeat_s
| distinct Name_s, LastHeartbeat_s
| project Name = Name_s, LastHeartbeat = LastHeartbeat_s
If we look at the above results, we see that while the watcher is running every minute the log analytics entries are writing every 15 minutes (which makes sense as that’s how we configured the ping to work by setting SuppressMinutes to 15).
Generating alerts for ping failures:
Now that we have our underlying queries, it’s simple to generate alerts for these conditions in Azure Monitor. We add a new rule which queries Log Analytics and alerts when the number of results is greater than 0 based on a 15-minute period and checking with a 15-minute frequency.
The full configuration for the alert is below.
And here’s what we receive when a system is not responding to ping requests.
Azure Cost breakdown:
Once we get data into Log Analytics cost is impacted by the amount of data sent to Log Analytics, and the number/configuration of ping failures alerts on that data.
- Log Analytics cost: (per this article, assuming the East US region)
- Charged at $2.30 per GB per month
- The first 5 GB of data ingested per customer to the Azure Log Analytics service every month is offered free.
- So the overall cost on this should never exceed $2.30 per month as the amount of data is extremely low.
- As we see in the example above, the alert for this condition running on a 15-minute basis is approximately $.50 per month.
- In general, the cost for this solution for Log Analytics data and alerting should be less than $5 a month and in general should be less than $1 a month.
Summary: Once we get the data into Log Analytics, it’s very straightforward to generate queries, alerts and dashboards based on this data. The overall cost of this solution should be generally insignificant on a monthly basis while still providing critical information for when systems are down.