-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
52 lines (48 loc) · 1.65 KB
/
Copy pathdocker-compose.yml
File metadata and controls
52 lines (48 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This runs a LOCAL Prometheus that:
# 1. Scrapes metrics from your public Hugging Face Spaces deployment
# 2. Remote-writes them to Grafana Cloud
# Grafana itself runs on grafana.com (free tier) — no local container needed.
services:
# ── Prometheus (local scraper + remote-write agent) ──────────
prometheus:
image: prom/prometheus:v2.51.2
container_name: oilprice_prometheus
env_file:
- .env
entrypoint: /bin/sh
ports:
- "9090:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml.template:ro
- prometheus_data:/prometheus
command: |
-c '
: "$${HF_SPACE_TARGET:?HF_SPACE_TARGET is required}";
: "$${GRAFANA_REMOTE_WRITE_URL:?GRAFANA_REMOTE_WRITE_URL is required}";
: "$${GRAFANA_METRICS_USER_ID:?GRAFANA_METRICS_USER_ID is required}";
: "$${GRAFANA_API_TOKEN:?GRAFANA_API_TOKEN is required}";
cat > /tmp/prometheus.yml <<EOF
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: "fastapi"
scheme: https
static_configs:
- targets: ["$${HF_SPACE_TARGET}"]
metrics_path: "/metrics"
remote_write:
- url: "$${GRAFANA_REMOTE_WRITE_URL}"
basic_auth:
username: "$${GRAFANA_METRICS_USER_ID}"
password: "$${GRAFANA_API_TOKEN}"
EOF
exec /bin/prometheus \
--config.file=/tmp/prometheus.yml \
--storage.tsdb.path=/prometheus \
--storage.tsdb.retention.time=7d \
--web.enable-lifecycle
'
restart: unless-stopped
volumes:
prometheus_data: