如何使用Prometheus监控docker容器的状态,看看它是up还是down?

问题描述 投票:0回答:1

我目前使用prometheus和cadvisor来监控容器,我目前有一个名为timesheet的容器,如何判断这个容器的状态是up还是down?

prometheus cadvisor
1个回答
0
投票

您可以使用名为

container_last_seen
cadvisor 指标。如果指标在查询时存在,则容器已启动,否则容器已关闭。用于检测容器是否启动或关闭的 PromQL 查询为:
absent(container_last_seen{container="MY_CONTAINER"})

使用 Prometheus 的容器环境中警报的常见查询的一个很好的来源是:https://samber.github.io/awesome-prometheus-alerts/rules#rule-docker-containers-1-2

去那里看看,你会得到很多好的结果。

© www.soinside.com 2019 - 2024. All rights reserved.