Scraping and visualizing metrics

Now that all the Prometheus endpoints are prepared, we can now proceed with collecting these metrics in Prometheus itself. Afterwards, we will run Grafana to visualize all of the metrics that we have exposed in the previous subsection.

The following steps will deploy Prometheus as a service in our Docker Swarm cluster:

  1. First, let's prepare a service config for Prometheus in a file called prometheus.yml, as follows:
---global:  scrape_interval: 15sscrape_configs:  - job_name: cadvisor    dns_sd_configs:      - names:          - 'tasks.cadvisor'        type: A        port: 8080  - job_name: docker    static_configs:      - targets:          - dockerhost:1337          - node1:1337

In the preceding configuration, we scraped each Docker Engine in our Docker Swarm cluster ...

Get Docker High Performance - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.