Prometheus dns service discovery in docker swarm relabel instance

那年仲夏 提交于 2019-12-06 09:50:39

Service discovery for docker swarm setups isn’t supported well in Prometheus as there are many features missing on the swarm side.

The dns service discovery is one way to mitigate those missing features but in my opinion it isn’t a good solution and I recommend to not use it in production:

  • there is no way to provide additional information e.g. using SRV records
  • there is no information about how many instances should be running
  • as the the dns only lists the healthy tasks, the amount of scrape targets decreases when one task is no longer considered healthy which makes it harder to alert on misbehaving containers
  • when containers die and are restarted you will observe new instances as there is no information like the task slot available

Altogether these issues don’t allow this approach for being a reliable source for a monitoring system.

If you are really tied to using docker swarm, you should consider building a more sustainable solution by querying the docker api programmatically and using the file_sd service discovery mechanism of Prometheus. Please see this poc by containersolutions for reference: https://github.com/ContainerSolutions/prometheus-swarm-discovery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!