eventhorizon
eventhorizon

Reputation: 3377

How do I get the number of running instances per docker swarm service as a prometheus metric?

For me it seems impossible to get a reliable metric containing all services and their container states (and count).

Using the "last seen" from cadvisor does not work - it is unreliable; there are some open bugs... Using the docker metric I only get the number of total instances running, stopped,...

Does anyone have an idea?

Upvotes: 1

Views: 1772

Answers (1)

Aziz Zoaib
Aziz Zoaib

Reputation: 781

May be below query can help ..

count(count(container_tasks_state{container_label_com_docker_swarm_service_name=~".+", container_label_com_docker_swarm_node_id=~"$node_id"}) by (container_label_com_docker_swarm_service_name))

Use above query in Grafana, prometheus being datasource.

Upvotes: 2

Related Questions