Python SDKFeature Clients

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_get_task_statsGet task statistics for the tenant.
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).
get_task_statsGet task statistics for the tenant.
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_get_task_stats

Get task statistics for the tenant.

Returns:

TypeDescription
dict[str, TaskStat]A dictionary mapping task names to their statistics.

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

get_task_stats

Get task statistics for the tenant.

Returns:

TypeDescription
dict[str, TaskStat]A dictionary mapping task names to their statistics.

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

Last updated on September 1, 2026

On this page