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_metricstask_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:
| Name | Description |
|---|---|
get_queue_metrics | Retrieve the current queue metrics for the tenant. |
scrape_tenant_prometheus_metrics | Scrape Prometheus metrics for the tenant. |
get_task_stats | Get task statistics for the tenant. |
get_task_metrics | Retrieve 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_metricsReturns:
| Type | Description |
|---|---|
Hash | The current queue metrics. |
Raises:
| Type | Description |
|---|---|
HatchetSdkRest::ApiError | If the API request fails. |
scrape_tenant_prometheus_metrics
Scrape Prometheus metrics for the tenant.
prometheus_text = hatchet.metrics.scrape_tenant_prometheus_metricsReturns:
| Type | Description |
|---|---|
String | The metrics in Prometheus text format. |
Raises:
| Type | Description |
|---|---|
HatchetSdkRest::ApiError | If the API request fails. |
get_task_stats
Get task statistics for the tenant.
stats = hatchet.metrics.get_task_statsReturns:
| Type | Description |
|---|---|
Object | The task statistics. |
Raises:
| Type | Description |
|---|---|
HatchetSdkRest::ApiError | If 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:
| Name | Type | Description | Default |
|---|---|---|---|
since | Time | nil | Start time for the metrics query (defaults to the past day if unset) | nil |
until_time | Time | nil | End time for the metrics query. | nil |
workflow_ids | Array<String> | nil | List of workflow IDs to filter the metrics by. | nil |
parent_task_external_id | String | nil | ID of the parent task to filter by. | nil |
triggering_event_external_id | String | nil | ID of the triggering event to filter by. | nil |
Returns:
| Type | Description |
|---|---|
TaskMetrics | Task metrics with counts per status. |
Raises:
| Type | Description |
|---|---|
HatchetSdkRest::ApiError | If the API request fails. |
Last updated on August 24, 2026