TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How to do simple heartbeat monitoring?

108 点作者 benjbrooks大约 1 年前
Hey there!<p>My team is hosting an API that sends open telemetry data to Signoz &amp; manages on-call via PagerDuty. We&#x27;ve configured Signoz to hit Pagerduty when there&#x27;s a series of 500 errors.<p>However, our server went down last night and NO opentel data was sent to Signoz. We weren&#x27;t notified that the server went down as there weren&#x27;t 500 responses to report. What&#x27;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&#x27;s API? Should I be migrating to another monitoring service?<p>Any advice would be appreciated!

45 条评论

runjake大约 1 年前
If you want super minimal, something like this might work?<p><pre><code> #!&#x2F;bin&#x2F;bash # Add this script to cron to run at whatever duration you desire. # URL to be checked URL=&quot;https:&#x2F;&#x2F;example.com&#x2F;test.php&quot; # Email for alerts EMAIL=&quot;root@example.com&quot; # Perform the HTTP request and extract the status code with 10 second timeout. STATUS=$(curl -o &#x2F;dev&#x2F;null -s -w &quot;%{http_code}\n&quot; --max-time 10 $URL) # Check if the status code is not 200 if [ &quot;$STATUS&quot; -ne 200 ]; then # Send email alert echo &quot;The URL $URL did not return a 200 status code. Status was $STATUS.&quot; | mail -s &quot;URL Check Alert&quot; $EMAIL # Instead of email, you could send a Slack&#x2F;Teams&#x2F;PagerDuty&#x2F;Pushover&#x2F;etc, etc alert, with something like: curl -X POST https:&#x2F;&#x2F;events.pagerduty.com&#x2F;... fi </code></pre> Edit: updated with suggested changes.
评论 #40277374 未加载
评论 #40277436 未加载
azeemba大约 1 年前
A lot of vendors offer this and call it &quot;synthetic monitoring&quot;. They will repeatedly send requests that you configure and record the success rate.<p>They usually all have pager duty integration as well.<p>Some examples:<p>Datadog: <a href="https:&#x2F;&#x2F;docs.datadoghq.com&#x2F;synthetics&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.datadoghq.com&#x2F;synthetics&#x2F;</a> Grafana cloud: <a href="https:&#x2F;&#x2F;grafana.com&#x2F;grafana&#x2F;plugins&#x2F;grafana-synthetic-monitoring-app&#x2F;" rel="nofollow">https:&#x2F;&#x2F;grafana.com&#x2F;grafana&#x2F;plugins&#x2F;grafana-synthetic-monito...</a>
评论 #40277418 未加载
Gys大约 1 年前
<a href="https:&#x2F;&#x2F;heartbeat.sh&#x2F;" rel="nofollow">https:&#x2F;&#x2F;heartbeat.sh&#x2F;</a><p>Free and easy. Not affiliated, just a happy user.<p>I combine it with a service like uptimerobot to get messages if the heartbeat stopped.
cweagans大约 1 年前
You&#x27;re looking for a dead man&#x27;s switch. <a href="https:&#x2F;&#x2F;deadmanssnitch.com" rel="nofollow">https:&#x2F;&#x2F;deadmanssnitch.com</a> is a good hosted service or Uptime Kuma (<a href="https:&#x2F;&#x2F;github.com&#x2F;louislam&#x2F;uptime-kuma">https:&#x2F;&#x2F;github.com&#x2F;louislam&#x2F;uptime-kuma</a>) can be configured to do the same thing.
评论 #40278011 未加载
评论 #40277756 未加载
what2大约 1 年前
You need to implement a deadman switch. For example if using Prometheus you can configure it to access an HTTP endpoint of a deadman switch service every X seconds. When that service detects you have not accessed it in some time it will alert you.<p>For example: <a href="https:&#x2F;&#x2F;blog.ediri.io&#x2F;how-to-set-up-a-dead-mans-switch-in-prometheus" rel="nofollow">https:&#x2F;&#x2F;blog.ediri.io&#x2F;how-to-set-up-a-dead-mans-switch-in-pr...</a>
评论 #40276947 未加载
benjbrooks大约 1 年前
Update:<p>Thanks for your recommendations everyone! We decided to go the route of measuring successful hits on the endpoint associated with our docs (inside our monitoring service). That&#x27;s the default health check associated with our load balancer, so it gets hit periodically (built-in cron job). We just added a signoz alert that is triggered if the sum of those successful calls over the past X seconds falls below a threshold.
评论 #40279560 未加载
guzik大约 1 年前
I can highly recommend Better Stack. We have never been let down by their service.
评论 #40277474 未加载
评论 #40276769 未加载
dvlsg大约 1 年前
Depending on your expected traffic patterns and volume, no responses to report for an extended period of time is its own data point.
评论 #40277472 未加载
foobarqux大约 1 年前
Healthchecks.io is very simple to use and free for low usage (including 5 free sms per month)
geor9e大约 1 年前
I came here ready to pontificate on the wild world of signal processing for electrocardiography and photoplethysmography sensors. Nevermind.
tomsun2812 个月前
Maybe can try use opensource project apache hertzbeat to monitoring heartbeat. <a href="https:&#x2F;&#x2F;github.com&#x2F;apache&#x2F;hertzbeat">https:&#x2F;&#x2F;github.com&#x2F;apache&#x2F;hertzbeat</a>
roboben大约 1 年前
<a href="https:&#x2F;&#x2F;checklyhq.com" rel="nofollow">https:&#x2F;&#x2F;checklyhq.com</a><p>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.
winrid大约 1 年前
I&#x27;ve been using UptimeRobot since 2019 for FastComments, relatively happy. They have a PagerDuty integration, although I just use the built in text&#x2F;email alerts ATM.
encoderer大约 1 年前
This basic monitoring primitive is the first thing we started with at Cronitor[1]. I was a software engineer at my day job and needed a way to be alerted when something <i>doesn&#x27;t</i> happen.<p>We have a decent free plan that would probably work for you.<p>[1] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7917587">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7917587</a>
notatoad大约 1 年前
we use updown.io for this and are happy with it.<p>there&#x27;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&#x27;s not part of the rest of our monitoring stack, not part of our own codebase, and not something we manage.
评论 #40278593 未加载
jrockway大约 1 年前
This is normal website monitoring. There are a billion services that do this. The cloud providers have them. I use Oh Dear.<p>Something that can happen is that your alerting system stops working. I wrote alertmanager-status to bridge Alertmanager to these website uptime checkers: <a href="https:&#x2F;&#x2F;github.com&#x2F;jrockway&#x2F;alertmanager-status">https:&#x2F;&#x2F;github.com&#x2F;jrockway&#x2F;alertmanager-status</a> Basically, Alertmanager gives it a fake alert every so often. If that arrives, then alertmanager-status reports healthy to your website upness checker. If it doesn&#x27;t arrive in a given time window, then that reports unhealthy, and you&#x27;ll get an alert that alerts don&#x27;t work. I use this for my personal stuff and at work and ... Alertmanager has never broken, so it was a waste of time to write ;)
sixhobbits大约 1 年前
This is one of those things that _seems_ really simple but the details make it pretty complicated.<p>Not sure about Signoz and PagerDuty, but there are plenty freemium services like UpTimeRobot that work fine for basics.<p>And then something like AWS CloudWatch has a lot more advanced options about how to treat missing data.<p><a href="https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;AmazonCloudWatch&#x2F;latest&#x2F;monitoring&#x2F;AlarmThatSendsEmail.html" rel="nofollow">https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;AmazonCloudWatch&#x2F;latest&#x2F;monitori...</a><p>With a lot of knobs to tune around what intervals you need and what counts as &#x27;down&#x27;, which you&#x27;ll want to think about pretty carefully given what you need.
et-al大约 1 年前
&gt; <i>Should I have a serverless function running on a timer that uses Pagerduty&#x27;s API?</i><p>If you&#x27;re on AWS, there&#x27;s already heartbeat monitoring and that can integrate with CloudWatch to notify PagerDuty.
divbzero大约 1 年前
If this is a cloud deployment, there might be a recommended method native to your cloud if you search for <i>&lt;your cloud provider&gt; synthetic monitoring</i> or <i>&lt;your cloud provider&gt; canary</i>.<p>For example, AWS recommends using CloudWatch Synthetics to create a canary: <a href="https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;AmazonCloudWatch&#x2F;latest&#x2F;monitoring&#x2F;CloudWatch_Synthetics_Canaries.html" rel="nofollow">https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;AmazonCloudWatch&#x2F;latest&#x2F;monitori...</a>
评论 #40277924 未加载
jarofgreen大约 1 年前
I had a similar concern about a custom monitoring script that was regularly writing out a metrics file in Prometheus format to be picked up by the Prometheus node monitor. What if the script breaks?<p>So I set the script to also write out a metric that was just the time stamp the metrics were last updated. Then it was simple to set up an alert in Prometheus - I can&#x27;t access the config now so you&#x27;ll have to look it up yourself, but it was basically &quot;alert if metric less than now minus a time gap&quot;
评论 #40278082 未加载
devoutsalsa大约 1 年前
Writing a heartbeat process using UDP for a Fluentd logger is as one of the first things I learned in Elixir! In my case, basically when then there was no heartbeat, the TCP forwarder &#x2F;w a connection pool would be taken offline. When the heartbeat came back, the forwarder was free to send messages again.<p>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.
ttymck大约 1 年前
For my applications, monitored by prometheus + grafana, we have alerts when no data is reported for certain metrics in the past 5 minutes, indicating a malfunction in the subsystem.<p>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.
AH4oFVbPT4f8大约 1 年前
<a href="https:&#x2F;&#x2F;www.wormly.com" rel="nofollow">https:&#x2F;&#x2F;www.wormly.com</a><p>I run multiple e-commerce websites where up time is critical and the types of errors could be anything. I use a service called Wormly that hits specific end points from multiple locations around the world. I&#x27;m not affiliated, just a happy customer.
anikdas大约 1 年前
We have been using Cloudflare health check at work for this and we have been pretty happy with this. We have this integrated with slack and opsgenie as well.<p><a href="https:&#x2F;&#x2F;developers.cloudflare.com&#x2F;health-checks&#x2F;" rel="nofollow">https:&#x2F;&#x2F;developers.cloudflare.com&#x2F;health-checks&#x2F;</a>
jurajmasar大约 1 年前
Better Stack offers heartbeat monitoring for free, here&#x27;s the docs: <a href="https:&#x2F;&#x2F;betterstack.com&#x2F;docs&#x2F;uptime&#x2F;cron-and-heartbeat-monitor&#x2F;" rel="nofollow">https:&#x2F;&#x2F;betterstack.com&#x2F;docs&#x2F;uptime&#x2F;cron-and-heartbeat-monit...</a><p>Disclaimer: I&#x27;m the founder
nicky0大约 1 年前
I use Uptime Robot for this: <a href="https:&#x2F;&#x2F;uptimerobot.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;uptimerobot.com&#x2F;</a><p>I just configure it to access some endpoint on the API server. It checks it every minute and if it fails (non 200) it pings me.<p>You can also set it up in more complex ways but this is easy.
kraig911大约 1 年前
Back in the day I had a script that would telnet once every so often to a configured time frame and listen on each one. Then another script monitoring the number of each and if the average over 10 mins was less than 90% each node send a message in your manner of choice (email or something)
eps大约 1 年前
&gt; <i>What&#x27;s the easiest way to have a cron-like query hit our API and integrate with our existing stack?</i><p>Write a cron job that greps the logs and pulls on your api with curl?<p>With another 20 minutes of work you can remember the log size on each run and grep only what&#x27;s new on the next run.
hatthew大约 1 年前
Not familiar with Signoz, but a simple solution should be to check if the total number of requests in the past X duration is &lt;= Y, where X depends on how much traffic you see and Y is some threshold such as 1, 1000, or min(yesterday, last_week).
compumike大约 1 年前
We do this at Heii On-Call: <a href="https:&#x2F;&#x2F;heiioncall.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;heiioncall.com&#x2F;</a><p>Outbound Probes to hit your exposed HTTP services, or Inbound Liveness for your own cron jobs etc to check in.
rozenmd大约 1 年前
OnlineOrNot has a cron job&#x2F;scheduled task monitoring system that integrates with PagerDuty fwiw<p>edit: on second read, it sounds like regular uptime monitoring for your API would do the trick
renewiltord大约 1 年前
All monitoring systems have a no-data condition. Use that.
seper8大约 1 年前
I use grafana. Setup an endpoint on the backend that uses things like the database to check if it can still connect. Every 10 sec. If it fails I get a text.
Atotalnoob大约 1 年前
To me, this is the biggest problem with OpenTelemetry.<p>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
GauntletWizard大约 1 年前
Prometheus makes this a basic part of monitoring, &quot;up&quot; is a synthetic metric based on whether or not metrics gathering succeeds.
nprateem大约 1 年前
Invert the flux capacitor so it fires an alert if it doesn&#x27;t receive a heartbeat. This should be a separate alert to your 500 one.
beeboobaa3大约 1 年前
Just have your monitoring system hit some health check endpoint of yours to verify everything is reachable &amp; healthy.
papa_autist大约 1 年前
healthchecks.io
评论 #40277633 未加载
lmeyerov大约 1 年前
We have two different external uptime status monitoring services, which has helped
Joel_Mckay大约 1 年前
In general the &quot;are-you-alive&quot; messages are redundant, as the data exchange messages serves the same purpose.<p>While my legal encumbrances prohibit helping you with actual code, I would recommend looking at watchdog processes.<p>For example, even a simple systemd periodic trigger that runs a script every minute that does general house keeping can work. i.e. a small script has the advantage of minimal library dependencies, fast&#x2F;finite run state, and flexible behavior (checking cpu&#x2F;network loads for nuisance traffic, and playing possum when a set threshold exceeded.)<p>Distributed systems is hard, but polling generally does not scale well (i.e. the cost of a self-check is locally fixed, but balloons on a cluster if going beyond a few fixed peer-checks).<p>And yeah, some clowns that think they are James Bond have been DDoS small boxes on Sun (they seem to be blindly hitting dns and ntp ports hard). We had to reset the tripwire on a 6 year old hobby host too.<p>tip, rate limiting firewall rules that expose whitelisted peers&#x2F;admins to bandwidth guarantees is wise. Otherwise any cluster&#x2F;heartbeats can be choked into a degraded state.<p>Don&#x27;t take it personally, and enjoy a muffin with your tea. =3
devneelpatel大约 1 年前
OneUptime.com does this for you and is 100% open-source.
liveoneggs大约 1 年前
statuscake &amp; new relic both have generous free tiers
g8oz大约 1 年前
I&#x27;ve heard good things about UptimeRobot.
nsguy大约 1 年前
I clicked to say something about Instrumentation Amplifiers or interfacing with chest straps ;)<p>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&#x27;t know.
评论 #40277590 未加载
评论 #40277789 未加载
评论 #40277827 未加载
评论 #40278944 未加载
jeffbarg大约 1 年前
Believe you can do this in Signoz: <a href="https:&#x2F;&#x2F;signoz.io&#x2F;docs&#x2F;monitor-http-endpoints&#x2F;">https:&#x2F;&#x2F;signoz.io&#x2F;docs&#x2F;monitor-http-endpoints&#x2F;</a>
评论 #40276773 未加载