Monitor Task Run States, Attempts, and Outputs

For the complete documentation index, see llms.txt. For a full content snapshot, see llms-full.txt. Append .md to any kestra.io/docs/* URL for plain Markdown.

A task run is a single execution of an individual task within an Execution, where an execution represents a run of the entire flow. One execution can therefore contain multiple task runs.

Attempts

A task run can include one or more attempts. Most have only a single attempt, but you can configure retries if needed. When retries are enabled, a task failure triggers new attempts until the maxAttempts or maxDuration threshold is reached.

States

Similar to executions, task runs can exist in different states.

StateDescription
CREATEDThe task run is waiting to be processed, usually queued and not yet started.
SUBMITTEDThe task run has been submitted to a Worker but has not started running yet.
RUNNINGThe execution or task run is currently being processed.
SUCCESSThe execution or task run has been completed successfully.
WARNINGThe task run had issues but continued, flagged with a warning.
FAILEDThe task run encountered errors that caused the execution to fail.
RETRYINGThe execution or task run is currently being retried.
RETRIEDAn execution or task run exhibited unintended behavior, stopped, and created a new execution as defined by its flow-level retry policy. The policy was set to the CREATE_NEW_EXECUTION behavior.
KILLINGA kill command was issued and the system is terminating the task run.
KILLEDAn execution or task run was killed (upon request), and no more tasks will run.

For a detailed overview of how task runs transition through states, see the States page.

Expression

You can access information about the current task run using the {{ taskrun }} expression.

The following example outputs task run details using {{ taskrun }}:

id: taskrun
namespace: company.team
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ taskrun }}"

The logs show the following:

{
"id": "61TxwXQjkXfwTd4ANK6fhv",
"startDate": "2024-11-13T14:38:38.355668Z",
"attemptsCount": 0
}

Loop iteration context

Inside a Loop task, each iteration runs as an isolated sub-execution. Use {{ item.value }} and {{ item.index }} to access the current iteration value and zero-based index from any task inside that sub-execution, including tasks nested inside If, Parallel, or other flowable tasks.

id: loop
namespace: company.team
tasks:
- id: loop
type: io.kestra.plugin.core.flow.Loop
values: [1, 2, 3]
tasks:
- id: log
type: io.kestra.plugin.core.log.Log
message: |
value={{ item.value }}
index={{ item.index }}
taskrun.id={{ taskrun.id }}
taskrun.startDate={{ taskrun.startDate }}
taskrun.attemptsCount={{ taskrun.attemptsCount }}
taskrun.parentId={{ taskrun.parentId }}

For nested loops, {{ item.parent.value }} accesses the immediate enclosing loop’s value, and {{ item.parents[n].value }} accesses deeper ancestors ([0] = immediate parent, [1] = grandparent, and so on).

See Loop iteration context in the expressions reference for the full item variable table.

Task Run JSON Object Example
{
"id": "5cBZ1JF8kim8fbFg13bumX",
"executionId": "6s1egIkxu3gpzzILDnyxTn",
"namespace": "io.kestra.tests",
"flowId": "each-sequential-nested",
"taskId": "1-1_return",
"parentTaskRunId": "5ABxhOwhpd2X8DtwUPKERJ",
"value": "s1",
"attempts": [
{
"metrics": [
{
"name": "length",
"tags": {
"format": "{{task.id}} > {{item.value}} ⬅ {{taskrun.startDate}}"
},
"value": 45.0,
"type": "counter"
},
{
"name": "duration",
"tags": {
"format": "{{task.id}} > {{item.value}} ⬅ {{taskrun.startDate}}"
},
"type": "timer",
"value": "PT0.007213673S"
}
],
"state": {
"current": "SUCCESS",
"histories": [
{
"state": "CREATED",
"date": "2025-05-04T12:02:54.121836Z"
},
{
"state": "RUNNING",
"date": "2025-05-04T12:02:54.121841Z"
},
{
"state": "SUCCESS",
"date": "2025-05-04T12:02:54.131892Z"
}
],
"duration": "PT0.010056S",
"endDate": "2025-05-04T12:02:54.131892Z",
"startDate": "2025-05-04T12:02:54.121836Z"
}
}
],
"outputs": {
"value": "1-1_return > s1 ⬅ 2025-05-04T12:02:53.938333Z"
},
"state": {
"current": "SUCCESS",
"histories": [
{
"state": "CREATED",
"date": "2025-05-04T12:02:53.938333Z"
},
{
"state": "RUNNING",
"date": "2025-05-04T12:02:54.116336Z"
},
{
"state": "SUCCESS",
"date": "2025-05-04T12:02:54.144135Z"
}
],
"duration": "PT0.205802S",
"endDate": "2025-05-04T12:02:54.144135Z",
"startDate": "2025-05-04T12:02:53.938333Z"
}
}

Was this page helpful?