Merge pull request #35 from se4ai2526-uniba/hf-space-monitoring-integration
Browse files- Dockerfile +21 -0
- monitoring/grafana/grafana.ini +20 -0
- nginx.conf +18 -0
- scripts/start_space.sh +20 -0
Dockerfile
CHANGED
|
@@ -23,6 +23,27 @@ RUN useradd -m -u 1000 user
|
|
| 23 |
# Set working directory
|
| 24 |
WORKDIR /app
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# Copy requirements first for caching
|
| 27 |
COPY requirements.txt .
|
| 28 |
|
|
|
|
| 23 |
# Set working directory
|
| 24 |
WORKDIR /app
|
| 25 |
|
| 26 |
+
# Grafana
|
| 27 |
+
RUN apt-get update && apt-get install -y wget apt-transport-https && \
|
| 28 |
+
wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key && \
|
| 29 |
+
echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | tee /etc/apt/sources.list.d/grafana.list && \
|
| 30 |
+
apt-get update && \
|
| 31 |
+
apt-get install -y grafana && \
|
| 32 |
+
apt-get clean && \
|
| 33 |
+
rm -rf /var/lib/apt/lists/*
|
| 34 |
+
|
| 35 |
+
# Prometheus
|
| 36 |
+
RUN wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz && \
|
| 37 |
+
tar xvfz prometheus-*.tar.gz && \
|
| 38 |
+
mv prometheus-*/prometheus /usr/local/bin/ && \
|
| 39 |
+
mv prometheus-*/promtool /usr/local/bin/ && \
|
| 40 |
+
mkdir -p /etc/prometheus /var/lib/prometheus && \
|
| 41 |
+
rm -rf prometheus-*
|
| 42 |
+
|
| 43 |
+
COPY monitoring/grafana/provisioning /etc/grafana/provisioning
|
| 44 |
+
COPY monitoring/grafana/dashboards /var/lib/grafana/dashboards
|
| 45 |
+
COPY monitoring/prometheus/prometheus.yml /etc/prometheus/prometheus.yml
|
| 46 |
+
|
| 47 |
# Copy requirements first for caching
|
| 48 |
COPY requirements.txt .
|
| 49 |
|
monitoring/grafana/grafana.ini
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[server]
|
| 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]
|
| 9 |
+
enabled = true
|
| 10 |
+
org_role = Viewer
|
| 11 |
+
|
| 12 |
+
[security]
|
| 13 |
+
allow_embedding = true
|
| 14 |
+
|
| 15 |
+
[users]
|
| 16 |
+
allow_sign_up = false
|
| 17 |
+
|
| 18 |
+
[log]
|
| 19 |
+
mode = console
|
| 20 |
+
level = info
|
nginx.conf
CHANGED
|
@@ -73,6 +73,24 @@ http {
|
|
| 73 |
proxy_set_header Host $host;
|
| 74 |
}
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
# Prometheus UI
|
| 77 |
location /prometheus/ {
|
| 78 |
proxy_pass http://prometheus/prometheus/;
|
|
|
|
| 73 |
proxy_set_header Host $host;
|
| 74 |
}
|
| 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
|
| 95 |
location /prometheus/ {
|
| 96 |
proxy_pass http://prometheus/prometheus/;
|
scripts/start_space.sh
CHANGED
|
@@ -81,6 +81,26 @@ prometheus \
|
|
| 81 |
--web.route-prefix=/prometheus/ \
|
| 82 |
>> /tmp/prometheus.log 2>&1 &
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
echo "$(date) - Starting Nginx reverse proxy..."
|
| 85 |
if ! command -v nginx &> /dev/null; then
|
| 86 |
echo "$(date) - ERROR: nginx not found in PATH"
|
|
|
|
| 81 |
--web.route-prefix=/prometheus/ \
|
| 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
|
| 106 |
echo "$(date) - ERROR: nginx not found in PATH"
|