From 309b3a9c950618caa75481f7921e0f1103629f20 Mon Sep 17 00:00:00 2001 From: Yevgeniy Ulyantsev Date: Fri, 30 Jan 2026 21:43:46 +0300 Subject: [PATCH] 1 --- docker-compose.yml | 9 +++++---- otel/otel-collector.yaml | 7 +++++++ prometheus/prometheus.yml | 10 +++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6d732ec..2c03faa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,10 +37,11 @@ services: command: - "--config=/etc/otel/otel-collector.yaml" ports: - - "4317:4317" - - "4318:4318" - - "8888:8888" - - "55679:55679" + - "4317:4317" # OTLP gRPC + - "4318:4318" # OTLP HTTP + - "8888:8888" # Collector self-metrics + - "8889:8889" # Application metrics (добавьте эту строку!) + - "55679:55679" # ZPages grafana: image: grafana/grafana:10.3.1 diff --git a/otel/otel-collector.yaml b/otel/otel-collector.yaml index 13d05dc..df321eb 100644 --- a/otel/otel-collector.yaml +++ b/otel/otel-collector.yaml @@ -15,6 +15,13 @@ exporters: prometheus: endpoint: 0.0.0.0:8889 + namespace: pricehistory # Добавьте namespace для группировки метрик + const_labels: + service: pricehistory-api + send_timestamps: true + metric_expiration: 10m + enable_open_metrics: true + add_metric_suffixes: false # Важно для совместимости otlp/tempo: endpoint: tempo:4317 diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml index 0bd70c3..b7fe618 100644 --- a/prometheus/prometheus.yml +++ b/prometheus/prometheus.yml @@ -2,6 +2,14 @@ global: scrape_interval: 15s scrape_configs: - - job_name: otel-collector + - job_name: 'otel-collector' static_configs: - targets: ['otel-collector:8888'] + # Это метрики самого коллектора + + - job_name: 'application-metrics' + static_configs: + - targets: ['otel-collector:8889'] + # Это прикладные метрики из вашего приложения + scrape_interval: 10s + metrics_path: /metrics \ No newline at end of file