Update Grafana configuration and enhance startup script for better logging and health check
Browse files- monitoring/grafana/grafana.ini +1 -1
- nginx.conf +10 -1
- scripts/start_space.sh +17 -3
monitoring/grafana/grafana.ini
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
protocol = http
|
| 3 |
http_port = 3000
|
| 4 |
domain = localhost
|
| 5 |
-
root_url = %(protocol)s://%(domain)s/grafana/
|
| 6 |
serve_from_sub_path = true
|
| 7 |
|
| 8 |
[auth.anonymous]
|
|
|
|
| 2 |
protocol = http
|
| 3 |
http_port = 3000
|
| 4 |
domain = localhost
|
| 5 |
+
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
|
| 6 |
serve_from_sub_path = true
|
| 7 |
|
| 8 |
[auth.anonymous]
|
nginx.conf
CHANGED
|
@@ -75,11 +75,20 @@ http {
|
|
| 75 |
|
| 76 |
# Grafana
|
| 77 |
location /grafana/ {
|
| 78 |
-
|
|
|
|
|
|
|
| 79 |
proxy_set_header Host $host;
|
| 80 |
proxy_set_header X-Real-IP $remote_addr;
|
| 81 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 82 |
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
}
|
| 84 |
|
| 85 |
# Prometheus UI
|
|
|
|
| 75 |
|
| 76 |
# Grafana
|
| 77 |
location /grafana/ {
|
| 78 |
+
rewrite ^/grafana/(.*) /$1 break;
|
| 79 |
+
|
| 80 |
+
proxy_pass http://127.0.0.1:3000;
|
| 81 |
proxy_set_header Host $host;
|
| 82 |
proxy_set_header X-Real-IP $remote_addr;
|
| 83 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 84 |
proxy_set_header X-Forwarded-Proto $scheme;
|
| 85 |
+
|
| 86 |
+
proxy_set_header X-Forwarded-Host $host;
|
| 87 |
+
proxy_set_header X-Forwarded-Server $host;
|
| 88 |
+
|
| 89 |
+
proxy_http_version 1.1;
|
| 90 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 91 |
+
proxy_set_header Connection "upgrade";
|
| 92 |
}
|
| 93 |
|
| 94 |
# Prometheus UI
|
scripts/start_space.sh
CHANGED
|
@@ -82,10 +82,24 @@ prometheus \
|
|
| 82 |
>> /tmp/prometheus.log 2>&1 &
|
| 83 |
|
| 84 |
# Start Grafana
|
| 85 |
-
echo "Starting Grafana..."
|
| 86 |
grafana-server --homepath=/usr/share/grafana \
|
| 87 |
-
--config=/
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
echo "$(date) - Starting Nginx reverse proxy..."
|
| 91 |
if ! command -v nginx &> /dev/null; then
|
|
|
|
| 82 |
>> /tmp/prometheus.log 2>&1 &
|
| 83 |
|
| 84 |
# Start Grafana
|
| 85 |
+
echo "$(date) - Starting Grafana..."
|
| 86 |
grafana-server --homepath=/usr/share/grafana \
|
| 87 |
+
--config=/app/monitoring/grafana/grafana.ini \
|
| 88 |
+
cfg:default.paths.data=/tmp/grafana_data \
|
| 89 |
+
cfg:default.paths.logs=/tmp/grafana_logs \
|
| 90 |
+
cfg:default.paths.plugins=/usr/share/grafana/plugins \
|
| 91 |
+
>> /tmp/grafana.log 2>&1 &
|
| 92 |
+
|
| 93 |
+
# Wait for Grafana to start
|
| 94 |
+
echo "$(date) - Waiting for Grafana (20s)..."
|
| 95 |
+
for i in {1..20}; do
|
| 96 |
+
if curl -s http://127.0.0.1:3000/api/health > /dev/null; then
|
| 97 |
+
echo "$(date) - Grafana is UP!"
|
| 98 |
+
break
|
| 99 |
+
fi
|
| 100 |
+
sleep 1
|
| 101 |
+
done
|
| 102 |
+
|
| 103 |
|
| 104 |
echo "$(date) - Starting Nginx reverse proxy..."
|
| 105 |
if ! command -v nginx &> /dev/null; then
|