Do not send GSE to Nagios when activate_alerting=false

DocImpact
blueprint: alarming-refactoring

Change-Id: Ie343672afd4a222a3d7f920182a0b2e90e1fd6de
This commit is contained in:
Swann Croiset 2016-09-13 10:00:31 +02:00
parent 692cb46fbe
commit cc5aadb474
6 changed files with 25 additions and 3 deletions

View File

@ -115,6 +115,8 @@ lma_collector:
output_metric_name: cluster_service_status output_metric_name: cluster_service_status
interval: 10 interval: 10
warm_up_period: 20 warm_up_period: 20
enable_notification: false
activate_alerting: true
clusters: clusters:
nova-logs: nova-logs:
policy: highest_severity policy: highest_severity
@ -440,6 +442,8 @@ lma_collector:
output_metric_name: cluster_node_status output_metric_name: cluster_node_status
interval: 10 interval: 10
warm_up_period: 80 warm_up_period: 80
enable_notification: false
activate_alerting: true
clusters: clusters:
controller: controller:
policy: majority_of_members policy: majority_of_members
@ -536,6 +540,8 @@ lma_collector:
output_metric_name: cluster_status output_metric_name: cluster_status
interval: 10 interval: 10
warm_up_period: 30 warm_up_period: 30
enable_notification: true
activate_alerting: true
clusters: clusters:
mysql: mysql:
policy: highest_severity policy: highest_severity

View File

@ -1097,6 +1097,10 @@ in Heka.
* `warm_up_period`: *Optional*. Number of seconds after a (re)start that the * `warm_up_period`: *Optional*. Number of seconds after a (re)start that the
GSE plugin will wait before emitting its metric messages. Valid options: an GSE plugin will wait before emitting its metric messages. Valid options: an
integer. Default: undef. integer. Default: undef.
* `enable_notification`: *Optional*. Whether or not enable notifications in the
alerting system. Valid options: a boolean. Default: true.
* `activate_alerting`: *Optional*. Whether or not configure alerting system
for all clusters. Valid options: a boolean. Default: true.
#### Define `lma_collector::gse_nagios` #### Define `lma_collector::gse_nagios`

View File

@ -125,7 +125,7 @@ end
-- compute the cluster metric and inject it into the Heka pipeline -- compute the cluster metric and inject it into the Heka pipeline
-- the metric's value is computed using the status of its members -- the metric's value is computed using the status of its members
function inject_cluster_metric(msg_type, cluster_name, metric_name, interval, source) function inject_cluster_metric(msg_type, cluster_name, metric_name, interval, source, to_alerting)
local payload local payload
local status, alarms = resolve_status(cluster_name) local status, alarms = resolve_status(cluster_name)
@ -139,6 +139,11 @@ function inject_cluster_metric(msg_type, cluster_name, metric_name, interval, so
payload = '{"alarms":[]}' payload = '{"alarms":[]}'
end end
local no_alerting
if to_alerting ~= nil and to_alerting == false then
no_alerting = true
end
local msg = { local msg = {
Type = msg_type, Type = msg_type,
Payload = payload, Payload = payload,
@ -149,6 +154,7 @@ function inject_cluster_metric(msg_type, cluster_name, metric_name, interval, so
tag_fields={'cluster_name'}, tag_fields={'cluster_name'},
interval=interval, interval=interval,
source=source, source=source,
no_alerting=no_alerting,
} }
} }
lma.inject_tags(msg) lma.inject_tags(msg)

View File

@ -29,6 +29,7 @@ local interval = (read_config('interval') or error('interval must be specified!'
local interval_in_ns = interval * 1e9 local interval_in_ns = interval * 1e9
local max_inject = (read_config('max_inject') or 10) + 0 local max_inject = (read_config('max_inject') or 10) + 0
local warm_up_period = ((read_config('warm_up_period') or 0) + 0) * 1e9 local warm_up_period = ((read_config('warm_up_period') or 0) + 0) * 1e9
local activate_alerting = read_config('activate_alerting') or true
local is_active = false local is_active = false
local first_tick local first_tick
@ -122,7 +123,8 @@ function timer_event(ns)
cluster_name, cluster_name,
output_metric_name, output_metric_name,
interval, interval,
source source,
activate_alerting
) )
last_index = i last_index = i
injected = injected + 1 injected = injected + 1

View File

@ -21,6 +21,8 @@ define lma_collector::gse_cluster_filter (
$cluster_field = undef, $cluster_field = undef,
$clusters = {}, $clusters = {},
$warm_up_period = undef, $warm_up_period = undef,
$enable_notification = true,
$activate_alerting = true,
$ensure = present, $ensure = present,
) { ) {
include lma_collector::params include lma_collector::params
@ -66,6 +68,8 @@ define lma_collector::gse_cluster_filter (
member_field => $member_field, member_field => $member_field,
max_inject => $lma_collector::params::hekad_max_timer_inject, max_inject => $lma_collector::params::hekad_max_timer_inject,
warm_up_period => $warm_up_period, warm_up_period => $warm_up_period,
enable_notification => $enable_notification,
activate_alerting => $activate_alerting,
}, },
module_directory => $lua_modules_dir, module_directory => $lua_modules_dir,
require => File[$topology_file], require => File[$topology_file],

View File

@ -50,7 +50,7 @@ define lma_collector::gse_nagios (
ensure => $ensure, ensure => $ensure,
config_dir => $lma_collector::params::metric_config_dir, config_dir => $lma_collector::params::metric_config_dir,
url => $url, url => $url,
message_matcher => "Type == 'heka.sandbox.${message_type}'", message_matcher => "Type == 'heka.sandbox.${message_type}' && Fields[no_alerting] == NIL",
username => $user, username => $user,
password => $password, password => $password,
encoder => "nagios_gse_${title}", encoder => "nagios_gse_${title}",