Live data from Hacker News

Ask HN: How to do simple heartbeat monitoring?

news.ycombinator.com

41–50 of 86 posts

Re: Ask HN: How to do simple heartbeat monitoring?

#42
post #25

Depending on your expected traffic patterns and volume, no responses to report for an extended period of time is its own data point.

In the old days when telemetry was exotic this was the answer.

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.

Re: Ask HN: How to do simple heartbeat monitoring?

#44
post #31

If you want super minimal, something like this might work? #!/bin/bash # Add this script to cron to run at whatever duration you desire. # URL to be checked URL="https://example.com/test.php" # Email for alerts EMAIL="root@example.com" # Perform the HTTP request and extract the status code with 10 second timeout. STATUS=$(curl -o /dev/null -s -w "%{http_code}\n" --max-time 10 $URL) # Check if the status code is not 2…

As a slight variation, you could send an alert to the PagerDuty API by replacing “Send email alert” with something like: # Send PagerDuty alert curl -X POST https://events.pagerduty.com/...

Added.

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.

Re: Ask HN: How to do simple heartbeat monitoring?

#45
If this is a cloud deployment, there might be a recommended method native to your cloud if you search for synthetic monitoring or canary.

For example, AWS recommends using CloudWatch Synthetics to create a canary: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitori...

Re: Ask HN: How to do simple heartbeat monitoring?

#48
post #19

I clicked to say something about Instrumentation Amplifiers or interfacing with chest straps ;) 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.

What did you want to say about instrumentation amplifiers / chest straps? :eyes:

Re: Ask HN: How to do simple heartbeat monitoring?

#49
post #31

If you want super minimal, something like this might work? #!/bin/bash # Add this script to cron to run at whatever duration you desire. # URL to be checked URL="https://example.com/test.php" # Email for alerts EMAIL="root@example.com" # Perform the HTTP request and extract the status code with 10 second timeout. STATUS=$(curl -o /dev/null -s -w "%{http_code}\n" --max-time 10 $URL) # Check if the status code is not 2…

You should include a timeout in the curl to detect if it hangs, or if it gets slower than it should be.

Added!
Post reply on HN