We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking "Accept", you agree to our use of cookies.
Learn more.

SDK ReferencePython SDKFeature ClientsMetrics

Metrics Client

Bases: BaseRestClient

The metrics client is a client for reading metrics out of Hatchet’s metrics API.

Methods:

NameDescription
aio_get_queue_metricsRetrieve the current queue metrics for the tenant.
aio_get_task_metricsRetrieve task metrics, grouped by status (queued, running, completed, failed, cancelled).
aio_scrape_tenant_prometheus_metricsScrape Prometheus metrics for the tenant. Returns the metrics in Prometheus text format.
get_queue_metricsRetrieve the current queue metrics for the tenant.
get_task_metricsRetrieve task metrics, grouped by status (queued, running, completed, failed, cancelled).
scrape_tenant_prometheus_metricsScrape Prometheus metrics for the tenant. Returns the metrics in Prometheus text format.

Functions

aio_get_queue_metrics

Retrieve the current queue metrics for the tenant.

Returns:

TypeDescription
dict[str, Any]The current queue metrics

aio_get_task_metrics

Retrieve task metrics, grouped by status (queued, running, completed, failed, cancelled).

Parameters:

NameTypeDescriptionDefault
sincedatetime | NoneStart time for the metrics query (defaults to the past day if unset)None
untildatetime | NoneEnd time for the metrics queryNone
workflow_idslist[str] | NoneList of workflow IDs to filter the metrics byNone
parent_task_external_idstr | NoneID of the parent task to filter by (note that parent task here refers to the task that spawned this task as a child)None
triggering_event_external_idstr | NoneID of the triggering event to filter byNone

Returns:

TypeDescription
TaskMetricsTask metrics

aio_scrape_tenant_prometheus_metrics

Scrape Prometheus metrics for the tenant. Returns the metrics in Prometheus text format.

Returns:

TypeDescription
strThe metrics, returned in Prometheus text format

get_queue_metrics

Retrieve the current queue metrics for the tenant.

Returns:

TypeDescription
dict[str, Any]The current queue metrics

get_task_metrics

Retrieve task metrics, grouped by status (queued, running, completed, failed, cancelled).

Parameters:

NameTypeDescriptionDefault
sincedatetime | NoneStart time for the metrics query (defaults to the past day if unset)None
untildatetime | NoneEnd time for the metrics queryNone
workflow_idslist[str] | NoneList of workflow IDs to filter the metrics byNone
parent_task_external_idstr | NoneID of the parent task to filter by (note that parent task here refers to the task that spawned this task as a child)None
triggering_event_external_idstr | NoneID of the triggering event to filter byNone

Returns:

TypeDescription
TaskMetricsTask metrics

scrape_tenant_prometheus_metrics

Scrape Prometheus metrics for the tenant. Returns the metrics in Prometheus text format.

Returns:

TypeDescription
strThe metrics, returned in Prometheus text format