From 681430445595c048b85ca776215b2fa6f713fade Mon Sep 17 00:00:00 2001 From: Hillary Fraley <19190208+hillaryfraley@users.noreply.github.com> Date: Mon, 9 May 2022 09:47:29 -0400 Subject: [PATCH 1/3] Explain annotation override --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 28139485..043c0bc4 100644 --- a/README.md +++ b/README.md @@ -90,17 +90,27 @@ as for `description-template` as a check annotation requires that you place the desired template as a [golang string literal][11] (enlcosed in backticks) within another template definition. This does not apply to entity annotations. +set a backend `SLACK_CHANNEL` environment variable to the `#monitoring-alerts` channel. + +Runtime env_vars defined for a slack handler's definition in backend lose to event's entity annotations if latter are present. + #### Examples -To customize the channel for a given entity, you could use the following -sensu-agent configuration snippet: +If you use entity or check annotations to set arguments for the Sensu Slack Handler, the values in the annotations will override any values you set in the handler command or backend runtime environment variables. + +For example, imagine you configure the a Slack handler whose command sets the `--channel` flag to `#monitoring`. +Suppose that for one particular entity, you want to use the Slack handler, but you want the entity's incidents to go to the `#special-alerts` Slack channel. +You update the entity to include the following annotation: ```yml # /etc/sensu/agent.yml example annotations: - sensu.io/plugins/slack/config/channel: '#monitoring' + sensu.io/plugins/slack/config/channel: '#special-alerts' ``` +For this one entity, the Slack handler will send alerts to the `#special-alerts` channel (the entity annotation overrides the handler command flag). +For all other entites, the Slack handler will send alerts to the `#monitoring` channel as configured in the handler command flag. + ## Configuration ### Asset registration From 0c62c90751a0eb3a86bb9572fe827224407644b1 Mon Sep 17 00:00:00 2001 From: Hillary Fraley <19190208+hillaryfraley@users.noreply.github.com> Date: Mon, 9 May 2022 09:55:05 -0400 Subject: [PATCH 2/3] Adjust explanation a bit --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 043c0bc4..d6992d15 100644 --- a/README.md +++ b/README.md @@ -90,15 +90,11 @@ as for `description-template` as a check annotation requires that you place the desired template as a [golang string literal][11] (enlcosed in backticks) within another template definition. This does not apply to entity annotations. -set a backend `SLACK_CHANNEL` environment variable to the `#monitoring-alerts` channel. - -Runtime env_vars defined for a slack handler's definition in backend lose to event's entity annotations if latter are present. +Per-entity and per-check arguments set in entity and check annotations will override any arguments set in the handler command with flags or in backend runtime environment variables. #### Examples -If you use entity or check annotations to set arguments for the Sensu Slack Handler, the values in the annotations will override any values you set in the handler command or backend runtime environment variables. - -For example, imagine you configure the a Slack handler whose command sets the `--channel` flag to `#monitoring`. +Imagine you configure the a Slack handler whose command sets the `--channel` flag to `#monitoring`. Suppose that for one particular entity, you want to use the Slack handler, but you want the entity's incidents to go to the `#special-alerts` Slack channel. You update the entity to include the following annotation: From 08531edb5c89a1f25afd2c1948165f18653882d4 Mon Sep 17 00:00:00 2001 From: Hillary Fraley <19190208+hillaryfraley@users.noreply.github.com> Date: Mon, 9 May 2022 09:56:43 -0400 Subject: [PATCH 3/3] One more correction --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d6992d15..d87d0880 100644 --- a/README.md +++ b/README.md @@ -94,9 +94,10 @@ Per-entity and per-check arguments set in entity and check annotations will over #### Examples -Imagine you configure the a Slack handler whose command sets the `--channel` flag to `#monitoring`. -Suppose that for one particular entity, you want to use the Slack handler, but you want the entity's incidents to go to the `#special-alerts` Slack channel. -You update the entity to include the following annotation: +Suppose that you configure the a Slack handler whose command sets the `--channel` flag to `#monitoring`. +For one particular entity, you want to use the Slack handler, but you want the entity's incidents to go to the `#special-alerts` Slack channel. + +Update the entity definition to include an annotation that specifies the `#special-alerts` channel: ```yml # /etc/sensu/agent.yml example