For the complete documentation index, see llms.txt. This page is also available as Markdown.

Use CEL Expressions in Runbook Triggers

Learn how to use CEL expressions to write dynamic trigger conditions for runbooks in Harness AI SRE.

CEL (Common Expression Language) expressions provide conditional logic for trigger conditions that go beyond simple field comparisons.

CEL expressions cannot be tested or previewed before they execute. Syntax validation occurs when you save, but runtime errors only appear in execution logs. Test triggers in non-production environments first.

FEATURE FLAG REQUIRED

CEL expression mode requires the IR_CEL_CONDITIONS feature flag. Contact your Harness account team to enable this feature.

Access CEL mode in triggers

To switch a trigger from Rule mode to CEL mode:

  1. Open your runbook and go to the Triggers tab

  2. Click + New Trigger or edit an existing trigger

  3. In the conditions section, look for the Rule/CEL toggle or mode selector

  4. Select CEL mode

  5. The UI switches to show ${{}} delimiters with a text input area

  6. Type your CEL boolean expression

  7. The input provides syntax highlighting for CEL keywords and operators


CEL trigger syntax

CEL trigger conditions must evaluate to a boolean (true or false). When the expression evaluates to true, the runbook executes.

Basic structure:

The ${{}} delimiters are displayed in the UI but you only need to write the expression inside them.


Available data in trigger conditions

Incident-based triggers can access:

Alert-based triggers can access:


Common CEL trigger patterns

Severity and environment:

Multiple severities:

Service pattern matching:

Complex multi-condition logic:

Alert source filtering:


CEL trigger examples by use case

1. Critical production incidents only:

2. High-severity incidents in any environment:

3. Payment service issues:

4. Production issues affecting multiple users:

5. After-hours critical alerts (requires time input):

6. Database incidents requiring immediate escalation:

7. API errors above threshold:

8. Unassigned critical incidents:

9. Multi-service outages:

10. Customer-impacting incidents:


CEL versus Rule mode comparison

Rule mode example:

  • Condition Type: ALL

  • Field: severity

  • Operator: equals

  • Value: "0"

  • AND

  • Field: environment

  • Operator: equals

  • Value: "production"

Equivalent CEL expression:

Rule mode limitations overcome by CEL:

  • Cannot use regex matching. CEL: .matches()

  • Cannot check multiple values efficiently. CEL: in ["0", "1"]

  • Cannot perform calculations. CEL: (errors / total) > 0.05

  • Cannot check null values. CEL: owner != null

  • Limited string operations. CEL: .contains(), .startsWith(), .endsWith()


Trigger frequency with CEL

CEL conditions work with all trigger frequency options:

Activity Created:

Activity Updated:

Key Event Created:


Troubleshooting CEL triggers

Trigger not activating when expected

Check your condition returns a boolean, not a value. incident.severity returns a string, not a boolean. Use incident.severity == "0" to return true or false. Verify the condition is true when the trigger should fire.

Syntax validation errors when saving trigger

Use == for comparison, not single =. Check for unclosed strings, missing parentheses, or typos in field names. Use the exact namespace prefix (incident. or alert.). The error message shows the position of the syntax error.

Field not found errors in trigger execution logs

Verify the field name matches exactly (case-sensitive). Use incident. or alert. prefix. For custom fields, ensure they exist on the incident or alert type. Check for typos like incident.severiy instead of incident.severity.

Null pointer errors in trigger execution

Add null checks before accessing fields: incident.owner != null && incident.owner.contains( "@example.com"). Custom fields and optional fields may be null or missing.

Regex pattern not matching expected incidents

Escape special characters with backslashes. Use ^ for start and $ for end. Test your regex pattern separately. Example: incident.service.matches("^payment-api\\.") with escaped dot.


Next steps

Last updated

Was this helpful?