Ask HN: How to do simple heartbeat monitoring?
Hey there!
My team is hosting an API that sends open telemetry data to Signoz & manages on-call via PagerDuty. We've configured Signoz to hit Pagerduty when there's a series of 500 errors.
However, our server went down last night and NO opentel data was sent to Signoz. We weren't notified that the server went down as there weren't 500 responses to report. What's the easiest way to have a cron-like query hit our API and integrate with our existing stack? Is this feasible with our existing vendors? Should I have a serverless function running on a timer that uses Pagerduty's API? Should I be migrating to another monitoring service?
Any advice would be appreciated!
85 comments
[ 4.3 ms ] story [ 149 ms ] threadAnother alternative is to use an alert to notify on a metric being absent for sometime. Both of these should work
With a metric, you can use a monotonic counter to serve as a heartbeat. A timestamp would work. In your monitoring system, when the heartbeat value has not increased in X minutes, you alert.
We have a decent free plan that would probably work for you.
[1] https://news.ycombinator.com/item?id=7917587
there's probably functionality built in to your other monitoring tools, or you could write a little serverless function to to it, but for me i really like to have it isolated. i wanted a tool that's not part of the rest of our monitoring stack, not part of our own codebase, and not something we manage.
I wish they had a better way to hit your phone. Currently it supports Slack and SMS but I need a way to make my phone go crazy when things go wrong (you can set Updown as an emergency contact but this has many downsides as well).
Write a cron job that greps the logs and pulls on your api with curl?
With another 20 minutes of work you can remember the log size on each run and grep only what's new on the next run.
There isn’t a good way to solve this using a PUSH model that isn’t somewhat of a hack or using another external tool
Not sure about Signoz and PagerDuty, but there are plenty freemium services like UpTimeRobot that work fine for basics.
And then something like AWS CloudWatch has a lot more advanced options about how to treat missing data.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitori...
With a lot of knobs to tune around what intervals you need and what counts as 'down', which you'll want to think about pretty carefully given what you need.
You cannot only do classic heartbeat checks but also high level API (single request and multi request) and Browser checks to make sure your service is behaving as expected.
The heartbeat process itself basically just sent pings every second on a UDP port and waited for a reply. If we didn’t get a reply in one second, it’d assume the connection was bad until a ping came again.
For example: https://blog.ediri.io/how-to-set-up-a-dead-mans-switch-in-pr...
You might want to use a different service for monitoring your stack just to make sure you have some redundancy there. Seems like you got an answer for how to do this with Signoz but if that is down then you won't know.
That's more or less what I was gonna say...
edit: on second read, it sounds like regular uptime monitoring for your API would do the trick
Free and easy. Not affiliated, just a happy user.
I combine it with a service like uptimerobot to get messages if the heartbeat stopped.
No 2XX-499 results means the server is borked.
If you wanted to be really fancy you could send heartbeat requests when no live traffic had hit that node for n milliseconds.
I still think the latter is the right answer. Why inflate traffic when you are horizontally scaling? That’s a lot of health checks per second.
If you're on AWS, there's already heartbeat monitoring and that can integrate with CloudWatch to notify PagerDuty.
In fact, this is what I'd recommend (though I use Pushover), because then you don't have to be concerned with email setup, not getting caught in spam filters, firewalls, etc. You could also send a Slack/Teams alert with a similar POST.
For some reason, I thought I had read that OP wanted to send an email.
https://github.com/caronc/apprise
They usually all have pager duty integration as well.
Some examples:
Datadog: https://docs.datadoghq.com/synthetics/ Grafana cloud: https://grafana.com/grafana/plugins/grafana-synthetic-monito...
1. Yes, a synthetic check is very useful here to just see if a user facing "thing" is still working.
2. a heartbeat check / deadman's switch can also work here, but it will only be reliable when the monitored event has a predefined cadence, e.g. "every 5 minutes this should happen".
3. The lack / absence of metrics flowing into a system is also sign. This would typically be solved by the Signoz team where they would alert on not seeing some specific event happening for x time. This can be tricky if the event is directly related to a user interaction.
Super big disclaimer: founder at a monitoring company that solve 1 and 2, not 3.