Introducing a new way to review your PRs.

Read the announcement

keephq / keep

The open-source AIOps and alert management platform

View on GitHub

22 documents · Updated Nov 23, 2026

docs / workflow-automation

Workflow automation

Keep workflow automation turns alert and incident events into repeatable operational work. A workflow matches an event or a time schedule, checks whether its rules allow a run, gathers data through steps, and sends results through actions such as notifications or updates.

Automation model

Workflow purpose

A workflow is a named automation plan for one tenant. It combines trigger rules with ordered work and keeps the event context available while that work runs. The plan can be enabled or disabled and can record its revision, owner, providers, and execution history.

References: keep/…/workflow.py• L22-69 keep/…/workflow.py• L12-39 keep/…/workflow.py• L25-47

Trigger sources

Triggers define when Keep considers a workflow for execution. Alert triggers inspect incoming alerts, incident triggers respond to incident events, manual triggers support an explicit run, and interval triggers make a workflow run on a time cycle.

Keep checks enabled workflows for each relevant event. A workflow may have more than one trigger, so the same plan can support event-driven work and operator-driven work when the definition requires it.

References: keep/…/workflowmanager.py• L124-176 keep/…/workflowmanager.py• L287-317 keep/…/parser.py• L872-884

Matching rules

Alert matching uses the event as the input to a rule. New definitions use a CEL expression, which is a small expression language for testing event fields. Older key and value filters remain supported through conversion to CEL.

Matching happens before Keep adds the workflow to the run queue. A rule can also require a field to change since the prior alert with the same fingerprint. A fingerprint is the value Keep uses to group repeated alert events. This prevents a workflow from repeating work when the relevant alert state did not change.

References: keep/…/workflowmanager.py• L287-361 keep/…/workflowmanager.py• L402-470 keep/…/workflowmanager.py• L472-526 keep/…/alert.py• L25-37 keep/…/alert.py• L100-102

Workflow work

Steps

Steps gather data or perform an intermediate query before later work uses it. Their output becomes part of the workflow context, so later conditions and actions can use the result.

Steps run in definition order. A step can stop the remaining work after it succeeds, continue after an error, retry a failed provider call, or process each value in a collection. These controls let a workflow express both a short chain and a guarded sequence without changing the event that started it.

References: keep/…/parser.py• L488-522 keep/…/step.py• L19-65 keep/…/step.py• L73-160 keep/…/step.py• L331-386

Conditions

Conditions decide whether a step or action should run. They compare rendered workflow data with a rule and save the result in the shared workflow context.

The workflow supports named condition types. A threshold condition checks a value against a numeric or percentage limit. An assert condition evaluates an expression. When a work item has several conditions and no explicit if rule, Keep requires all of them to pass. An explicit if rule can define a different combined decision.

References: keep/…/step.py• L162-272 keep/…/base_condition.py• L11-71 keep/…/condition_factory.py• L7-21 keep/…/threshold_condition.py• L94-134 keep/…/assert_condition.py• L16-55

Actions

Actions produce the external effect of a workflow. They use a configured provider to notify a service or change a system after the workflow has gathered and checked its data.

Actions run after the steps. Each action can be conditional, throttled, retried, or set to stop later actions. Keep stores provider results with the execution so an operator can see what the automation returned.

References: keep/…/parser.py• L676-702 keep/…/step.py• L304-386 keep/…/workflow.py• L110-171 keep/…/workflowmanager.py• L729-736

Scheduling and execution

Event scheduling

The scheduler is the handoff point between a matched event and background work. Matching code places an independent workflow instance in the scheduler queue, and the scheduler submits it to a worker for execution.

The queue keeps event work separate from event intake. This allows Keep to accept an event without waiting for provider calls to finish. The scheduler also tracks active work and periodically checks for executions that take too long.

References: keep/…/workflowmanager.py• L526-596 keep/…/workflowscheduler.py• L408-477 keep/…/workflowscheduler.py• L630-672

Interval scheduling

An interval trigger runs an enabled workflow when its last completed run is older than the configured interval. The interval can be expressed as seconds or as a simple minute, hour, or day value.

The scheduler creates an execution record before it submits interval work. That record acts as a shared claim, which prevents more than one scheduler worker from starting the same interval run at the same time.

References: keep/…/parser.py• L414-449 keep/…/db.py• L319-419 keep/…/workflowscheduler.py• L115-182

Concurrency policy

A workflow strategy controls what happens when the same alert fingerprint reaches a workflow while an earlier run is still active. Parallel work allows both runs. Non-parallel work rejects the collision. Non-parallel work with retry places the later event back in the queue for a later run.

