fix Monitoring - docker-compose.* + .env*
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# Prometheus configuration for Meldestelle project
|
||||
# Basic configuration to enable service monitoring
|
||||
# ===================================================================
|
||||
# Prometheus Configuration for Meldestelle
|
||||
# Features: Consul Service Discovery, Spring Boot Actuator support
|
||||
# ===================================================================
|
||||
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
@@ -9,33 +11,21 @@ global:
|
||||
alerting:
|
||||
alertmanagers:
|
||||
- static_configs:
|
||||
- targets:
|
||||
- "alertmanager:9093"
|
||||
- targets:
|
||||
# Da wir Alertmanager noch nicht im Docker Compose haben (kommt noch!),
|
||||
# lassen wir das vorerst auskommentiert oder fügen den Container hinzu.
|
||||
- "alertmanager:9093"
|
||||
|
||||
rule_files:
|
||||
- "/etc/prometheus/rules/alerts.yaml"
|
||||
|
||||
scrape_configs:
|
||||
# Job 1: Prometheus überwacht sich selbst
|
||||
# 1. Prometheus Self-Monitoring
|
||||
- job_name: 'prometheus'
|
||||
static_configs:
|
||||
- targets: [ 'localhost:9090' ]
|
||||
|
||||
# Job 2: API Gateway (Spring Boot Actuator)
|
||||
- job_name: 'api-gateway'
|
||||
metrics_path: '/actuator/prometheus'
|
||||
scrape_interval: "30s"
|
||||
static_configs:
|
||||
- targets: [ 'api-gateway:8081' ]
|
||||
|
||||
# Job 3: Postgres (ACHTUNG)
|
||||
# Postgres direkt auf 5432 zu scrapen geht nicht.
|
||||
# Entweder auskommentieren oder 'postgres-exporter' Container hinzufügen.
|
||||
# - job_name: 'postgres-exporter'
|
||||
# static_configs:
|
||||
# - targets: ['postgres-exporter:9187']
|
||||
|
||||
# Add consul for service discovery monitoring
|
||||
# 2. Consul Self-Monitoring
|
||||
- job_name: 'consul'
|
||||
metrics_path: '/v1/agent/metrics'
|
||||
params:
|
||||
@@ -43,4 +33,31 @@ scrape_configs:
|
||||
static_configs:
|
||||
- targets: [ 'consul:8500' ]
|
||||
|
||||
# 3. Spring Boot Services via Consul Discovery.
|
||||
# Das ist die Magie: Prometheus fragt Consul nach allen Services.
|
||||
# Wenn ein Service das Tag 'metrics' oder 'spring-boot' hat (oder einfach alle), wird er scraped.
|
||||
- job_name: 'consul-services'
|
||||
consul_sd_configs:
|
||||
- server: 'consul:8500'
|
||||
services: [ ] # Leere Liste = Alle Services
|
||||
|
||||
relabel_configs:
|
||||
# Nur Services scrapen, die NICHT consul selbst sind (das haben wir oben schon)
|
||||
- source_labels: [ __meta_consul_service ]
|
||||
regex: consul
|
||||
action: drop
|
||||
|
||||
# Setze den Pfad auf /actuator/prometheus für Spring Boot Apps
|
||||
# Optional: Man kann das auch über Consul Tags steuern
|
||||
- source_labels: [ __meta_consul_service ]
|
||||
target_label: __metrics_path__
|
||||
replacement: /actuator/prometheus
|
||||
|
||||
# Übernehme den Service-Namen als 'application' Label
|
||||
- source_labels: [ __meta_consul_service ]
|
||||
target_label: application
|
||||
|
||||
# Behalte die Instanz (IP: Port)
|
||||
- source_labels: [ __meta_consul_address, __meta_consul_service_port ]
|
||||
separator: ':'
|
||||
target_label: instance
|
||||
|
||||
@@ -117,6 +117,40 @@ services:
|
||||
aliases:
|
||||
- "pgadmin"
|
||||
|
||||
# --- MONITORING: Postgres Exporter ---
|
||||
postgres-exporter:
|
||||
image: quay.io/prometheuscommunity/postgres-exporter
|
||||
container_name: "${PROJECT_NAME:-meldestelle}-postgres-exporter"
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
DATA_SOURCE_NAME: "postgresql://pg-user:pg-password@postgres:5432/pg-meldestelle-db?sslmode=disable"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
meldestelle-network:
|
||||
aliases:
|
||||
- postgres-exporter
|
||||
|
||||
# --- MONITORING: Alertmanager ---
|
||||
alertmanager:
|
||||
image: prom/alertmanager:v0.26.0
|
||||
container_name: "${PROJECT_NAME:-meldestelle}-alertmanager"
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "9093:9093"
|
||||
volumes:
|
||||
# Wir müssen hier envsubst nutzen ODER die Config ohne Variablen schreiben.
|
||||
# Einfachste Lösung: Ein Entrypoint-Script, das envsubst macht (ähnlich wie bei Nginx).
|
||||
# ODER: Wir hardcoden es für Dev erst mal.
|
||||
- ./config/backend/infrastructure/monitoring/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml
|
||||
command:
|
||||
- --config.file=/etc/alertmanager/alertmanager.yml
|
||||
networks:
|
||||
meldestelle-network:
|
||||
aliases:
|
||||
- alertmanager
|
||||
|
||||
# --- MONITORING: Prometheus ---
|
||||
prometheus:
|
||||
image: "${PROMETHEUS_IMAGE:-prom/prometheus:v3.7.3}"
|
||||
|
||||
Reference in New Issue
Block a user