Counts
yaml
type: "io.kestra.core.tasks.executions.Counts"
List execution counts for a list of flow
Can be used to send an alert if a condition is met about execution counts.
Examples
Send a slack notification if no execution for a flow on the last 24h
yaml
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
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:
null
: no execution foundnull
: 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 state to be filtered
Outputs
results
- Type: array
- SubType: Result
total
- Type: integer
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: ✔️