diff --git a/blackbox.yml b/blackbox.yml new file mode 100644 index 0000000..96d593e --- /dev/null +++ b/blackbox.yml @@ -0,0 +1,7 @@ +modules: + http_2xx: + prober: http + timeout: 5s + http: + valid_status_codes: [200] + follow_redirects: true \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d46c961..6594713 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,10 +14,7 @@ services: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.retention.time=30d' - '--storage.tsdb.path=/prometheus' - ports: - - "9090:9090" - networks: - - monitoring + network_mode: host grafana: image: grafana/grafana:11.1.0 @@ -65,6 +62,15 @@ services: networks: - monitoring + blackbox-exporter: + image: prom/blackbox-exporter:v0.25.0 + container_name: blackbox-exporter + restart: unless-stopped + command: --config.file=/etc/blackbox/blackbox.yml + volumes: + - ./blackbox.yml:/etc/blackbox/blackbox.yml:ro + network_mode: host + networks: monitoring: driver: bridge \ No newline at end of file diff --git a/loki-config.yaml b/loki-config.yaml new file mode 100644 index 0000000..9a0293b --- /dev/null +++ b/loki-config.yaml @@ -0,0 +1,34 @@ +# Loki config (single-binary, local storage) +auth_enabled: false + +server: + http_listen_port: 3100 + +common: + path_prefix: /loki + storage: + filesystem: + chunks_directory: /loki/chunks + rules_directory: /loki/rules + replication_factor: 1 + ring: + kvstore: + store: inmemory + +schema_config: + configs: + - from: 2024-01-01 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h + +limits_config: + retention_period: 168h # 7 дней + allow_structured_metadata: true + +compactor: + working_directory: /loki/compactor + compaction_interval: 15m \ No newline at end of file diff --git a/prometheus.yml b/prometheus.yml index fb16546..a041aef 100644 --- a/prometheus.yml +++ b/prometheus.yml @@ -8,7 +8,7 @@ rule_files: - /etc/prometheus/alerts.yml scrape_configs: - # Garage node metrics (admin API on WG) + # Garage node metrics (admin API on WG) — Bearer auth - job_name: 'garage' metrics_path: /metrics scheme: http @@ -20,16 +20,30 @@ scrape_configs: labels: cluster: garage - # Health check for each node (returns 200 if quorum OK) + # HTTP health probe via blackbox-exporter (returns probe_success) - job_name: 'garage_health' - metrics_path: /health - scheme: http + metrics_path: /probe + params: + module: [http_2xx] static_configs: - - targets: ['10.8.0.1:3903', '10.8.0.2:3903', '10.8.0.4:3903'] + - targets: ['http://10.8.0.1:3903/health'] labels: - cluster: garage + instance: vps01 + - targets: ['http://10.8.0.2:3903/health'] + labels: + instance: bigbox + - targets: ['http://10.8.0.4:3903/health'] + labels: + instance: vps02 + relabel_configs: + - source_labels: [__address__] + target_label: __param_target + - source_labels: [__param_target] + target_label: target + - target_label: __address__ + replacement: 127.0.0.1:9115 - # Node exporter on each host (system metrics) + # Node exporter on each host (system metrics via WG) - job_name: 'node' static_configs: - targets: ['10.8.0.2:9100'] diff --git a/promtail-config.yaml b/promtail-config.yaml new file mode 100644 index 0000000..470a285 --- /dev/null +++ b/promtail-config.yaml @@ -0,0 +1,23 @@ +# Promtail config: docker-логи (garage и др.) + собственные логи vps01/vps02 через WG +server: + http_listen_port: 9080 + grpc_listen_port: 0 + +positions: + filename: /tmp/positions.yaml + +clients: + - url: http://loki:3100/loki/api/v1/push + +scrape_configs: + # Логи docker-контейнеров на bigbox (garage и др.) + - job_name: docker + docker_sd_configs: + - host: unix:///var/run/docker.sock + refresh_interval: 15s + relabel_configs: + - source_labels: ['__meta_docker_container_name'] + regex: '/(.*)' + target_label: 'container' + - source_labels: ['__meta_docker_container_log_stream'] + target_label: 'stream' \ No newline at end of file