Metrics
A metric is a number a task records while it runs: how many rows a query returned, how long it took. Egret stores each metric with the execution that produced it and shows them in two places: the Metrics tab of an execution, and the Metrics tab of a flow, where the same metric is charted over time across runs.
The egret.sql task is the only task type that records metrics so far. Every other task type —
core tasks, script tasks, plugin tasks — runs without recording any, so their executions show an
empty Metrics tab. There is no task for publishing a metric of your own: Kestra's
metric.Publish is not available (see Task catalogue),
and Assert records no metric (it logs its N succeeded, M failed line instead).
What a task records
Each metric has a name, a kind, a numeric value, an optional set of tags
(key=value labels) and the time it was recorded. There are three kinds:
| Kind | Value | Example |
|---|---|---|
counter | A count. | rows — the number of rows a query returned. |
gauge | A point-in-time measurement. | None is recorded yet; the kind is read and charted if one appears. |
timer | A duration, stored in seconds. | query.duration — how long a statement took. |
An egret.sql task that succeeds records two metrics: a rows counter and a query.duration
timer, both with no tags. A failed query records nothing.
The execution Metrics tab
Open an execution and choose the Metrics tab. It is a table, newest first, with one row per metric:
| Column | What it shows |
|---|---|
| Task | The task that recorded the metric. |
| Name | The metric name, such as rows. |
| Type | counter, gauge or timer. |
| Value | The number (a timer is in seconds). |
| Tags | The key=value labels, if any. |
| Timestamp | When it was recorded. |
Filter by Task or by a single run of a task with the two dropdowns above the table; the filter is kept in the page address. The table is paged (50 rows a page). While the execution is still running the tab refreshes every five seconds, so metrics appear as the tasks that record them finish.
The flow Metrics tab
Open a flow and choose the Metrics tab to chart one metric over time across the flow's runs. Pick a Task (or all tasks), a Metric name, an Aggregate and a start and end time. The chart is a line of one value a time bucket; the bucket size is chosen from the range you ask for (a minute for a few hours, up to a month for more than a year). The default range is the last 30 days.
| Aggregate | Each bucket shows |
|---|---|
sum (default) | The total of the metric in the bucket. |
avg | The mean. |
min | The smallest value. |
max | The largest value. |
Buckets with no metric are drawn as zero, so the line is continuous.
Retention
A metric lives as long as its execution. Deleting an execution deletes its metrics with it, so
metrics follow the same workflow.storage_retention_days and manual-purge rules as the rest of
an execution's data. The PurgeExecutions
task has a purgeMetric property (default true): on a purge that keeps the executions
(purgeExecution: false) it deletes the matched executions' metrics on its own, and its
metricsCount output reports how many rows it removed. There is no separate time-based retention
for metrics.
The metrics API
The metrics are read through six endpoints under /api/ws/{workspace}/workflows/metrics/, in the
workflow OpenAPI group. All need the workflow:read permission on the flow, and all are
read-only (GET). See the Workflows API for authentication
and error conventions.
| Path | What it returns |
|---|---|
metrics/executions/{execution} | A page of one execution's metric rows. Query: taskId, taskRunId, limit (1–200, default 50), offset. |
metrics/names/{namespace}/{flow} | The distinct metric names a flow has recorded. |
metrics/names/{namespace}/{flow}/{task_id} | The distinct metric names one task has recorded. |
metrics/tasks/{namespace}/{flow} | The task ids of a flow that have recorded a metric. |
metrics/aggregates/{namespace}/{flow}/{metric} | A date-bucketed aggregation of one metric, flow-wide. Query: startDate, endDate, aggregation (sum, avg, min, max). |
metrics/aggregates/{namespace}/{flow}/{task_id}/{metric} | The same, for one task. |
The aggregate endpoints return the bucket size they chose as group_by and a dense series
(empty buckets carry a value of 0). An unknown aggregation, an unparseable date, or a start
after the end answers 400.
Limits and known issues
- Only
egret.sqlrecords metrics; every other task type records none (KI-366). - There is no way to record a custom metric from a flow:
metric.Publishis not available. Assertrecords no metric; it writes its counts to the logs.- Metrics recorded inside a Kestra plugin task (the plugin host's own
metric()) are not kept.