<@ULVA73B9P> hi, what is the earliest version that...
# ask-marvin
l
@Marvin hi, what is the earliest version that contained the server metrics feature?
m
thought for 150.4 seconds
Shortest answer: Prefect 3.0.0 line. - Earliest tag with server metrics: 3.0.0rc14 - First stable release with it: 3.0.0 - Not available in any 2.x versions If you need docs for enabling it, see the settings reference: Prefect 3 settings.
l
@Marvin if i'm running a prefect server on kubernetes using helm how can I expose a metrics endpoint?
m
thought for 238.2 seconds
Great question. In Prefect 3.x, the API/server exposes Prometheus metrics on the same port as the API and at the path
/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)
Copy code
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
Copy code
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
Copy code
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.
l
@Marvin I have prefect version 2.14.1 self hosted, which version of Prometheus exporter is compatible with mine?
m
thought for 406.2 seconds
Short answer: use the 1.x series of the Prometheus exporter. Details: - The official exporter is here: prometheus-prefect-exporter - For Prefect 2.14.1 (self-hosted Orion), the compatible line is the 1.x releases of the exporter. Pin to the latest 1.x release from the releases page: releases - The 2.x+ exporter releases target Prefect 3.x and are not intended for Prefect 2.x. - Prefect 2.x does not expose a native /metrics endpoint; the exporter runs separately and scrapes Prefect’s API to emit Prometheus metrics. If you’re on Kubernetes, there’s a Helm chart you can use: - Chart: prefect-helm: prometheus-prefect-exporter - Helm repo index: prefect-helm repo If you share how you plan to deploy (Docker vs. Helm) and whether your Prefect API requires auth, I can provide a ready-to-run command with the right env vars.
l
@Amir Lasry boom