From 39f6078928ae8afbe0586738ec1819dc94bab5ad Mon Sep 17 00:00:00 2001 From: "Benjamin W. Broersma" Date: Mon, 9 Dec 2024 23:22:06 +0100 Subject: [PATCH 1/2] Add compose monitoring profile Fixes #1588 --- docker/batch-test.env | 2 +- docker/build.env | 2 +- docker/compose.yaml | 28 ++++++++++++++++++++++++++++ docker/defaults.env | 2 +- docker/develop.env | 2 +- documentation/Docker-metrics.md | 4 ++-- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/docker/batch-test.env b/docker/batch-test.env index 223f151d1..5b5f60fe1 100644 --- a/docker/batch-test.env +++ b/docker/batch-test.env @@ -8,7 +8,7 @@ INTERNETNL_DOMAINNAME=internet.test # use unique name to not conflict with integration tests COMPOSE_PROJECT_NAME=internetnl-batch-test -COMPOSE_PROFILES=batch,cron +COMPOSE_PROFILES=batch,cron,monitoring ENABLE_BATCH=True diff --git a/docker/build.env b/docker/build.env index 8cc319b99..0bcddb0fa 100644 --- a/docker/build.env +++ b/docker/build.env @@ -2,7 +2,7 @@ # include all compose files COMPOSE_FILE=docker/compose.yaml:docker/compose.build.yaml:docker/compose.development.yaml:docker/compose.integration-tests.yaml:docker/compose.test.yaml:docker/compose.tools.yaml:docker/compose.test-runner-develop.yaml:docker/compose.integration-tests.yaml -COMPOSE_PROFILES=connectiontest,cron,routinator,batch,build +COMPOSE_PROFILES=connectiontest,cron,monitoring,routinator,batch,build # don't expose HTTP(S) and DNS ports to the outside, this also causes issues due to being privileged ports WEBSERVER_PORT=80 diff --git a/docker/compose.yaml b/docker/compose.yaml index 811420175..4c39ba444 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -569,6 +569,7 @@ services: # start_interval: 5s start_period: 1m retries: 10 + profiles: - connectiontest @@ -752,6 +753,9 @@ services: internal: ipv4_address: $IPV4_IP_GRAFANA_INTERNAL + profiles: + - monitoring + prometheus: image: ${DOCKER_IMAGE_PROMETHEUS} @@ -782,6 +786,9 @@ services: volumes: - prometheus-data:/prometheus + profiles: + - monitoring + alertmanager: image: ${DOCKER_IMAGE_PROMETHEUS_ALERTMANAGER} @@ -824,6 +831,9 @@ services: networks: - internal + profiles: + - monitoring + redis-exporter: image: ${DOCKER_IMAGE_REDIS_EXPORTER} @@ -841,6 +851,9 @@ services: networks: - internal + profiles: + - monitoring + statsd-exporter: image: ${DOCKER_IMAGE_STATSD_EXPORTER} @@ -862,6 +875,9 @@ services: aliases: - statsd + profiles: + - monitoring + celery-exporter: image: ${DOCKER_IMAGE_CELERY_EXPORTER} command: @@ -883,6 +899,9 @@ services: rabbitmq: condition: service_healthy + profiles: + - monitoring + # https://github.com/prometheus/node_exporter#docker node-exporter: image: ${DOCKER_IMAGE_NODE_EXPORTER} @@ -913,6 +932,9 @@ services: - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket - prometheus-textfile-directory:/prometheus-textfile-directory + profiles: + - monitoring + docker_stats_exporter: # https://github.com/jan4843/docker_stats_exporter image: ${DOCKER_IMAGE_DOCKER_STATSD_EXPORTER} @@ -932,6 +954,9 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock + profiles: + - monitoring + nginx_logs_exporter: image: ${DOCKER_IMAGE_NGINX_LOGS_EXPORTER} command: @@ -953,6 +978,9 @@ services: volumes: - nginx-logs-exporter:/var/log/nginx/prometheus-nginxlog-exporter/ + profiles: + - monitoring + volumes: postgres: {} postgres-backups: {} diff --git a/docker/defaults.env b/docker/defaults.env index bebe5f775..ca89d0505 100644 --- a/docker/defaults.env +++ b/docker/defaults.env @@ -146,7 +146,7 @@ COMPOSE_PROJECT_NAME=internetnl COMPOSE_FILE=docker/compose.yaml # enable all services and crons -COMPOSE_PROFILES=connectiontest,cron,routinator +COMPOSE_PROFILES=connectiontest,cron,monitoring,routinator # interval for batch processing BATCH_SCHEDULER_INTERVAL=1 diff --git a/docker/develop.env b/docker/develop.env index 36493c41e..e2f87c11c 100644 --- a/docker/develop.env +++ b/docker/develop.env @@ -70,4 +70,4 @@ INTERNETNL_BRANDING=False NGINX_PROXY_CACHE=off # only enable application services -COMPOSE_PROFILES=connectiontest +COMPOSE_PROFILES=connectiontest,monitoring diff --git a/documentation/Docker-metrics.md b/documentation/Docker-metrics.md index 0f9d84695..a28db7d67 100644 --- a/documentation/Docker-metrics.md +++ b/documentation/Docker-metrics.md @@ -1,6 +1,6 @@ # Metrics -The Docker deployment includes a metrics collection system which is available on production as well as development/test environments. It consists of a Prometheus metrics server which scrapes metrics from various exporters. Grafana is provided as frontend to visualise metrics and create graphs/dashboards. +The Docker deployment includes a metrics collection system which is available on production as well as development/test environments. It consists of a Prometheus metrics server which scrapes metrics from various exporters. Grafana is provided as frontend to visualise metrics and create graphs/dashboards. The various exporters, Prometheus and Grafana containers can be disabled by not loading the `monitoring` profile, by overriding the default profiles with e.g. `COMPOSE_PROFILES=batch,cron` in `local.env`. To view metrics and graphs visit the `/grafana/` endpoint. Eg: `http://localhost:8080/grafana/` for development and `https://example.com/grafana/` for production. For development the user/password is set to `test/test`, for production users can be configured using the `MONITORING_AUTH_RAW` variable in `docker/local.env` (see `docker/defaults.env` for information). @@ -26,4 +26,4 @@ The Grafana service is used because Prometheus does not include curl. The URL's **notice**: Please note that Grafana (and the rest of the monitoring containers) are not connected to the public interface and don't have internet access. So adding Dashboards via "Import via grafana.com" does not work. Dashboard from grafana.com can be imported using the JSON model. -Dashboard can be manually created through the Grafana web interface and can be saved there. Existing Dashboard cannot be modified this way as they are provisioned from the Docker image. Either duplicate the Dashboard with your own modifications or export the Dashboard JSON Model and update the files at: https://github.com/internetstandards/Internet.nl/tree/docker/docker/monitoring/grafana/dashboards \ No newline at end of file +Dashboard can be manually created through the Grafana web interface and can be saved there. Existing Dashboard cannot be modified this way as they are provisioned from the Docker image. Either duplicate the Dashboard with your own modifications or export the Dashboard JSON Model and update the files at: https://github.com/internetstandards/Internet.nl/tree/main/docker/monitoring/grafana/dashboards From b1377427f5aa6929864531549a093ee2a86135f5 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Broersma" Date: Tue, 10 Dec 2024 00:06:40 +0100 Subject: [PATCH 2/2] Cleanup compose profiles Removing the unused batch profile from env. Adding the alertmanager profile to all monitoring services. --- docker/batch-test.env | 2 +- docker/build.env | 2 +- docker/compose.yaml | 9 +++++++++ documentation/Docker-metrics.md | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docker/batch-test.env b/docker/batch-test.env index 5b5f60fe1..cc7b4de7b 100644 --- a/docker/batch-test.env +++ b/docker/batch-test.env @@ -8,7 +8,7 @@ INTERNETNL_DOMAINNAME=internet.test # use unique name to not conflict with integration tests COMPOSE_PROJECT_NAME=internetnl-batch-test -COMPOSE_PROFILES=batch,cron,monitoring +COMPOSE_PROFILES=cron,monitoring ENABLE_BATCH=True diff --git a/docker/build.env b/docker/build.env index 0bcddb0fa..10d05d144 100644 --- a/docker/build.env +++ b/docker/build.env @@ -2,7 +2,7 @@ # include all compose files COMPOSE_FILE=docker/compose.yaml:docker/compose.build.yaml:docker/compose.development.yaml:docker/compose.integration-tests.yaml:docker/compose.test.yaml:docker/compose.tools.yaml:docker/compose.test-runner-develop.yaml:docker/compose.integration-tests.yaml -COMPOSE_PROFILES=connectiontest,cron,monitoring,routinator,batch,build +COMPOSE_PROFILES=connectiontest,cron,monitoring,routinator,build # don't expose HTTP(S) and DNS ports to the outside, this also causes issues due to being privileged ports WEBSERVER_PORT=80 diff --git a/docker/compose.yaml b/docker/compose.yaml index 4c39ba444..5034f02c6 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -754,6 +754,7 @@ services: ipv4_address: $IPV4_IP_GRAFANA_INTERNAL profiles: + - alertmanager - monitoring prometheus: @@ -787,6 +788,7 @@ services: - prometheus-data:/prometheus profiles: + - alertmanager - monitoring alertmanager: @@ -832,6 +834,7 @@ services: - internal profiles: + - alertmanager - monitoring redis-exporter: @@ -852,6 +855,7 @@ services: - internal profiles: + - alertmanager - monitoring statsd-exporter: @@ -876,6 +880,7 @@ services: - statsd profiles: + - alertmanager - monitoring celery-exporter: @@ -900,6 +905,7 @@ services: condition: service_healthy profiles: + - alertmanager - monitoring # https://github.com/prometheus/node_exporter#docker @@ -933,6 +939,7 @@ services: - prometheus-textfile-directory:/prometheus-textfile-directory profiles: + - alertmanager - monitoring docker_stats_exporter: @@ -955,6 +962,7 @@ services: - /var/run/docker.sock:/var/run/docker.sock profiles: + - alertmanager - monitoring nginx_logs_exporter: @@ -979,6 +987,7 @@ services: - nginx-logs-exporter:/var/log/nginx/prometheus-nginxlog-exporter/ profiles: + - alertmanager - monitoring volumes: diff --git a/documentation/Docker-metrics.md b/documentation/Docker-metrics.md index a28db7d67..51dfda971 100644 --- a/documentation/Docker-metrics.md +++ b/documentation/Docker-metrics.md @@ -1,6 +1,6 @@ # Metrics -The Docker deployment includes a metrics collection system which is available on production as well as development/test environments. It consists of a Prometheus metrics server which scrapes metrics from various exporters. Grafana is provided as frontend to visualise metrics and create graphs/dashboards. The various exporters, Prometheus and Grafana containers can be disabled by not loading the `monitoring` profile, by overriding the default profiles with e.g. `COMPOSE_PROFILES=batch,cron` in `local.env`. +The Docker deployment includes a metrics collection system which is available on production as well as development/test environments. It consists of a Prometheus metrics server which scrapes metrics from various exporters. Grafana is provided as frontend to visualise metrics and create graphs/dashboards. The various exporters, Prometheus and Grafana containers can be disabled by not loading the `monitoring` profile, by overriding the default profiles with e.g. `COMPOSE_PROFILES=cron` in `local.env`. To view metrics and graphs visit the `/grafana/` endpoint. Eg: `http://localhost:8080/grafana/` for development and `https://example.com/grafana/` for production. For development the user/password is set to `test/test`, for production users can be configured using the `MONITORING_AUTH_RAW` variable in `docker/local.env` (see `docker/defaults.env` for information).