From bc0f7c81df2081429331f4f4dd62d95a916acc2a Mon Sep 17 00:00:00 2001 From: ITQ Date: Sat, 19 Jul 2025 23:41:12 +0300 Subject: [PATCH] revert: "chore: removed all exporters and prometheus" This reverts commit 353e90ea9ee60e64acfd2b13306664014ab52e96. --- compose.yaml | 75 ++++++++++++++++++- infrastructure/celery-exporter/.env.template | 1 + .../postgres-exporter/.env.template | 3 + infrastructure/prometheus/prometheus.yaml | 33 ++++++++ infrastructure/redis-exporter/.env.template | 2 + tests/e2e/README.md | 2 +- 6 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 infrastructure/celery-exporter/.env.template create mode 100644 infrastructure/postgres-exporter/.env.template create mode 100644 infrastructure/prometheus/prometheus.yaml create mode 100644 infrastructure/redis-exporter/.env.template diff --git a/compose.yaml b/compose.yaml index f5abef5..096496f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -107,6 +107,20 @@ services: start_interval: 2s restart: unless-stopped + celery-exporter: + image: docker.io/danihodovic/celery-exporter:0.11.1 + depends_on: + redis: + restart: false + condition: service_healthy + required: true + env_file: + - path: ./infrastructure/celery-exporter/.env.template + required: true + - path: ./infrastructure/celery-exporter/.env + required: false + restart: unless-stopped + telegram_bot: build: context: ./services/telegram_bot @@ -158,6 +172,21 @@ services: source: redis_data target: /data + redis-exporter: + image: docker.io/oliver006/redis_exporter:v1.67.0-alpine + depends_on: + redis: + restart: false + condition: service_healthy + required: true + env_file: + - path: ./infrastructure/redis-exporter/.env.template + required: true + - path: ./infrastructure/redis-exporter/.env + required: false + restart: unless-stopped + shm_size: 4mb + postgres: image: docker.io/postgres:17-alpine3.21 configs: @@ -186,6 +215,21 @@ services: source: postgres_data target: /var/lib/postgresql/data + postgres-exporter: + image: quay.io/prometheuscommunity/postgres-exporter:v0.16.0 + depends_on: + postgres: + restart: false + condition: service_healthy + required: true + env_file: + - path: ./infrastructure/postgres-exporter/.env.template + required: true + - path: ./infrastructure/postgres-exporter/.env + required: false + restart: unless-stopped + shm_size: 4mb + pgadmin: image: docker.io/dpage/pgadmin4:9 configs: @@ -256,6 +300,33 @@ services: source: ./infrastructure/grafana/scripts target: /etc/grafana/scripts + prometheus: + image: docker.io/prom/prometheus:v3.1.0 + command: + - "--config.file=/etc/prometheus/prometheus.yaml" + configs: + - source: prometheus_config + target: /etc/prometheus/prometheus.yaml + healthcheck: + test: ["CMD", "wget", "-O", "-", "http://localhost:9090/-/healthy"] + interval: 1m30s + timeout: 5s + start_period: 5s + start_interval: 2s + retries: 5 + ports: + - name: web + target: 9090 + published: 13244 + host_ip: 127.0.0.1 + protocol: tcp + restart: unless-stopped + shm_size: 4mb + volumes: + - type: volume + source: prometheus_data + target: /prometheus + minio: command: server --console-address ":9001" image: docker.io/minio/minio:RELEASE.2025-02-03T21-03-04Z @@ -274,12 +345,12 @@ services: ports: - name: api target: 9000 - published: 13244 + published: 13245 host_ip: 127.0.0.1 protocol: tcp - name: console target: 9001 - published: 13245 + published: 13246 host_ip: 127.0.0.1 protocol: tcp restart: unless-stopped diff --git a/infrastructure/celery-exporter/.env.template b/infrastructure/celery-exporter/.env.template new file mode 100644 index 0000000..0bc4e3e --- /dev/null +++ b/infrastructure/celery-exporter/.env.template @@ -0,0 +1 @@ +CE_BROKER_URL=redis://redis:6379 diff --git a/infrastructure/postgres-exporter/.env.template b/infrastructure/postgres-exporter/.env.template new file mode 100644 index 0000000..9e72489 --- /dev/null +++ b/infrastructure/postgres-exporter/.env.template @@ -0,0 +1,3 @@ +DATA_SOURCE_URI=postgres:5432/postgres?sslmode=disable +DATA_SOURCE_USER=postgres +DATA_SOURCE_PASS=postgres diff --git a/infrastructure/prometheus/prometheus.yaml b/infrastructure/prometheus/prometheus.yaml new file mode 100644 index 0000000..43a0c92 --- /dev/null +++ b/infrastructure/prometheus/prometheus.yaml @@ -0,0 +1,33 @@ +# Global config +global: + scrape_interval: 10s + scrape_timeout: 10s + evaluation_interval: 10m + external_labels: + environment: local + instance: somemachinelol + +scrape_configs: + # Prometheus + - job_name: prometheus + scrape_interval: 5s + static_configs: + - targets: ["localhost:9090"] + + # Postgres + - job_name: postgres + scrape_interval: 10s + static_configs: + - targets: ["postgres-exporter:9187"] + + # Redis + - job_name: redis + scrape_interval: 10s + static_configs: + - targets: ["redis-exporter:9121"] + + # Celery + - job_name: celery + scrape_interval: 30s + static_configs: + - targets: ["celery-exporter:9808"] diff --git a/infrastructure/redis-exporter/.env.template b/infrastructure/redis-exporter/.env.template new file mode 100644 index 0000000..d1fc912 --- /dev/null +++ b/infrastructure/redis-exporter/.env.template @@ -0,0 +1,2 @@ +REDIS_ADDR=redis://redis:6379 +REDIS_EXPORTER_PING_ON_CONNECT=true diff --git a/tests/e2e/README.md b/tests/e2e/README.md index 6b3d225..d05845e 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -11,7 +11,7 @@ Ensure you have the following installed on your system: ## Warning -Please note that containers will use ports from 13241 to 13245 and 8080, so there is must be no listeners on this ports range. +Please note that containers will use ports from 13241 to 13246 and 8080, so there is must be no listeners on this ports range. ## Setup