![]() The Linux Foundation has registered trademarks and uses trademarks. © Prometheus Authors 2014-2023 | Documentation Distributed under CC-BY-4.0 Please help improve it by filing issues or pull requests. That given proper configuration, this should be pluggable to any existing stack. The service discovery makes no assumptions about your Swarm stack, in such a way Prometheus server (under the "Status" menu) to see all the discovered labels. Don't hesitate to look at the "Service Discovery" page of your Targets to monitor and how, for the tasks, there is more than 25 labelsĪvailable. There are many discovery labels you can play with to better determine which Options to connect to Swarm using HTTP and HTTPS, if you prefer that Prometheus offers additional configuration The above dockerswarm_sd_configs entries have a field host: host: unix:///var/run/docker.sock source_labels: Īdding a docker_node label to the targets - source_labels: Scraping metrics via a certain network only - source_labels: Here are other relabel configs that you might find useful. The Prometheus Documentation contains the full list of labels, but That last part takes the label prometheus-job of the task and turns it intoĪ target label, overwriting the default dockerswarm job label that comes from Targets which have a prometheus-job label. When we deployed our cadvisor, we have added a label prometheus-job=cadvisor.Īs Prometheus fetches the tasks labels, we can instruct it to only keep the Monitoring tasks that should be shut down. Out example, we only keep the targets that should be running. source_labels: ĭocker Swarm exposes the desired state of the tasks over the API. Let's analyze each part of the relabel configuration. # Use the prometheus-job Swarm label as Prometheus job label. # Only keep containers that have a `prometheus-job` label. # Only keep containers that should be running. # Create a job for Docker Swarm containers. This is a minimal prometheus.yml file to monitor it: scrape_configs: mount type=bind,src=/var/lib/docker,dst=/var/lib/docker,ro \ mount type=bind,src=/var/run,dst=/var/run \ mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock,ro \ mode=global -publish target=8080,mode=host \ We will deploy cadvisor, whichĮxposes container resources metrics: docker service create -name cadvisor -l prometheus-job=cadvisor \ ![]() However, using relabel_configs is recommended as itĮnables Prometheus to reuse the same API calls across identical Docker Swarm source_labels: įor the nodes role, you can also use the port parameter ofĭockerswarm_sd_configs. # Make Prometheus scrape itself for metrics. Then, you can configure Prometheus to scrape the Docker daemon, by providing theįollowing prometheus.yml file: scrape_configs: The Docker documentation contains more info about this. Instead of 0.0.0.0, you can set the IP of the Docker Swarm node.Ī restart of the daemon is required to take the new configuration into account. You can enable them by editing /etc/docker/daemon.json and setting the Let's dive into the service discovery itself.ĭocker itself, as a daemon, exposes metrics that can be Prometheus runs on a Docker Swarm manager node and has access to the Docker Setting up Prometheusįor this guide, you need to setup Prometheus. NOTE: The rest of this post assumes that you have a Swarm running. Prometheus will only discover tasks and service that expose ports. To use the tasks role instead of this one. It will discover the ports exposed by the services. The third one, services, will discover the services deployed in the Each task gets its associated service labels. The second role, tasks, represents any individual container deployed in the ItĬan be used to automatically monitor the Docker daemons or the Node Exporters The first role, nodes, represents the hosts that are part of the Swarm. The Docker Swarm service discovery contains 3 different roles: nodes, services, Docker Swarm service discovery architecture This guide demonstrates how to use that service discovery mechanism. Prometheus can discover targets in a Docker Swarm cluster, as of Adding a docker_node label to the targets.Scraping metrics via a certain network only.Docker Swarm service discovery architecture.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |