Files
mtusi2026lab7/infra/prometheus/prometheus.yml

60 lines
2.9 KiB
YAML

# lab7: HTTPS + обязательный клиентский сертификат (web.yml): писать OTLP может только Collector,
# читать — Grafana, оператор и сам Prometheus (client_allowed_sans). Цели scrape — тоже по mTLS.
# Prometheus 3.15.1 — хранилище МЕТРИК. Принимает метрики приложения push-ом по OTLP от Collector
# (флаг --web.enable-otlp-receiver, путь /api/v1/otlp/v1/metrics) и сам забирает (pull) служебные
# метрики Collector, Loki и Tempo. Вычисляет recording rules (SLI) и alert rules; состояние алертов
# (pending/firing/resolved) видно на /alerts и через /api/v1/alerts — внешняя доставка не нужна.
# Проверка: promtool check config prometheus.yml
global:
scrape_interval: 15s
scrape_timeout: 5s
evaluation_interval: 15s
# Как имена OTLP переводятся в имена Prometheus (фиксируем явно, чтобы dashboard не сломался при
# смене значения по умолчанию): точки -> подчёркивания, суффиксы единиц и _total.
# http.server.request.duration (s, histogram) -> http_server_request_duration_seconds_{bucket,sum,count}
# атрибут http.route -> метка http_route; service.name -> job; service.instance.id -> instance.
otlp:
translation_strategy: UnderscoreEscapingWithSuffixes
storage:
tsdb:
# Collector после недоступности Prometheus дошлёт пакеты из очереди с прошлыми временными метками.
out_of_order_time_window: 10m
rule_files:
- /etc/prometheus/rules/*.yml
# lab7: все scrape — HTTPS с проверкой сертификата цели (наш CA + имя) и клиентским сертификатом
# Prometheus (CN=prometheus); цели принимают только сертификат нашего CA (mTLS).
scrape_configs:
- job_name: prometheus
scheme: https
tls_config: &tls
ca_file: /run/tls-ca/ca.crt
cert_file: /run/tls/tls.crt
key_file: /run/tls/tls.key
min_version: TLS12
static_configs:
- targets: ["localhost:9090"]
# Собственные метрики Collector: принято/отправлено/отброшено по сигналам, очереди, RSS.
# Через otel-gate (mTLS, разрешены только CN prometheus/operator) -> 127.0.0.1:8888 Collector.
- job_name: otel-collector
scheme: https
tls_config: *tls
static_configs:
- targets: ["otel-collector:8889"]
- job_name: loki
scheme: https
tls_config: *tls
static_configs:
- targets: ["loki:3100"]
- job_name: tempo
scheme: https
tls_config: *tls
static_configs:
- targets: ["tempo:3200"]