From c7cff4ddf84867cb3bdc5c37a790a5806e78c44c Mon Sep 17 00:00:00 2001 From: vityaman Date: Fri, 24 Jan 2025 17:18:00 +0300 Subject: [PATCH 1/4] #88 Get Consul metrics --- backend/prometheus/prometheus.yml | 7 +++++++ compose.yml | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/backend/prometheus/prometheus.yml b/backend/prometheus/prometheus.yml index 43ee500a..3ca40bc9 100644 --- a/backend/prometheus/prometheus.yml +++ b/backend/prometheus/prometheus.yml @@ -65,3 +65,10 @@ scrape_configs: - database-primary-exporter.dating.se.ifmo.ru type: 'A' port: 9187 + + - job_name: consul + dns_sd_configs: + - names: + - consul-exporter.dating.se.ifmo.ru + type: 'A' + port: 9107 diff --git a/compose.yml b/compose.yml index 50fddb69..55b59967 100644 --- a/compose.yml +++ b/compose.yml @@ -141,6 +141,14 @@ services: - consul-data:/opt/consul/data tty: true hostname: server.dc1.consul + consul-exporter: + image: prom/consul-exporter + command: --consul.server=server.dc1.consul:8500 + tty: true + hostname: consul-exporter.dating.se.ifmo.ru + depends_on: + consul: + condition: service_started vault: image: ghcr.io/secs-dev/itmo-dating-vault:latest build: From 9ea6127d9f2e5a04b165fc2b0254c7adda62db3e Mon Sep 17 00:00:00 2001 From: vityaman Date: Fri, 24 Jan 2025 17:38:51 +0300 Subject: [PATCH 2/4] #88 Get Vault metrics --- backend/.gitignore | 3 +++ backend/prometheus/Dockerfile | 2 ++ backend/prometheus/prometheus.yml | 15 +++++++++++++++ backend/vault/config/vault.hcl | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/backend/.gitignore b/backend/.gitignore index a6d69a58..3b467049 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -37,5 +37,8 @@ build/ *.srl *.jks +# Secrets +*.token.txt + # Java *.hprof diff --git a/backend/prometheus/Dockerfile b/backend/prometheus/Dockerfile index 31e5f126..ca1e255c 100644 --- a/backend/prometheus/Dockerfile +++ b/backend/prometheus/Dockerfile @@ -2,6 +2,8 @@ FROM prom/prometheus:latest COPY ./prometheus.yml /etc/prometheus/prometheus.yml +COPY ./vault.token.txt /etc/prometheus/vault.token.txt + CMD [ \ "--config.file=/etc/prometheus/prometheus.yml", \ "--storage.tsdb.retention.size=500MB", \ diff --git a/backend/prometheus/prometheus.yml b/backend/prometheus/prometheus.yml index 3ca40bc9..2479f354 100644 --- a/backend/prometheus/prometheus.yml +++ b/backend/prometheus/prometheus.yml @@ -72,3 +72,18 @@ scrape_configs: - consul-exporter.dating.se.ifmo.ru type: 'A' port: 9107 + + - job_name: vault + metrics_path: /v1/sys/metrics + params: + format: [ 'prometheus' ] + authorization: + credentials_file: /etc/prometheus/vault.token.txt + dns_sd_configs: + - names: + - vault.dating.se.ifmo.ru + type: 'A' + port: 8200 + scheme: https + tls_config: + insecure_skip_verify: true diff --git a/backend/vault/config/vault.hcl b/backend/vault/config/vault.hcl index 80361bdf..2b06e766 100644 --- a/backend/vault/config/vault.hcl +++ b/backend/vault/config/vault.hcl @@ -10,6 +10,10 @@ listener "tcp" { tls_min_version = "tls13" } +telemetry { + prometheus_retention_time = "12h" +} + storage "consul" { address = "server.dc1.consul:8501" max_parallel = 32 From 43e1b0f2646bcd8c5a7165365521e593cd0c01f3 Mon Sep 17 00:00:00 2001 From: vityaman Date: Fri, 24 Jan 2025 17:46:32 +0300 Subject: [PATCH 3/4] #88 Get HAProxy metrics --- backend/haproxy/config/haproxy.cfg | 6 ++++++ backend/prometheus/prometheus.yml | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/backend/haproxy/config/haproxy.cfg b/backend/haproxy/config/haproxy.cfg index 7a234c36..e122bc60 100644 --- a/backend/haproxy/config/haproxy.cfg +++ b/backend/haproxy/config/haproxy.cfg @@ -15,6 +15,12 @@ defaults default-server check inter 10s fall 2 rise 1 +frontend prometheus + bind :8405 + mode http + http-request use-service prometheus-exporter if { path /metrics } + no log + frontend internal bind :8445 ssl crt /usr/local/etc/haproxy/itmo-dating-backend.pem bind :8446 ssl crt /usr/local/etc/haproxy/itmo-dating-backend.pem diff --git a/backend/prometheus/prometheus.yml b/backend/prometheus/prometheus.yml index 2479f354..1600fffe 100644 --- a/backend/prometheus/prometheus.yml +++ b/backend/prometheus/prometheus.yml @@ -87,3 +87,10 @@ scrape_configs: scheme: https tls_config: insecure_skip_verify: true + + - job_name: haproxy + dns_sd_configs: + - names: + - haproxy.dating.se.ifmo.ru + type: 'A' + port: 8405 From 5f18b62db478f2c8638368c4631846f65d46d84d Mon Sep 17 00:00:00 2001 From: vityaman Date: Fri, 24 Jan 2025 17:53:59 +0300 Subject: [PATCH 4/4] #88 Get Prometheus & Grafana metrics --- backend/prometheus/prometheus.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/prometheus/prometheus.yml b/backend/prometheus/prometheus.yml index 1600fffe..bf0c9994 100644 --- a/backend/prometheus/prometheus.yml +++ b/backend/prometheus/prometheus.yml @@ -94,3 +94,17 @@ scrape_configs: - haproxy.dating.se.ifmo.ru type: 'A' port: 8405 + + - job_name: prometheus + dns_sd_configs: + - names: + - prometheus.dating.se.ifmo.ru + type: 'A' + port: 9090 + + - job_name: grafana + dns_sd_configs: + - names: + - grafana.dating.se.ifmo.ru + type: 'A' + port: 3000