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

Use CEL Expressions in Webhooks

Filter and conditionally map webhook payloads with CEL expressions.

Use CEL expressions in webhook advanced mapping conditions to filter incoming webhooks and route them based on payload content.

Advanced CEL field mapping with regex.extract(), orValue(), and trim() in webhook configuration

FEATURE FLAG REQUIRED

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

When to use CEL webhook filters

Use CEL expressions in webhook mappings when you need:

  • Payload-based routing: Route webhooks to different incident types based on payload content

  • Priority filtering: Only create incidents for high-priority alerts

  • Service filtering: Filter by service name patterns or specific services

  • Region-based routing: Route webhooks based on geographic region

  • Complex conditions: Combine multiple criteria with boolean logic

  • Custom field matching: Filter on custom fields from your monitoring tools


Available webhook data

All fields from the webhook payload are accessible via the Webhook namespace:

Common webhook fields (varies by source):

Use the data picker in the webhook configuration UI to discover available fields from your webhook payload. The picker shows actual field names from sample payloads.


CEL webhook examples

Filter by priority:

Filter by environment:

Production high-priority webhooks only:

Service pattern matching:

Region filtering:

Multiple services or priorities:

Severity threshold with environment:

Metric threshold filtering:

Complex multi-condition filter:

Status-based filtering:

Tag-based filtering:

Null-safe custom field check:


Webhook payload examples with CEL

Datadog webhook filters

PagerDuty webhook filters

Prometheus AlertManager filters

New Relic webhook filters

CloudWatch webhook filters


Best practices for webhook CEL filters

1. Start with simple filters and iterate:

2. Use explicit field checks for optional fields:

3. Test filters with sample webhooks:

  • Send test webhooks through your integration

  • Verify they are filtered correctly

  • Check webhook processing logs

  • Refine conditions based on results

4. Use in for multiple values:

5. Document complex filters:

6. Use regex anchors for exact matches:


Field mapping with CEL

You can also use CEL expressions to transform webhook field values during mapping:

Extract from nested JSON:

Conditional field mapping:

Format timestamps:

Combine multiple fields:

Extract with regex patterns:

Provide default values:

Clean up extracted values:

Advanced field mapping example:


Advanced CEL functions

regex.extract()

Extract values from JSON strings or text using regular expressions.

Syntax:

Examples:

.orValue()

Provide a default value when a field is null or empty.

Syntax:

Examples:

.trim()

Remove leading and trailing whitespace from strings.

Syntax:

Examples:

regex.replace()

Replace text matching a pattern with a replacement string.

Syntax:

Examples:


Troubleshooting CEL webhook filters

Webhook not creating incidents despite matching filter

Check webhook processing logs for errors. Verify the webhook payload contains the fields you are referencing. Use the data picker to confirm field names match exactly (case-sensitive). Test with a simple condition first like Webhook.priority == "P1".

Field not found errors in webhook CEL filter

Verify the field exists in the webhook payload. Use Webhook. prefix (capital W). Field names are case-sensitive. For nested fields use dot notation: Webhook.nested.field. Check the webhook logs to see the actual payload structure.

Webhook filter not evaluating regex matches correctly

Test your regex pattern separately. Escape special characters with backslashes. Use ^ for start and $ for end to avoid partial matches. Example: Webhook.service.matches("^payment-.*$ ") for exact start match.

Null pointer errors when webhook filter executes

Add null checks for optional fields: Webhook.custom_field != null && Webhook.custom_field == "value". Not all webhook payloads contain every field. Check your monitoring tool documentation for which fields are always present.

Webhook creates incidents for all payloads ignoring CEL filter

Verify CEL mode is enabled for the webhook condition. Check that the condition returns a boolean (true/false), not a string. The expression Webhook.priority returns a value; use Webhook.priority == "P1" to return boolean.


Next steps

Need Help? Contact our support team by email at support@harness.io or visit the Harness Documentation for additional resources and troubleshooting guides.

Last updated

Was this helpful?