Enable Prometheus
You will need to addENABLE_PROMETHEUS environment variable as true in order to
enable Prometheus style metrics on the <BASE_PATH>/metrics route.
Prometheus metrics
When enabled, Mage will publish Metrics for the HTTP Server (Tornado) as well as for the Python Runtime. The /metrics route will be updated on-demand to respond to scrape requests.Kubernetes resource usage in Mage Pro
In Mage Pro, Kubernetes executor resource usage summaries can optionally read historical CPU and memory samples from Prometheus. SetK8S_RESOURCE_USAGE_PROMETHEUS_URL to your Prometheus base URL to make
Prometheus the preferred source for K8s resource usage metrics. If Prometheus is
not configured or does not return samples for the run pod, Mage falls back to the
Kubernetes Metrics API when it is available.
Mage queries Prometheus for the completed run pod by namespace and pod name. CPU
usage is read from container_cpu_usage_seconds_total, and memory usage is read
from container_memory_working_set_bytes. The stored samples power the
Resources tab on pipeline run pages and the K8s resource usage panel in
pipeline monitoring.
Set up Prometheus for resource usage
For self-hosted or private-cloud Mage Pro clusters, install Prometheus in the same Kubernetes cluster as the Mage deployment and expose it to the Mage server pod through an internal Kubernetes service. Keep Prometheus as aClusterIP
service unless your platform already provides an authenticated internal gateway.
Install Prometheus separately from the Mage Pro Helm chart:
kube-prometheus-stack is commonly
prometheus-kube-prometheus-prometheus, but it can differ based on the Helm
release name and chart values.
Verify required metrics
Mage Pro needs cAdvisor container CPU and memory metrics. Port-forward Prometheus, then check that the metrics exist for pods in the namespace where K8s executor jobs run:mage with the namespace used by your K8s executor pods. If either
query returns 0, confirm that Prometheus is scraping kubelet/cAdvisor metrics
for that namespace before enabling Mage Pro resource usage collection.
Configure Mage Pro
Set the Prometheus URL on the Mage Pro web/server deployment. Use the in-cluster service DNS name so traffic stays inside the cluster:Managed cloud deployments
For managed cloud deployments, do not configure customer Mage Pro clusters to query a shared Prometheus service directly. Route resource usage requests through a tenant-aware gateway, such asmage-pro-api, so authentication,
authorization, and tenant label scoping happen before Prometheus is queried.