Count
yaml
type: "io.kestra.plugin.core.execution.Count"
List execution counts for a list of flow.
This can be used to send an alert if a condition is met about execution counts.
Examples
Send a slack notification if there is no execution for a flow for the last 24 hours.
yaml
id: executions-count
namespace: company.team
tasks:
- id: counts
type: io.kestra.plugin.core.execution.Counts
expression: "{{ count == 0 }}"
flows:
- namespace: company.team
flowId: logs
startDate: "{{ now() | dateAdd(-1, 'DAYS') }}"
- id: each_parallel
type: io.kestra.plugin.core.flow.EachParallel
tasks:
- id: slack_incoming_webhook
type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
payload: |
{
"channel": "#run-channel",
"text": ":warning: Flow <code v-pre>{{ jq taskrun.value '.namespace' true }}</code>.<code v-pre>{{ jq taskrun.value '.flowId' true }}</code> has no execution for last 24h!"
}
url: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
value: "{{ jq outputs.counts.results '. | select(. != null) | .[]' }}"
triggers:
- id: schedule
type: io.kestra.plugin.core.trigger.Schedule
backfill: {}
cron: "0 4 * * * "
Properties
expression
- Type: string
- Dynamic: ✔️
- Required: ✔️
The expression to look at against each flow.
The expression is such that expression must return
true
in order to keep the current line. Some examples:
yaml {{ eq count 0 }}
: no execution foundyaml {{ gte count 5 }}
: more than 5 executions
flows
- Type: array
- SubType: Flow
- Dynamic: ❌
- Required: ✔️
- Min items:
1
A list of flows to be filtered.
startDate
- Type: string
- Dynamic: ✔️
- Required: ✔️
The start date.
endDate
- Type: string
- Dynamic: ✔️
- Required: ❌
The end date.
states
- Type: array
- SubType: string
- Dynamic: ❌
- Required: ❌
A list of states to be filtered.
Outputs
results
- Type: array
- SubType: Count-Result
- Dynamic: ❓
- Required: ❌
total
- Type: integer
- Dynamic: ❓
- Required: ❌
Definitions
io.kestra.plugin.core.execution.Count-Result
Properties
count
- Type: integer
- Dynamic: ❓
- Required: ❓
flowId
- Type: string
- Dynamic: ❓
- Required: ❓
namespace
- Type: string
- Dynamic: ❓
- Required: ❓
io.kestra.core.models.executions.statistics.Flow
Properties
flowId
- Type: string
- Dynamic: ❓
- Required: ✔️
namespace
- Type: string
- Dynamic: ❓
- Required: ✔️
Was this page helpful?