MetricsRegistry#
- class openfactory.monitoring.registry.src.metrics_registry.MetricsRegistry(*args, **kwargs)[source]#
Bases:
OpenFactoryFastAPIAppOpenFactory Metrics Registry.
This service acts as a bridge between OpenFactory applications and Prometheus HTTP Service Discovery.
Applications register and deregister Prometheus metrics endpoints through OpenFactory methods. Registered endpoints are persisted in Kafka and materialized into a KSQLDB table.
Prometheus periodically queries the HTTP discovery endpoint to obtain the list of metrics targets to scrape.
By default, the discovery endpoint is exposed at:
/prometheus/targets
This can be overridden using the environment variable
PROMETHEUS_SD_ENDPOINT.The registry itself does not store any state in memory. Kafka and KSQLDB are the source of truth for all registered metrics endpoints.
- __init__(*args, **kwargs)[source]#
Initialize the MetricsRegistry.
This constructor forwards all parameters to
OpenFactoryFastAPIApp- Environment Variables:
- PROMETHEUS_SD_ENDPOINT:
HTTP endpoint exposing the Prometheus HTTP Service Discovery target list.
- Default:
/prometheus/targets
- Parameters:
ksqlClient – KSQL client instance.
bootstrap_servers – Kafka bootstrap server address.
asset_router_url – Asset Router URL.
loglevel – Logging level (e.g.,
INFO,DEBUG).test_mode – Enables test mode (disables live Kafka/ksql interaction).
See also
OpenFactoryFastAPIAppfor full initialization details and environment variable handling.
- prometheus_targets()[source]#
Return metrics targets using the Prometheus HTTP Service Discovery format.
Prometheus periodically invokes this endpoint to discover metrics endpoints exposed by OpenFactory applications.
- Returns:
list[dict] – List of Prometheus target definitions.
Example:
[ { "targets": ["shdr-gateway:4000"], "labels": { "__metrics_path__": "/metrics" } } ]