stefanprodan / dockprom

Docker hosts and containers monitoring with Prometheus, Grafana, cAdvisor, NodeExporter and AlertManager
MIT License
5.98k stars 1.72k forks source link

Swarm #1

Closed xeor closed 7 years ago

xeor commented 7 years ago

First; VERY nice put toghter! Thank you very much for this!

I must admit, I don't have much experience with prometheus, but how would a swarm-mode setup work with this project? Would it be as easy as setting up collectors on all node and have the monitor network on overlay?

ps: Sorry for submitting this as an issue.. It is sort of a feature request 👍

stefanprodan commented 7 years ago

Hello @xeor

When running the Prometheus stack on Docker Swarm you need to decide if you want to use the same Prometheus database for all Swarm nodes. If that's the case, then you need to do the following:

The challenge with this setup is that Swarm will load balance the Prometheus scraping calls to NodeExporter and cAdvisor. So you can't use the host name of these 2 services in the Prometheus config. Docker Swarm doesn't have a Prometheus discovery integration like Kubernetes has. I know that Docker plans to do this, but right now it's not available.

A workaround would be to use the Prometheus dns_sd_config for service discovery, or you could deploy a dedicated NodeExporter and cAdvisor service for each Swarm node and use the node constrain to prevent Swarm from moving your services between nodes.

I plan to extend dockprom to Docker Swarm in the future.

xeor commented 7 years ago

Thanks for a very good answer, it's all logical now :)

Looking forward to a future update..! Keep it up!

larryboymi commented 7 years ago

I had to change a few of the queries on the container grafana dashboard to do sums, but now it's working pretty decently. I'm still trying to figure out how to get container (or service) names to show up instead of the generated id's, but wonder if that might be a cAdvisor/newest swarm issue. Thanks for your tips.

alexsandro-xpt commented 7 years ago

Swarm Mode +1

Hermain commented 7 years ago

"A workaround would be to use the Prometheus dns_sd_config for service discovery" Could you please explain what speaks against this workaround? It seems to solve the problem of the swarm loadbalancing the requests.

stefanprodan commented 7 years ago

@Hermain if you use the dns for node-exporter than you'll not be able to link the source to the hosts. every time you'll restart node-export it will get another IP, how will you match the source to the real host name?

Hermain commented 7 years ago

@stefanprodan I only wanted to understand why you call it a workaround and not a solution. Now I understand. The problem is, you can't link the node-exporter instance to a host. Thank you for the explanation.

stefanprodan commented 7 years ago

One way I could think of is to inject a label with the Docker Swarm Node ID on each metric in node-exporter. This way, even if the node-exporter changes IP you have the same ID, since this is generated at Swarm init. I'm trying to port dockprom to swarm this week and I'll post on the blog if I manage to run it properly.

vguna commented 7 years ago

Sounds promising!

pascalandy commented 6 years ago

IMHO, we could split Swarm Version to another project. At this point, I assume this project is for a single host monitoring

imajes commented 3 years ago

pinging in to see where this might go... also interested.