diff --git a/swarm/core.yml b/swarm/core.yml index e9570c0..b7f036f 100644 --- a/swarm/core.yml +++ b/swarm/core.yml @@ -162,6 +162,11 @@ services: - --log.level=INFO # Enable the Dashboard and API - --api=true + # Enable Prometheus metrics for scraping by Prometheus + - --metrics.prometheus=true + - --metrics.prometheus.buckets=0.1,0.3,1.2,5.0 + - --metrics.prometheus.addEntryPointsLabels=true + - --metrics.prometheus.addServicesLabels=true networks: # Use the public network created to be shared between Traefik and # any other service that needs to be publicly available with HTTPS diff --git a/swarm/prometheus.yml b/swarm/prometheus.yml index d712f25..de0e579 100644 --- a/swarm/prometheus.yml +++ b/swarm/prometheus.yml @@ -1,6 +1,10 @@ volumes: prometheus_data: {} +configs: + prometheus_config: + file: ./prometheus/prometheus.yml + networks: traefik-public: external: true @@ -17,8 +21,10 @@ services: - '--web.enable-lifecycle' volumes: - prometheus_data:/prometheus - - /var/data/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro - /var/data/prometheus/rules:/etc/prometheus/rules:ro + configs: + - source: prometheus_config + target: /etc/prometheus/prometheus.yml networks: - traefik-public deploy: diff --git a/swarm/prometheus/prometheus.yml b/swarm/prometheus/prometheus.yml new file mode 100644 index 0000000..e1f834f --- /dev/null +++ b/swarm/prometheus/prometheus.yml @@ -0,0 +1,19 @@ +# Prometheus configuration for the Swarm stack. +# Mounted into the Prometheus container as a Docker config. +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + # Scrape Prometheus itself + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] + + # Scrape Traefik Prometheus metrics + # Both services are on the traefik-public overlay network, + # so 'traefik' resolves via Swarm DNS. + - job_name: 'traefik' + static_configs: + - targets: ['traefik:8080'] + metrics_path: /metrics