What is a Heartbeat Monitor
Heartbeat Monitor is used to check if a cronjob is running regularly.
After creating a heartbeat monitor, MonSpark provides a unique URL to the user, and the user's cronjob sends requests to this specific URL. If it misses a beat (or is known as a request), MonSpark will create an alert about it.
Users can also choose to get notifications if the cronjob send requests out of it’s schedule.
Customizable Rules (Optional)
With MonSpark's Cronjob/Heartbeat Monitor, users can create customized rules based on the request data using JSON paths. For instance, if the cpu_usage
property is a numeric value and the it’s expected to be less than 80, MonSpark will flag this monitor as an anomaly (or down based on the rule configuration) and generate an alarm accordingly if the cpu_usage
property is more than 80.
This adaptable feature makes MonSpark's Cronjob/Heartbeat Monitor a versatile solution for monitoring various aspects of applications, such as daily database backups, CPU usage, disk usage, and more.
The possibilities for configuring rules on number, string, or boolean fields are endless, limited only by the user's imagination.
2. Click on Create Heartbeat
3. Type in the "Name of check"
4. Click on Create Heartbeat Monitors
5. Copy the URL of the created monitor
You can send any type of request to this URL by default.
MonSpark will automatically start the monitor once the initial request is received.
Here we are using the CPU usage script to check our CPU usage, MonSpark will make sure that the script is running properly with the set intervals. The exact command is as follows:
python3 cpu.py -u https://app.monspark.com/api/heartbeat/YOUR_UNIQUE_URL
This CPU usage script is one of multiple handy scripts provided open-source by MonSpark!
Check out more details about these this script over at https://github.com/MonSpark/heartbeat-scripts
6. Click on View Details
7. Click on Heartbeat Monitors Detail
You have successfully created and started using the MonSpark Heartbeat Monitoring!
Additionally you can set up advanced rules to monitor your CPU usage.
1. Click on the cog icon
2. Click on Edit
3. Click on Advanced Settings
4. Click on Add Rule
5. Click on Rule 1
6. Type in the Title and JSON Path
Here the JSON Path is cpu_usage_1min_avg
since we are using the CPU usage script provided by MonSpark. This field can be anything you want, depending on the data you send with the heartbeats.
7. Type in the Description and select the Expected Type
Again, since we are using the CPU usage script provided by MonSpark the expected type is number
8. Type in the Expected Value
We want to get an alert whenever our CPU usage goes over 50%, so here we set the Operation as greater than
and the Expected Value as 50
9. Type in highlight
You can also set the minimum and maximum values just the see a better defined chart in the MonSpark UI. Here the CPU usage can only be between 0 and 100, so we type it in.
10. Click on Anomaly
We want to make sure that the Rule does not make the monitor Down, instead it just creates an Anomaly, so we select that option.
11. Click on Edit Heartbeat Monitors
12. Click on View Details
13. Click on CPU Usage (Last Minute)
And viola! You can see the CPU Usage chart in the monitor details.
14. If CPU Usage Exceeds 50%
You can see that if the CPU usage does exceed 50% it will trigger an anomaly and send the appropriate notifications to saved email addresses and integrations.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article