Support alarm evaluation with collected_on metric attribute
Change-Id: I61529d6ca2d8a9a26e5fa70a776ad03c212c7982
This commit is contained in:
parent
0c050cb8eb
commit
be4f8d36df
|
@ -41,6 +41,7 @@ class { 'fuel_lma_collector::afds':
|
|||
node_profiles => $lma['node_profiles'],
|
||||
node_cluster_alarms => $lma['node_cluster_alarms'],
|
||||
service_cluster_alarms => $lma['service_cluster_alarms'],
|
||||
metrics => $lma['metrics'],
|
||||
alarms => $alarms_definitions,
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
# ARG1: Array of alarm definitions
|
||||
# ARG2: Array of AFD profiles
|
||||
# ARG3: Type of AFD (either 'node' or 'service')
|
||||
# ARG4: Hash table mapping metric names to the place where there are collected.
|
||||
#
|
||||
# Ex:
|
||||
#
|
||||
|
@ -67,6 +68,8 @@
|
|||
#
|
||||
# ARG3: type (node|service)
|
||||
#
|
||||
# ARG4: {"openstack_nova_total_free_vcpus" => {"collected_on": "aggregator"}}
|
||||
#
|
||||
# Results -> {
|
||||
# 'rabbitmq_queue' => {
|
||||
# 'type' => 'service',
|
||||
|
@ -93,9 +96,32 @@ module Puppet::Parser::Functions
|
|||
alarm_definitions = args[1]
|
||||
afd_profiles = args[2]
|
||||
type = args[3]
|
||||
if not args[4]
|
||||
metric_defs = {}
|
||||
else
|
||||
metric_defs = args[4]
|
||||
end
|
||||
afd_filters = {}
|
||||
|
||||
afd_profiles.each do |afd_profile|
|
||||
# Override apply_to_node with collectd_on if present in metrics definitions.
|
||||
afd_alarms.each do |k ,v|
|
||||
v['alarms'].each do |afd_name, alarms|
|
||||
alarms.each do |a_name|
|
||||
a = alarm_definitions.select {|defi| defi['name'] == a_name}
|
||||
next if a.empty?
|
||||
a[0]['trigger']['rules'].each do |r|
|
||||
if metric_defs.has_key?(r['metric'])
|
||||
# TODO(all): This overrides the whole cluster while it is better
|
||||
# to treat per AFD. This implies that a cluster must be tied to
|
||||
# only one AFD.
|
||||
v['apply_to_node'] = metric_defs[r['metric']]['collected_on']
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
afds = afd_alarms.select {|k,v| v.has_key?('apply_to_node') and v['apply_to_node'] == afd_profile }
|
||||
afds.each do |k, v|
|
||||
activate_alerting=true
|
||||
|
|
|
@ -19,12 +19,14 @@ class fuel_lma_collector::afds (
|
|||
$node_cluster_alarms = undef,
|
||||
$service_cluster_alarms = undef,
|
||||
$alarms = undef,
|
||||
$metrics = {},
|
||||
){
|
||||
|
||||
validate_array($roles)
|
||||
validate_hash($node_profiles)
|
||||
validate_hash($node_cluster_alarms)
|
||||
validate_hash($service_cluster_alarms)
|
||||
validate_hash($metrics)
|
||||
validate_array($alarms)
|
||||
|
||||
$clusters_tmp = get_cluster_names($node_profiles, $roles)
|
||||
|
@ -37,12 +39,14 @@ class fuel_lma_collector::afds (
|
|||
$node_afd_filters = get_afd_filters($node_cluster_alarms,
|
||||
$alarms,
|
||||
$clusters,
|
||||
'node')
|
||||
'node',
|
||||
$metrics)
|
||||
|
||||
$service_afd_filters = get_afd_filters($service_cluster_alarms,
|
||||
$alarms,
|
||||
$clusters,
|
||||
'service')
|
||||
'service',
|
||||
$metrics)
|
||||
|
||||
create_resources(lma_collector::afd_filter, $node_afd_filters)
|
||||
create_resources(lma_collector::afd_filter, $service_afd_filters)
|
||||
|
|
|
@ -284,5 +284,91 @@ describe 'get_afd_filters' do
|
|||
)
|
||||
}
|
||||
end
|
||||
describe 'For services with apply_to_node overriden by metric collected_on' do
|
||||
alarms_services_o = [
|
||||
{"name"=>"free_vcpu_warning",
|
||||
"description"=>"",
|
||||
"severity"=>"warning",
|
||||
"trigger"=>
|
||||
{"logical_operator"=>"or",
|
||||
"rules"=>
|
||||
[{"metric"=>"free_vcpu",
|
||||
"relational_operator"=>"<=",
|
||||
"threshold"=>1,
|
||||
"window"=>60,
|
||||
"periods"=>0,
|
||||
"function"=>"min"},
|
||||
]}},
|
||||
{"name"=>"total_free_vcpu_warning",
|
||||
"description"=>"",
|
||||
"severity"=>"warning",
|
||||
"trigger"=>
|
||||
{"logical_operator"=>"or",
|
||||
"rules"=>
|
||||
[{"metric"=>"total_free_vcpu",
|
||||
"relational_operator"=>"<=",
|
||||
"threshold"=>10,
|
||||
"window"=>60,
|
||||
"periods"=>0,
|
||||
"function"=>"min"},
|
||||
]}},
|
||||
|
||||
]
|
||||
afds_services_overriden = {
|
||||
"nova-free-resources" => {
|
||||
"apply_to_node" => "compute",
|
||||
"enable_notification" => false,
|
||||
"activate_alerting" => true,
|
||||
"enable_notification" => false,
|
||||
"alarms" => {
|
||||
"free-vcpu" => ['free_vcpu_warning'],
|
||||
},
|
||||
},
|
||||
"nova-total-free-resources" => {
|
||||
"enable_notification" => false,
|
||||
"activate_alerting" => true,
|
||||
"enable_notification" => false,
|
||||
"alarms" => {
|
||||
"total-free-vcpu" => ['total_free_vcpu_warning'],
|
||||
},
|
||||
},
|
||||
}
|
||||
metrics = {
|
||||
"free_vcpu" => {
|
||||
"collected_on" => "controller"
|
||||
},
|
||||
"total_free_vcpu" => {
|
||||
"collected_on" => "controller"
|
||||
}
|
||||
}
|
||||
it { should run.with_params(afds_services_overriden, alarms_services_o, ['controller'], 'service', metrics)
|
||||
.and_return(
|
||||
{
|
||||
"nova-free-resources_free-vcpu"=>
|
||||
{
|
||||
"type"=>"service",
|
||||
"cluster_name"=>"nova-free-resources",
|
||||
"logical_name"=>"free-vcpu",
|
||||
"alarms_definitions"=> alarms_services_o,
|
||||
"alarms"=>["free_vcpu_warning"],
|
||||
"message_matcher"=>"Fields[name] == 'free_vcpu'",
|
||||
"activate_alerting" => true,
|
||||
"enable_notification" => false,
|
||||
},
|
||||
"nova-total-free-resources_total-free-vcpu"=>
|
||||
{
|
||||
"type"=>"service",
|
||||
"cluster_name"=>"nova-total-free-resources",
|
||||
"logical_name"=>"total-free-vcpu",
|
||||
"alarms_definitions"=> alarms_services_o,
|
||||
"alarms"=>["total_free_vcpu_warning"],
|
||||
"message_matcher"=>"Fields[name] == 'total_free_vcpu'",
|
||||
"activate_alerting" => true,
|
||||
"enable_notification" => false,
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue