Ruby SDKFeature Clients

Metrics Client

Metrics client for reading metrics out of Hatchet's metrics API.

This class provides a high-level interface for retrieving queue metrics, Prometheus metrics, task statistics, and task metrics from the Hatchet system.

metrics = hatchet.metrics.get_queue_metrics
task_metrics = hatchet.metrics.get_task_metrics(
  since: Time.now - 86400,
  workflow_ids: ["wf-1"]
)

It is available on the main client as hatchet.metrics.

Methods:

NameDescription
get_queue_metricsRetrieve the current queue metrics for the tenant.
scrape_tenant_prometheus_metricsScrape Prometheus metrics for the tenant.
get_task_statsGet task statistics for the tenant.
get_task_metricsRetrieve task metrics grouped by status (queued, running, completed, failed, cancelled)

Functions

get_queue_metrics

Retrieve the current queue metrics for the tenant.

queues = hatchet.metrics.get_queue_metrics

Returns:

TypeDescription
HashThe current queue metrics.

Raises:

TypeDescription
HatchetSdkRest::ApiErrorIf the API request fails.

scrape_tenant_prometheus_metrics

Scrape Prometheus metrics for the tenant.

prometheus_text = hatchet.metrics.scrape_tenant_prometheus_metrics

Returns:

TypeDescription
StringThe metrics in Prometheus text format.

Raises:

TypeDescription
HatchetSdkRest::ApiErrorIf the API request fails.

get_task_stats

Get task statistics for the tenant.

stats = hatchet.metrics.get_task_stats

Returns:

TypeDescription
ObjectThe task statistics.

Raises:

TypeDescription
HatchetSdkRest::ApiErrorIf the API request fails.

get_task_metrics

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

metrics = hatchet.metrics.get_task_metrics(
  since: Time.now - 86400,
  workflow_ids: ["wf-1"]
)
puts "Completed: #{metrics.completed}, Failed: #{metrics.failed}"

Parameters:

NameTypeDescriptionDefault
sinceTime | nilStart time for the metrics query (defaults to the past day if unset)nil
until_timeTime | nilEnd time for the metrics query.nil
workflow_idsArray<String> | nilList of workflow IDs to filter the metrics by.nil
parent_task_external_idString | nilID of the parent task to filter by.nil
triggering_event_external_idString | nilID of the triggering event to filter by.nil

Returns:

TypeDescription
TaskMetricsTask metrics with counts per status.

Raises:

TypeDescription
HatchetSdkRest::ApiErrorIf the API request fails.

Last updated on August 24, 2026

On this page