Tickets Documents Updates Đăng nhập

[Datadog] I want to trigger alerts to different channels based on conditions when configuring a Monitor.

When configuring a monitor, you can apply different messages and alert propagation channels for each condition by using conditional variables in the “Notify your team” section.

Conditional Variables

These allow certain text to be displayed based on specified conditions. 

{{#is_alert}}

The triggered alarm is an ALERT.

{{^is_alert}}

The triggered alarm is NOT an ALERT.

{{#is_match}}

Matches the provided substring in the context.

{{^is_match}}

Does NOT match the provided substring in the context.

{{#is_exact_match}}

Exactly matches the provided string in the context.

{{^is_exact_match}}

Does NOT exactly match the provided string in the context.

{{#is_no_data}}

The triggered alarm is NO DATA.

{{^is_no_data}}

The triggered alarm is NOT NO DATA.

{{#is_warning}}

The triggered alarm is WARNING.

{{^is_warning}}

The triggered alarm is NOT WARNING.

{{#is_recovery}}

The triggered alarm is a recovery from ALERT, WARNING, or NO DATA.

{{^is_recovery}}

The triggered alarm is NOT a recovery from ALERT, WARNING, or NO DATA.

{{#is_warning_recovery}}

The triggered alarm is a WARNING recovery.

{{^is_warning_recovery}}

The triggered alarm is NOT a WARNING recovery.

{{#is_alert_recovery}}

The triggered alarm is an ALERT recovery.

{{^is_alert_recovery}}

The triggered alarm is NOT an ALERT recovery.

{{#is_alert_to_warning}}

The triggered alarm is a transition from ALERT to WARNING.

{{^is_alert_to_warning}}

The triggered alarm is NOT a transition from ALERT to WARNING.

{{#is_no_data_recovery}}

The triggered alarm is a NO DATA recovery.

{{^is_no_data_recovery}}

The triggered alarm is NOT a NO DATA recovery.

{{#is_priority 'value'}}

The priority set for the monitor is value. (P1 to P5)

{{#is_unknown}}

The monitor is in an unknown state.

{{^is_unknown}}

The monitor is NOT in an unknown state.

{{#is_renotify}}

The monitor is renotifying.

{{^is_renotify}}

The monitor is NOT renotifying.


If you want to configure different propagation channels and messages based on a specific tag value,
it is recommended to create a new monitor or clone an existing one for each propagation channel, and create monitors per system individually.

Using multiple propagation channels in a single monitor may lead to different owners or management channels overseeing one monitor,
which requires alignment on common conditions such as thresholds.
Also, incorrect changes could affect multiple channels simultaneously.
For this reason, the method below should be used minimally and only when management is not an issue.

To apply conditions in the “Notify your team” message field,
you can use the following conditional variables from the list shown above:

  • {{#is_match "variable" "value1" "value2" }}{{/is_match}}

: Applies when the value of a specific variable contains the defined values. 

  • {{^is_match "variable" "value1" "value2" }}{{/is_match}}  

: Applies when the value of a specific variable does not contain the defined values. 

  • {{#is_exact_match "variable" "value1" "value2" }}{{/is_exact_match}} 

: Applies when the value of a specific variable exactly matches the defined values. 

  • {{^is_exact_match "variable" "value1" "value2" }} {{/is_exact_match}}  

: Applies when the value of a specific variable does not exactly match the defined values. 


You can define multiple strings for a single variable (applied as an OR condition).
Example: {{#is_match "host.env" "dev" "stg" }} This applies when the value of host.env is either dev or stg, and you can define messages or channels accordingly.  {{/is_match}} You can use conditional variables just like if/else statements in programming.
(Both of the following patterns are valid.)

{{#is_match  "host.env" "prod"}}
    @channel_prod
{{else}}
    @channel_dev
{{/is_match}}
{{#is_match  "host.service" "zmon" "slack"}}
    @채널_zmon
{{else}}
    {{#is_match  "host.service" "datadog"}}
        @channel_datadog
    {{else}}
        @channel_etc
    {{/is_match}}
{{/is_match}}

Câu trả lời này có giúp ích cho bạn không? Yes No

Send feedback
Rất tiếc là chúng tôi không giúp được nhiều. Hãy giúp chúng tôi cải thiện bài viết này bằng phản hồi của bạn.