From 4934d5eedc3d8f1d48ebd626cab9108616a846de Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Mon, 14 Apr 2025 14:45:54 +0530 Subject: [PATCH] chore: update example for notifications match query --- .../docs/guide/notifications/index.mdx | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/mission-control/docs/guide/notifications/index.mdx b/mission-control/docs/guide/notifications/index.mdx index 7bc4652e..b80dd414 100644 --- a/mission-control/docs/guide/notifications/index.mdx +++ b/mission-control/docs/guide/notifications/index.mdx @@ -15,6 +15,15 @@ Mission Control provides a flexible, event-based notification system that enable Notifications are triggered by events. An event is a specific occurrence or change in state within the system. For example, notifications can be granular such as a health check failing or a pod crashlooping - or high level based on the health of the system as a whole. +The following example sends an email when a pod or deployment in the `prod` cluster becomes unhealthy or enters a warning state, excluding config items named `postgres`. + +```yaml title="config-health-match-query.yaml" file=/modules/mission-control/fixtures/notifications/config-health-match-query.yaml {9} +``` + +The `events` field selects unhealthy and warning events. The [`matchQuery`](/docs/reference/scripting/cel#matchquery) filter narrows those events by config item type, name, and cluster tag. + +
+ ```yaml title="check-failed.yaml" apiVersion: mission-control.flanksource.com/v1 kind: Notification @@ -30,6 +39,9 @@ spec: This notification sends an email to `alerts@acme.com` whenever a health check fails. +
+ + @@ -62,6 +74,17 @@ Mission Control allows you to fine-tune your notification delivery by filtering The CEL filters you define have access to the same set of variables as the templates, providing flexibility in defining your filtering criteria. These variables, representing various attributes and properties of the events, empower you to create highly targeted notifications. +You can use the [`matchQuery`](/docs/reference/scripting/cel#matchquery) CEL function to match config items against a search query. +Example: + +```yaml title="config.yaml" file=/modules/mission-control/fixtures/notifications/config-health-match-query.yaml {9} +``` + +In this example, the filter matches all unhealthy or warning deployments and pods in the prod cluster except for the postgres deployment. + + +
+ To illustrate, consider a scenario where you want to receive notifications exclusively for failed HTTP checks. The following example demonstrates how to achieve this using a CEL filter: ```yaml title="filter-http.yaml" @@ -85,15 +108,11 @@ In this example: - This expression evaluates to true only when the `type` attribute of the [check](/docs/reference/canary-checker/check) object is equal to `'http'`. - So, Mission Control only sends notifications for events that meet this condition, which alerts you when HTTP checks fail. -
-For a more sophisticated filter, you can also use the handy [`matchQuery`](/docs/reference/scripting/cel#matchquery) cel function that supports search query. -Example: +You can also use `matchQuery` to filter failed checks by type and labels. This example excludes HTTP checks and checks with the label `Expected-Fail: true`. -```yaml title="config.yaml" file=/modules/mission-control/fixtures/notifications/config-health-match-query.yaml {9} +```yaml title="check-label-match-query.yaml" file=/modules/mission-control/fixtures/notifications/check-label-match-query.yaml {8} ``` -In this example, the filter matches all unhealthy or warning deployments and pods in the prod cluster except for the postgres deployment. -