Do not send AFD to Nagios when activate_alerting=false
blueprint: alarming-refactoring Change-Id: Ifb82ec16dcece731528c1ec7d84c96d83d452212
This commit is contained in:
parent
7deace8726
commit
692cb46fbe
|
@ -47,12 +47,25 @@ class { 'fuel_lma_collector::afds':
|
|||
# Forward AFD status to Nagios if deployed
|
||||
if hiera('lma::collector::infrastructure_alerting::server', false) {
|
||||
lma_collector::afd_nagios { 'nodes':
|
||||
ensure => present,
|
||||
hostname => $::hostname,
|
||||
server => hiera('lma::collector::infrastructure_alerting::server'),
|
||||
http_port => hiera('lma::collector::infrastructure_alerting::http_port'),
|
||||
http_path => hiera('lma::collector::infrastructure_alerting::http_path'),
|
||||
user => hiera('lma::collector::infrastructure_alerting::user'),
|
||||
password => hiera('lma::collector::infrastructure_alerting::password'),
|
||||
ensure => present,
|
||||
hostname => $::hostname,
|
||||
server => hiera('lma::collector::infrastructure_alerting::server'),
|
||||
http_port => hiera('lma::collector::infrastructure_alerting::http_port'),
|
||||
http_path => hiera('lma::collector::infrastructure_alerting::http_path'),
|
||||
user => hiera('lma::collector::infrastructure_alerting::user'),
|
||||
password => hiera('lma::collector::infrastructure_alerting::password'),
|
||||
service_template => '%{node_role}.%{source}',
|
||||
message_type => 'afd_node_metric',
|
||||
}
|
||||
lma_collector::afd_nagios { 'services':
|
||||
ensure => present,
|
||||
hostname => $::hostname,
|
||||
server => hiera('lma::collector::infrastructure_alerting::server'),
|
||||
http_port => hiera('lma::collector::infrastructure_alerting::http_port'),
|
||||
http_path => hiera('lma::collector::infrastructure_alerting::http_path'),
|
||||
user => hiera('lma::collector::infrastructure_alerting::user'),
|
||||
password => hiera('lma::collector::infrastructure_alerting::password'),
|
||||
service_template => '%{service}.%{source}',
|
||||
message_type => 'afd_service_metric',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ end
|
|||
|
||||
-- inject an AFD event into the Heka pipeline
|
||||
function inject_afd_metric(msg_type, msg_tag_name, msg_tag_value, metric_name,
|
||||
value, hostname, interval, source)
|
||||
value, hostname, interval, source, to_alerting)
|
||||
local payload
|
||||
|
||||
if #alarms > 0 then
|
||||
|
@ -144,6 +144,11 @@ function inject_afd_metric(msg_type, msg_tag_name, msg_tag_value, metric_name,
|
|||
payload = '{"alarms":[]}'
|
||||
end
|
||||
|
||||
local no_alerting
|
||||
if to_alerting ~= nil and to_alerting == false then
|
||||
no_alerting = true
|
||||
end
|
||||
|
||||
local msg = {
|
||||
Type = msg_type,
|
||||
Payload = payload,
|
||||
|
@ -154,6 +159,7 @@ function inject_afd_metric(msg_type, msg_tag_name, msg_tag_value, metric_name,
|
|||
interval=interval,
|
||||
source=source,
|
||||
tag_fields={msg_tag_name, 'source'},
|
||||
no_alerting = no_alerting,
|
||||
}
|
||||
}
|
||||
msg.Fields[msg_tag_name] = msg_tag_value,
|
||||
|
|
|
@ -19,6 +19,7 @@ local afd = require 'afd'
|
|||
|
||||
-- node or service
|
||||
local afd_type = read_config('afd_type') or error('afd_type must be specified!')
|
||||
local activate_alerting = read_config('activate_alerting') or true
|
||||
local msg_type
|
||||
local msg_field_name
|
||||
local afd_entity
|
||||
|
@ -90,7 +91,7 @@ function timer_event(ns)
|
|||
end
|
||||
|
||||
afd.inject_afd_metric(msg_type, afd_entity, afd_entity_value, msg_field_name,
|
||||
state, hostname, interval, msg_field_source)
|
||||
state, hostname, interval, msg_field_source, activate_alerting)
|
||||
end
|
||||
else
|
||||
A.set_start_time(ns)
|
||||
|
|
|
@ -42,11 +42,15 @@ define lma_collector::afd_nagios(
|
|||
notify => Class['lma_collector::service::metric'],
|
||||
}
|
||||
|
||||
$matcher = join(["Fields[${lma_collector::params::aggregator_flag}] == NIL",
|
||||
"Type == 'heka.sandbox.${message_type}'",
|
||||
'Fields[no_alerting] == NIL'], ' && ')
|
||||
|
||||
heka::output::http { "nagios_afd_${title}":
|
||||
ensure => $ensure,
|
||||
config_dir => $lma_collector::params::metric_config_dir,
|
||||
url => $url,
|
||||
message_matcher => "Fields[${lma_collector::params::aggregator_flag}] == NIL && Type == 'heka.sandbox.${message_type}'",
|
||||
message_matcher => $matcher,
|
||||
username => $user,
|
||||
password => $password,
|
||||
encoder => "nagios_afd_${title}",
|
||||
|
|
Loading…
Reference in New Issue