DaCrow13 commited on
Commit
946fd5e
·
1 Parent(s): 9c536a5

Fix Grafana datasource path and Prometheus route prefixes for Space deployment

Browse files
docker/scripts/start_space.sh CHANGED
@@ -53,9 +53,9 @@ for i in {1..30}; do
53
  done
54
 
55
  echo "$(date) - Configuring and starting Prometheus..."
56
- # Patch Grafana Datasource for Localhost (HF Space)
57
- # Replace prometheus:9090 with 127.0.0.1:9090 in all datasource configs
58
- find /app/monitoring/grafana/provisioning/datasources -name '*.yml' -exec sed -i 's/prometheus:9090/127.0.0.1:9090/g' {} +
59
 
60
  # Copy production configs to /tmp for modification
61
  cp /etc/prometheus/prometheus.yml /tmp/prometheus.yml
@@ -65,6 +65,8 @@ cp /etc/alertmanager/config.yml /tmp/alertmanager.yml
65
  # Modify Prometheus config for local execution (replace docker-compose service names with localhost)
66
  # hopcroft-api:8080 -> 127.0.0.1:8000 (API runs on 8000 in Space)
67
  sed -i 's/hopcroft-api:8080/127.0.0.1:8000/g' /tmp/prometheus.yml
 
 
68
  # alertmanager:9093 -> 127.0.0.1:9093
69
  sed -i 's/alertmanager:9093/127.0.0.1:9093/g' /tmp/prometheus.yml
70
  # pushgateway:9091 -> 127.0.0.1:9091
@@ -72,6 +74,14 @@ sed -i 's/pushgateway:9091/127.0.0.1:9091/g' /tmp/prometheus.yml
72
  # Fix alert_rules path to be absolute or relative to execution
73
  sed -i 's|"alert_rules.yml"|"/tmp/alert_rules.yml"|g' /tmp/prometheus.yml
74
 
 
 
 
 
 
 
 
 
75
  echo "$(date) - Starting Alertmanager..."
76
  alertmanager \
77
  --config.file=/tmp/alertmanager.yml \
 
53
  done
54
 
55
  echo "$(date) - Configuring and starting Prometheus..."
56
+ # Patch Grafana Datasource for Localhost (HF Space) and fix URL path
57
+ # Replace prometheus:9090 with 127.0.0.1:9090/prometheus in all datasource configs
58
+ find /app/monitoring/grafana/provisioning/datasources -name '*.yml' -exec sed -i 's/prometheus:9090/127.0.0.1:9090\/prometheus/g' {} +
59
 
60
  # Copy production configs to /tmp for modification
61
  cp /etc/prometheus/prometheus.yml /tmp/prometheus.yml
 
65
  # Modify Prometheus config for local execution (replace docker-compose service names with localhost)
66
  # hopcroft-api:8080 -> 127.0.0.1:8000 (API runs on 8000 in Space)
67
  sed -i 's/hopcroft-api:8080/127.0.0.1:8000/g' /tmp/prometheus.yml
68
+ # Alertmanager: hopcroft-api:8080 -> 127.0.0.1:8000
69
+ sed -i 's/hopcroft-api:8080/127.0.0.1:8000/g' /tmp/alertmanager.yml
70
  # alertmanager:9093 -> 127.0.0.1:9093
71
  sed -i 's/alertmanager:9093/127.0.0.1:9093/g' /tmp/prometheus.yml
72
  # pushgateway:9091 -> 127.0.0.1:9091
 
74
  # Fix alert_rules path to be absolute or relative to execution
75
  sed -i 's|"alert_rules.yml"|"/tmp/alert_rules.yml"|g' /tmp/prometheus.yml
76
 
77
+ # FIX: Add path prefixes to match --web.route-prefix arguments
78
+ # Add metrics_path for self-scraping prometheus
79
+ sed -i 's/job_name: "prometheus"/job_name: "prometheus"\n metrics_path: "\/prometheus\/metrics"/g' /tmp/prometheus.yml
80
+ # Add metrics_path for pushgateway
81
+ sed -i 's/job_name: "pushgateway"/job_name: "pushgateway"\n metrics_path: "\/pushgateway\/metrics"/g' /tmp/prometheus.yml
82
+ # Add path_prefix for Alertmanager
83
+ sed -i 's/ - static_configs:/ - path_prefix: "\/alertmanager\/"\n static_configs:/g' /tmp/prometheus.yml
84
+
85
  echo "$(date) - Starting Alertmanager..."
86
  alertmanager \
87
  --config.file=/tmp/alertmanager.yml \
monitoring/alertmanager/config.yml CHANGED
@@ -11,7 +11,7 @@ route:
11
  receivers:
12
  - name: "log-receiver"
13
  webhook_configs:
14
- - url: "http://127.0.0.1:8000/health"
15
 
16
  inhibition_rules:
17
  - source_match:
 
11
  receivers:
12
  - name: "log-receiver"
13
  webhook_configs:
14
+ - url: "http://hopcroft-api:8080/health"
15
 
16
  inhibition_rules:
17
  - source_match:
monitoring/prometheus/prometheus.yml CHANGED
@@ -12,13 +12,13 @@ alerting:
12
  alertmanagers:
13
  - static_configs:
14
  - targets:
15
- - "127.0.0.1:9093"
16
 
17
  scrape_configs:
18
  - job_name: "hopcroft-api"
19
  metrics_path: "/metrics"
20
  static_configs:
21
- - targets: ["127.0.0.1:8000"]
22
  scrape_interval: 10s
23
 
24
  - job_name: "prometheus"
@@ -28,5 +28,5 @@ scrape_configs:
28
  - job_name: "pushgateway"
29
  honor_labels: true
30
  static_configs:
31
- - targets: ["127.0.0.1:9091"]
32
  scrape_interval: 30s
 
12
  alertmanagers:
13
  - static_configs:
14
  - targets:
15
+ - "alertmanager:9093"
16
 
17
  scrape_configs:
18
  - job_name: "hopcroft-api"
19
  metrics_path: "/metrics"
20
  static_configs:
21
+ - targets: ["hopcroft-api:8080"]
22
  scrape_interval: 10s
23
 
24
  - job_name: "prometheus"
 
28
  - job_name: "pushgateway"
29
  honor_labels: true
30
  static_configs:
31
+ - targets: ["pushgateway:9091"]
32
  scrape_interval: 30s