1

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?

eventhorizon
  • 2,977
  • 8
  • 33
  • 57

1 Answers1

2

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.

Aziz Zoaib
  • 661
  • 8
  • 21
  • 1
    This looks good. Now I have to find a way to resolve the node_id to hostname :-) (BTW: I have to leave out the outer count and add the `state="running"` to get what I want) – eventhorizon Aug 07 '18 at 13:52