Counts
type: "io.kestra.core.tasks.executions.Counts"
List execution counts for a list of flow
Mostly use for send an alert if a conditions is meet about execution counts.
# Examples
Send a slack notification if no execution for a flow on last 24h
id: executions-count
namespace: io.kestra.tests
tasks:
- id: counts
type: io.kestra.core.tasks.executions.Counts
expression: "{{ count == 0 }}"
flows:
- namespace: io.kestra.tests
flowId: logs
startDate: "{{ now() | dateAdd(-1, 'DAYS') }}"
- id: each_parallel
type: io.kestra.core.tasks.flows.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 on last 24h !"
}
url: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
value: "{{ jq outputs.counts.results '. | select(. != null) | .[]' }}"
triggers:
- id: schedule
type: io.kestra.core.models.triggers.types.Schedule
backfill: {}
cron: "0 4 * * * "
# Properties
# endDate
- Type: string
- Dynamic: ✔️
- Required: ❌
The end date
# expression
- Type: string
- Dynamic: ✔️
- Required: ✔️
The expression against each flows to look at
The expression is as handlebars expression must return true
in order to keep the current line
some examples:
{{ eq count 0 }}
: no execution found{{ 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
# states
- Type: array
- SubType: string
- Dynamic: ❌
- Required: ❌
A list of state to be filtered
# Outputs
# results
- Type: array
- SubType: Result
# Definitions
# Result
# count
- Type: integer
- Dynamic: ❓
- Required: ❌
# flowId
- Type: string
- Dynamic: ❓
- Required: ❌
# namespace
- Type: string
- Dynamic: ❓
- Required: ❌
# Flow
# flowId
- Type: string
- Dynamic: ❓
- Required: ✔️
# namespace
- Type: string
- Dynamic: ❓
- Required: ✔️
← Return AllowFailure →