From fdb9a4fc3ef9f8f184ec4d9dc90e90fc2f982d04 Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Sat, 11 Feb 2023 16:36:26 +0100 Subject: [PATCH] add prometheus --- .env.sample | 2 -- compose.prometheus.yml | 13 ++----------- prometheus.yml.tmpl | 5 +++++ prometheus_web.yml.tmpl | 2 -- scrape-config.example.yml | 4 ++++ 5 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 prometheus_web.yml.tmpl create mode 100644 scrape-config.example.yml diff --git a/.env.sample b/.env.sample index 5eacd0a..70a6b89 100644 --- a/.env.sample +++ b/.env.sample @@ -28,9 +28,7 @@ COMPOSE_FILE="$COMPOSE_FILE:compose.metrics.yml" # COMPOSE_FILE="$COMPOSE_FILE:compose.prometheus.yml" # PROMETHEUS_DOMAIN=prometheus.example.com # PROMETHEUS_YML_VERSION=v1 -# PROMETHEUS_WEB_YML_VERSION=v # SECRET_PROMETHEUS_ADMIN_PASSWORD_VERSION=v1 -# SECRET_PROMETHEUS_ADMIN_PASSWORD_HASHED_VERSION=v1 # ALERTMANAGER_CONFIG_VERSION=v1 # ALERTMANAGER_SMTP_FROM=noreply@autonomic.zone # ALERTMANAGER_SMTP_HOST=mail.gandi.net:587 diff --git a/compose.prometheus.yml b/compose.prometheus.yml index 6529d05..1567160 100644 --- a/compose.prometheus.yml +++ b/compose.prometheus.yml @@ -5,17 +5,13 @@ services: image: prom/prometheus:v2.34.0 secrets: - prometheus_admin_password - - prometheus_admin_password_hashed volumes: - prometheus-data:/prometheus:rw configs: - source: prometheus_yml target: /etc/prometheus/prometheus.yml - - source: prometheus_web_yml - target: /etc/prometheus/prometheus_web.yml command: - "--config.file=/etc/prometheus/prometheus.yml" - - "--web.config.file=/etc/prometheus/prometheus_web.yml" - "--storage.tsdb.path=/prometheus" - "--web.console.libraries=/usr/share/prometheus/console_libraries" - "--web.console.templates=/usr/share/prometheus/consoles" @@ -32,6 +28,8 @@ services: - "traefik.http.routers.${STACK_NAME}-prometheus.entrypoints=web-secure" - "traefik.http.routers.${STACK_NAME}-prometheus.tls=true" - "traefik.http.routers.${STACK_NAME}-prometheus.tls.certresolver=${LETS_ENCRYPT_ENV}" + - "traefik.http.routers.${STACK_NAME}-prometheus.middlewares=basicauth@file" + alertmanager: image: prom/alertmanager:v0.23.0 @@ -57,10 +55,6 @@ configs: template_driver: golang name: ${STACK_NAME}_prometheus_yml_${PROMETHEUS_YML_VERSION} file: prometheus.yml.tmpl - prometheus_web_yml: - template_driver: golang - name: ${STACK_NAME}_prometheus_web_yml_${PROMETHEUS_WEB_YML_VERSION} - file: prometheus_web.yml.tmpl alertmanager_config: template_driver: golang name: ${STACK_NAME}_alertmanager_config_${ALERTMANAGER_CONFIG_VERSION} @@ -72,9 +66,6 @@ volumes: alertmanager-data: secrets: - prometheus_admin_password_hashed: - external: true - name: ${STACK_NAME}_prometheus_admin_password_hashed_${SECRET_PROMETHEUS_ADMIN_PASSWORD_HASHED_VERSION} prometheus_admin_password: external: true name: ${STACK_NAME}_prometheus_admin_password_${SECRET_PROMETHEUS_ADMIN_PASSWORD_VERSION} diff --git a/prometheus.yml.tmpl b/prometheus.yml.tmpl index 03656f2..a1f5333 100644 --- a/prometheus.yml.tmpl +++ b/prometheus.yml.tmpl @@ -10,6 +10,11 @@ alerting: scrape_configs: - job_name: "default" + scrape_interval: 10s + metrics_path: "/metrics" file_sd_configs: - files: - /prometheus/scrape_configs/*.yml + basic_auth: + username: admin + password: {{ secret "prometheus_admin_password" }} \ No newline at end of file diff --git a/prometheus_web.yml.tmpl b/prometheus_web.yml.tmpl deleted file mode 100644 index 38c005a..0000000 --- a/prometheus_web.yml.tmpl +++ /dev/null @@ -1,2 +0,0 @@ -basic_auth_users: - admin: {{ secret "prometheus_admin_password_hashed" }} diff --git a/scrape-config.example.yml b/scrape-config.example.yml new file mode 100644 index 0000000..316d837 --- /dev/null +++ b/scrape-config.example.yml @@ -0,0 +1,4 @@ +- targets: + - 'traefik.example.org' + - 'node.monitoring.example.org' + - 'cadvisor.monitoring.example.org'