diff --git a/config/config.alloy b/config/config.alloy index 06d7024..790a835 100644 --- a/config/config.alloy +++ b/config/config.alloy @@ -30,7 +30,7 @@ prometheus.scrape "host_metrics" { scrape_timeout = "10s" job_name = "node" } - + prometheus.remote_write "prometheus" { endpoint { url = "http://prometheus:9090/api/v1/write" diff --git a/config/prometheus.yml b/config/prometheus.yml index fde2624..2780488 100644 --- a/config/prometheus.yml +++ b/config/prometheus.yml @@ -32,15 +32,20 @@ scrape_configs: static_configs: - targets: ['grafana:3000'] - # Replace node-exporter job with Alloy - - job_name: 'ktpv-orch_node-exporter' + # Node metrics from Alloy - with custom instance name + - job_name: 'node' sample_limit: 50000 static_configs: - - targets: ['alloy:12345'] # Scrape from Alloy's metrics endpoint + - targets: ['alloy:12345'] + labels: + instance: 'main-server' # Use any name you want metrics_path: /metrics - - job_name: 'ktpv-apps01_node-exporter' + # Remote node for the second server + - job_name: 'node-app-server01' sample_limit: 50000 static_configs: - - targets: ['10.249.84.41:12345'] # Adjust IP as needed + - targets: ['10.249.84.41:12345'] + labels: + instance: 'app-server-01' # Use any name you want metrics_path: /metrics diff --git a/docker-compose.yml b/docker-compose.yml index 9b0cd15..f66b10c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -87,6 +87,7 @@ services: alloy: image: grafana/alloy:latest container_name: alloy + hostname: localhost # Set a proper hostname volumes: - ./config/config.alloy:/etc/alloy/config.alloy - /proc:/host/proc:ro # CRITICAL - must be mounted at /host/proc @@ -101,6 +102,8 @@ services: - "12345:12345" privileged: true # CRITICAL for accessing system metrics pid: "host" # CRITICAL for accessing process metrics + environment: + - HOSTNAME=localhost # Explicitly set the hostname for metrics networks: - monitoring