The default policy favors retry. On a retry, Keep refreshes enrichment data before it runs the event. This helps the later run use the newest alert state instead of repeating the first event snapshot.

References: keep/…/workflow.py• L13-20 keep/…/workflowscheduler.py• L497-571 keep/…/workflowscheduler.py• L576-629

Execution flow

This flow shows how an incoming signal becomes a recorded automation result.

flowchart LR
    A[Alert or incident] --> B[Match trigger]
    B -->|match| C[Queue workflow]
    B -->|no match| X[No run]
    C --> D[Create execution record]
    D --> E[Run steps]
    E --> F[Evaluate conditions]
    F -->|allowed| G[Run actions]
    F -->|not allowed| H[Skip work item]
    G --> I[Save results and status]
    E -->|failure| J[Run failure action]
    J --> I

The same background path serves event and interval runs. Manual runs use the API to create a tracked execution and then enter the scheduler queue. Test runs use a parsed definition and are marked separately from normal workflow history.

References: keep/…/workflowscheduler.py• L184-282 keep/…/workflowscheduler.py• L284-353 keep/…/workflows.py• L357-451 keep/…/workflows.py• L486-579

Automation outcomes

Execution records

Each run has an execution record that links the workflow, revision, tenant, trigger, status, error, duration, results, and event identity. Logs and links to the source alert or incident make the run traceable from the automation back to the event.

Execution status reports success, an error, or a provider configuration problem. The scheduler marks the record when work ends, when setup fails, or when a run times out.

References: keep/…/workflow.py• L77-170 keep/…/workflow.py• L172-203 keep/…/workflowscheduler.py• L710-725 keep/…/workflow.py• L111-124

Failure handling

A failed step or action can stop the workflow or allow later work to continue, based on the work item policy. A workflow-level failure action can notify or record the failure after a run reports errors.

Provider setup failures are kept distinct from ordinary run errors. This tells an operator whether the workflow logic failed or whether Keep could not use a required integration. Repeated failures can also produce an email notice when email delivery is enabled.

References: keep/…/workflow.py• L71-108 keep/…/workflowmanager.py• L637-706 keep/…/workflowscheduler.py• L136-172 keep/…/workflowscheduler.py• L727-762

Run access

Workflow execution is tenant-scoped and can require a user email or role listed in the workflow permissions. Administrators can run a protected workflow, while other users need a matching permission.

Manual execution accepts an alert or incident event and optional inputs. The API checks the request before it creates the execution, which keeps the run record tied to the user and the event supplied for that run.

References: keep/…/workflow.py• L201-218 keep/…/workflows.py• L357-425 keep/…/workflowscheduler.py• L284-353

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to trigger fields must stay aligned across event matching, interval discovery, manual run input, and the workflow representation returned to clients.
  • Changes to execution status or trigger labels must stay aligned between scheduler updates, stored execution records, API response models, and any notification that reports a failure.
  • Changes to fingerprint or collision rules must preserve the link between an alert event, its execution number, and the selected concurrency strategy.
  • Changes to step or action continuation behavior must preserve the point at which workflow results and failure actions are recorded.
  • Changes to workflow revisions must keep the executed revision connected to the stored workflow version and its execution history.

Important failure modes

TriggerConsequenceGuard
A trigger has neither a usable CEL rule nor valid legacy filtersThe workflow is skipped or may be considered for an unintended eventValidate trigger rules before saving or enabling the workflow
A required provider is not configuredThe execution ends with a provider configuration error and no provider work runsConfigure every provider referenced by steps and actions
A non-parallel workflow receives the same fingerprint during an active runThe event is rejected or delayed according to the workflow strategySelect retry when later alert state must be preserved
A step or action fails with error continuation disabledRemaining work stops and the execution reports an errorUse retry or explicit continuation only for work that can safely proceed
An interval execution remains in progress beyond its timeoutThe scheduler marks it timed out and can relaunch interval workKeep long provider calls within the workflow timeout or inspect worker health

Key files

FileWhy to read it
keep/…/workflowmanager.pyConnects incoming alerts and incidents to trigger matching and queued workflow runs.
keep/…/workflowscheduler.pyCoordinates event and interval scheduling, background execution, collision handling, and final status.
keep/…/workflow.pyDefines the high-level run order for steps, actions, and workflow-level failure work.
keep/…/step.pyShows the shared behavior for conditions, provider calls, retries, throttling, and context updates.
keep/…/parser.pyMaps a workflow definition to triggers, steps, actions, schedule values, and runtime policy.
keep/…/workflow.pyDefines the durable relationship between workflows, revisions, executions, logs, and source events.
keep/…/workflows.pyExposes workflow listing and manual or test execution entry points.