Skip to content

Commit 8f254c5

Browse files
committed
docs(observability): add prometheus scrape config, servicemonitor, grafana dashboard
1 parent d321a1e commit 8f254c5

4 files changed

Lines changed: 90 additions & 0 deletions

File tree

examples/observability/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Observability: Prometheus + Grafana
2+
3+
Forge serves Prometheus metrics at `/_/metrics`.
4+
5+
## Scrape with Prometheus
6+
Use `prometheus.yml` (note `metrics_path: /_/metrics`, not the default `/metrics`).
7+
8+
## Kubernetes (Prometheus Operator)
9+
Apply `servicemonitor.yaml` (adjust the selector to match your Service labels).
10+
11+
## Grafana
12+
Import `grafana-dashboard.json` and pick your Prometheus data source. It includes
13+
HTTP RED panels and Go runtime panels (`go_*`, `process_*`).
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"title": "Forge Overview",
3+
"schemaVersion": 39,
4+
"version": 1,
5+
"time": { "from": "now-1h", "to": "now" },
6+
"templating": {
7+
"list": [
8+
{
9+
"name": "datasource",
10+
"type": "datasource",
11+
"query": "prometheus",
12+
"current": {}
13+
}
14+
]
15+
},
16+
"panels": [
17+
{
18+
"type": "timeseries",
19+
"title": "Request rate",
20+
"datasource": "${datasource}",
21+
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
22+
"targets": [
23+
{ "expr": "sum(rate(http_requests_total[5m]))", "legendFormat": "rps" }
24+
]
25+
},
26+
{
27+
"type": "timeseries",
28+
"title": "Request p95 latency",
29+
"datasource": "${datasource}",
30+
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
31+
"targets": [
32+
{ "expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))", "legendFormat": "p95" }
33+
]
34+
},
35+
{
36+
"type": "timeseries",
37+
"title": "Goroutines",
38+
"datasource": "${datasource}",
39+
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 8 },
40+
"targets": [ { "expr": "go_goroutines", "legendFormat": "goroutines" } ]
41+
},
42+
{
43+
"type": "timeseries",
44+
"title": "Heap in use",
45+
"datasource": "${datasource}",
46+
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 8 },
47+
"targets": [ { "expr": "go_memstats_heap_inuse_bytes", "legendFormat": "heap" } ]
48+
},
49+
{
50+
"type": "timeseries",
51+
"title": "Process CPU",
52+
"datasource": "${datasource}",
53+
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 8 },
54+
"targets": [ { "expr": "rate(process_cpu_seconds_total[5m])", "legendFormat": "cpu" } ]
55+
}
56+
]
57+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
scrape_configs:
2+
- job_name: forge
3+
metrics_path: /_/metrics
4+
scrape_interval: 15s
5+
static_configs:
6+
- targets: ['localhost:8080'] # replace with your Forge app host:port
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: monitoring.coreos.com/v1
2+
kind: ServiceMonitor
3+
metadata:
4+
name: forge
5+
labels:
6+
release: prometheus
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: forge
11+
endpoints:
12+
- port: http
13+
path: /_/metrics
14+
interval: 15s

0 commit comments

Comments
 (0)