当ArgoCD应用程序不健康的X分钟不健康时,请使用Prometheus和Grafana

发布于 2025-01-24 04:09:56 字数 566 浏览 3 评论 0原文

我正在尝试建立一个Grafana面板,该面板显示AgroCD应用程序多长时间不健康,并且是否保持不健康15分钟。到目前为止,我的promql查询是:

sum(count_over_time(argocd_app_info{health_status!="Healthy"}[20m])) by (name)

”在此处输入图像说明“

这使我非常接近。该应用程序不健康的每一分钟每分钟都会增加线图,最多可达20分钟。我可以将限制设置为15分钟以提醒。

问题在于,该应用程序健康的每一分钟都会减少。这意味着该应用程序可以在过去20分钟中处于进步状态15,即使在此期间完成并恢复了几次健康状态。

我希望在应用程序健康后立即降至零,而不是减少每一分钟的应用程序。如何更改promql查询来做到这一点?

I am trying to set up a grafana panel that shows how long an ArgoCD app has been unhealthy and alert if it stays unhealthy for 15 minutes. My PromQL query so far is:

sum(count_over_time(argocd_app_info{health_status!="Healthy"}[20m])) by (name)

enter image description here

This gets me pretty close. The line graph increments every minute that the app is unhealthy, up to a maximum of 20 minutes. I can set a limit at 15 minutes to alert on.

The problem is that it decrements every minute the app is healthy. This means the app can be in a progressing state for 15 out of the past 20 minutes and alert, even if it finished progressing and went back to healthy several times in that period.

Instead of decrementing every minute the app is healthy, I want the line to drop to zero as soon as the app becomes healthy. How do I change the PromQL query to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尾戒 2025-01-31 04:09:56

我发现了。似乎您需要在应用程序同步时乘以值为0的向量。这是查询:

sum(count_over_time(argocd_app_info{health_status!="Healthy"}[20m]) * argocd_app_info{health_status!="Healthy"}) by (name)

“在此处输入图像描述”

查询有点长且令人困惑,但可以工作。

I figured it out. Seems like you need to multiply by a vector that has a value of 0 whenever the app is in sync. Here's the query:

sum(count_over_time(argocd_app_info{health_status!="Healthy"}[20m]) * argocd_app_info{health_status!="Healthy"}) by (name)

enter image description here

The query is a bit long and confusing, but it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文