Lior Barak
12/08/2025, 10:30 PMMarvin
12/08/2025, 10:30 PMMarvin
12/08/2025, 10:33 PMLior Barak
12/08/2025, 10:39 PMMarvin
12/08/2025, 10:39 PMMarvin
12/08/2025, 10:43 PM/api/metrics when enabled.
High-level steps
1) Enable server metrics in the API container
2) Make the endpoint reachable (Service, optional Ingress)
3) If you use Prometheus, either annotate the Service or add a ServiceMonitor
Enable metrics in your Helm values
- Set either env var (they are aliases): PREFECT_API_ENABLE_METRICS=true or PREFECT_SERVER_METRICS_ENABLED=true
- The endpoint will be served on port 4200 at /api/metrics
Example values.yaml (prefect-server)
yaml
server:
# Enable the Prometheus metrics endpoint on the API
env:
- name: PREFECT_API_ENABLE_METRICS
value: "true"
# If your chart version uses a different key for env (e.g., extraEnv), adjust accordingly.
# Check with: helm show values <repo>/prefect-server
service:
type: ClusterIP
port: 4200
targetPort: 4200
portName: server
# If your Prometheus scrapes by annotation, you can add:
annotations:
<http://prometheus.io/scrape|prometheus.io/scrape>: "true"
<http://prometheus.io/port|prometheus.io/port>: "4200"
<http://prometheus.io/path|prometheus.io/path>: "/api/metrics"
ingress:
enabled: false
# If you want to expose metrics externally, enable and add a rule for /api/metrics.
# Example (nginx):
# className: nginx
# host:
# hostname: <http://prefect.example.com|prefect.example.com>
# path: /
# pathType: Prefix
# extraPaths:
# - path: /api/metrics
# pathType: Prefix
# backend:
# service:
# name: prefect-server
# port:
# name: server
If you use Prometheus Operator (ServiceMonitor)
- The Prefect Helm chart does not ship a ServiceMonitor by default; create one that selects the server Service and scrapes /api/metrics on port 4200.
Example ServiceMonitor
yaml
apiVersion: <http://monitoring.coreos.com/v1|monitoring.coreos.com/v1>
kind: ServiceMonitor
metadata:
name: prefect-server-metrics
namespace: prefect
spec:
selector:
matchLabels:
<http://app.kubernetes.io/name|app.kubernetes.io/name>: prefect-server
endpoints:
- port: server
path: /api/metrics
interval: 30s
scrapeTimeout: 10s
Quick test
bash
# Port-forward the server service
kubectl -n prefect port-forward svc/prefect-server 4200:4200
# Fetch metrics
curl <http://localhost:4200/api/metrics>
Notes
- The metrics endpoint is unauthenticated; if exposing via Ingress, protect it (authn, IP allowlist, etc.).
- If you also want worker/client metrics (separate from the server), enable PREFECT_CLIENT_METRICS_ENABLED=true on the worker and expose port 4201 on the worker pod.
References
- Prefect Helm chart: prefect-server chart
- Prefect server on Helm docs: Server on Helm
- Settings (env var names): Prefect 3 settings
If you can share which Helm chart version you’re on (and your ingress/prometheus setup), I can tailor the exact values blocks for your environment.Lior Barak
12/09/2025, 8:42 AMMarvin
12/09/2025, 8:42 AMMarvin
12/09/2025, 8:49 AMLior Barak
12/09/2025, 8:55 AM