Adding Prometheus to the mix is relatively straightforward. We'll add a new Prometheus service while sending its logs to Loki to be aggregated (why not?). We'll also need to configure Prometheus to scrape the metric endpoints of our services. We did this earlier in this book, so it should be no problem for us to configure scrapers for each service.
First, let's add Prometheus to our stack:
prometheus: image: "prom/prometheus:${PROM_TAG-latest}" ports: - "9090:9090" volumes: - "${PWD-.}/prometheus:/etc/prometheus" command: --config.file=/etc/prometheus/prometheus.yaml networks: - loki logging: driver: loki options: loki-url: "http://host.docker.internal:3100/loki/api/v1/push"
We'll need to create a volume directory for Prometheus to store our configuration file (namedprometheus.yml).
The...