Registry / observability / dagster-prometheus

dagster-prometheus

JSON →
library0.29.9pypypi✓ verified 85d ago

Dagster-prometheus is a library that provides an integration for Dagster with Prometheus, allowing users to expose Dagster run and asset metrics, as well as custom metrics from their ops and assets. It is part of the Dagster ecosystem and typically releases new versions in lockstep with Dagster core releases. The current version is 0.29.0, corresponding to Dagster core 1.13.0.

pip install dagster-prometheus
INSTALL
IMPORT
SIG · DAGSTER-PROMETHEUS
D
dagster-prometheus
observabilitypythonv0.29.9
Install
12.9s avg
Import
Disk
134MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.29.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 131.6MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 12.9s · import 0.000s · 127MB
134MB installed
● package 134MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PrometheusResource
from dagster_prometheus import PrometheusResource
from dagster_prometheus import make_prometheus_resource
prometheus_resource
from dagster_prometheus import prometheus_resource
DagsterLibraryRegistry
from dagster_prometheus import DagsterLibraryRegistry

This example demonstrates how to define a Prometheus resource using `make_prometheus_resource`, attach it to a job, and then use the resource's exposed Prometheus registry within an op to emit custom metrics. The resource automatically starts an HTTP server for Prometheus to scrape metrics.

import os from dagster import Definitions, job, op from dagster_prometheus import make_prometheus_resource # The Prometheus resource starts an HTTP server and exposes the # prometheus_client registry for custom metrics. prometheus_resource = make_prometheus_resource( port=int(os.environ.get("PROMETHEUS_PORT", "8000")), prefix=os.environ.get("PROMETHEUS_PREFIX", "dagster_"), ) @op def emit_custom_metrics_op(context): """ An op that emits custom Prometheus metrics using the provided registry. The HTTP server will be running as long as the resource is active (e.g., during a job run). """ registry = context.resources.prometheus_resource.registry # Create and increment a custom counter my_counter = registry.get_or_create_metric( "my_custom_run_counter", "A counter for runs of my_metrics_job", "counter" ) my_counter.inc() # Create and set a custom gauge with labels my_gauge = registry.get_or_create_metric( "my_custom_value_gauge", "A gauge for a custom value", "gauge", labelnames=["job_name", "op_name"] ) # Example value derived from run_id, ensures a different value each time for demo example_value = float(int(context.run_id.split('-')[0], 16) % 100) my_gauge.labels(job_name=context.job_name, op_name=context.op.name).set(example_value) context.log.info(f"Emitted custom metrics to port {context.resources.prometheus_resource.port}") @job(resource_defs={"prometheus_resource": prometheus_resource}) def my_metrics_job(): emit_custom_metrics_op() defs = Definitions(jobs=[my_metrics_job]) # To run this example locally: # 1. Save the code as a Python file (e.g., `metrics_repo.py`). # 2. Run `dagster dev -f metrics_repo.py` in your terminal. # 3. In the Dagster UI (typically localhost:3000), navigate to the Launchpad for `my_metrics_job` and click 'Launch'. # 4. While the job is running (or if `dagster dev` is active), open your browser to `http://localhost:8000/metrics` # (or the port specified in PROMETHEUS_PORT if set) to view the exposed metrics. # You will see Dagster's default metrics along with 'dagster_my_custom_run_counter_total' and 'dagster_my_custom_value_gauge'.
Debug
Known issues
breakingDagster's resource API underwent significant changes with the 1.0 release. If you are upgrading from Dagster core versions prior to 1.0, your existing resource definitions, including those for `dagster-prometheus`, will likely need to be updated to the new resource definition syntax.
fix
Consult the Dagster 1.0 migration guide for updating resource definitions. Ensure `dagster-prometheus` is updated to a version compatible with your Dagster core version.
affects: All `dagster-prometheus` versions used with Dagster core < 1.0
gotchaThe Prometheus HTTP server started by `make_prometheus_resource` is bound to the lifespan of the Dagster process that initializes the resource (e.g., a specific job run process, or the `dagster dev` process). For continuous metric exposure in a production environment, ensure the Dagster process (e.g., `dagster-webserver`, `dagster-daemon`, or a persistent run process) is long-lived.
fix
For persistent metrics, consider running the Prometheus resource in a long-lived Dagster deployment, or implement a Prometheus Pushgateway if metrics need to be pushed from ephemeral jobs.
affects: All versions
gotcha`dagster-prometheus` is a library within the Dagster monorepo. While its own versioning (0.x.y) is separate from Dagster core (1.x.y), it is developed and released in tandem. Using mismatched versions of `dagster-prometheus` and `dagster` core can lead to unexpected behavior or `ImportError`s.
fix
Always install `dagster-prometheus` alongside a compatible version of `dagster`. Generally, installing the latest `dagster-prometheus` with the latest `dagster` core version is recommended. For example, `dagster-prometheus==0.29.0` is designed for `dagster==1.13.0`.
affects: All versions
Upgrade
Version history
0.29.9latest on PyPI · released Jun 11, 2026
Audit
Dependencies
dagsterrequiredCore data orchestration platform, required for defining jobs and resources.
prometheus_clientrequiredPython client for Prometheus, used internally by the resource to expose metrics.
Agent activity
29 hits · last 30 days
node
28
OpenAI (training)
1
Resources
dagster-prometheus — pip install dagster-prometheus · libregistry