【发布时间】:2021-08-18 00:26:51
【问题描述】:
我有服务 A,它是某个队列的消费者。
我可以使用 Prometheus 轻松监控和统计任何消耗的消息:)
from prometheus_client import start_http_server, Counter
COUNTER_IN_MSGS = Counter('msgs_consumed', 'count consumed messages')
start_http_server(8000)
while(queue not empty):
A.consume(queue)
COUNTER_IN_MSGS.inc()
但是,有一天我决定将我的消费者复制到 10 个消费者,它们执行相同的 {A1,A2...,A10},使用相同的代码但在 10 个不同的 docker 上运行(在我的例子中是 K8s 上的容器)。
如何使用 Prometheus 监控它们?我应该将我的代码和一些 id 更改为每个消费者作为标签吗?
最好的做法是什么才能将它们加在一起,同时又能单独依靠它们?
【问题讨论】:
标签: python docker kubernetes prometheus monitor