From d58c41f634eec907704c1a90382c33167f445645 Mon Sep 17 00:00:00 2001 From: nagyt234 Date: Tue, 28 Jun 2022 18:04:46 +0200 Subject: [PATCH] Slack alert example completed with filters Slack alert example completed with filters to work as a real example and to avoid to sending events continuously to Slack. --- examples/slack_alerts.pp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/slack_alerts.pp b/examples/slack_alerts.pp index dba59f3550..eea6fc4479 100644 --- a/examples/slack_alerts.pp +++ b/examples/slack_alerts.pp @@ -10,11 +10,24 @@ version => 'latest', } +sensu_filter { 'state_change_only in default': + ensure => 'present', + action => 'allow', + expressions => [ + 'event.check.occurrences == 1', + ], +} + sensu_handler { 'slack': type => 'pipe', env_vars => ["SLACK_WEBHOOK_URL=${webhook_url}"], command => "sensu-slack-handler --channel '${channel}'", runtime_assets => ['sensu/sensu-slack-handler'], + filters => [ + 'is_incident', + 'not_silenced', + 'state_change_only', + ], } sensu_check { 'check_cpu':