Counts Counts

yaml
type: "io.kestra.core.tasks.executions.Counts"

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: 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 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.core.models.triggers.types.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 found
  • yaml {{ 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

total

  • Type: integer
  • Dynamic:
  • Required:

Definitions

io.kestra.core.tasks.executions.Counts-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: ✔️