Replace the API backends AFD filter

This patch uses the generic AFD filter with new alarms to replace the
custom AFD for API backends.

Blueprint: allow-all-alarms-to-be-specified-in-alarming-file
Change-Id: Id139e45a9942a9c86a2d35d1966b083d9c75af89
This commit is contained in:
Guillaume Thouvenin 2016-09-08 14:35:29 +02:00 committed by Swann Croiset
parent c5942cde0e
commit 215f693307
4 changed files with 1040 additions and 97 deletions

View File

@ -261,7 +261,6 @@ if hiera('lma::collector::influxdb::server', false) {
class { 'lma_collector::logs::aggregated_http_metrics': }
# AFD filters
class { 'lma_collector::afd::api': }
class { 'lma_collector::afd::workers': }
}

View File

@ -449,7 +449,6 @@ Public Classes:
* [`lma_collector::notifications::metrics`](#class-lma_collectornotificationsmetrics)
* [`lma_collector::aggregator::client`](#class-lma_collectoraggregatorclient)
* [`lma_collector::aggregator::server`](#class-lma_collectoraggregatorserver)
* [`lma_collector::afd::api`](#class-lma_collectorafdapi)
* [`lma_collector::afd::workers`](#class-lma_collectorafdworkers)
* [`lma_collector::gse_policies`](#class-lma_collectorgse_policies)
* [`lma_collector::metrics::heka_monitoring`](#class-lma_collectormetricsheka_monitoring)
@ -871,11 +870,6 @@ Declare this class to make Heka run the aggregator service.
to check the health of the aggregator service. Valid options: an integer.
Default: `undef`.
#### Class: `lma_collector::afd::api`
Declare this class to configure the Heka filter that sends AFD metrics
reporting the availability of the OpenStack API endpoints.
#### Class: `lma_collector::afd::workers`
Declare this class to configure the Heka filter that sends AFD metrics

View File

@ -1,90 +0,0 @@
-- Copyright 2015 Mirantis, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
require 'string'
local afd = require 'afd'
local consts = require 'gse_constants'
local haproxy_backend_states = {}
-- emit AFD event metrics based on HAProxy backends
function process_message()
local metric_name = read_message('Fields[name]')
local value = read_message('Fields[value]')
local service = read_message('Fields[backend]')
local state = consts.OKAY
if not haproxy_backend_states[service] then
haproxy_backend_states[service] = {}
end
haproxy_backend_states[service][read_message('Fields[state]')] = value
if not (haproxy_backend_states[service].up and haproxy_backend_states[service].down) then
-- not enough data for now
return 0
end
if haproxy_backend_states[service].up == 0 then
state = consts.DOWN
afd.add_to_alarms(consts.DOWN,
'last',
metric_name,
{service=service,state='up'},
{},
'==',
haproxy_backend_states[service].up,
0,
nil,
nil,
string.format("All %s backends are down", service))
elseif haproxy_backend_states[service].down >= haproxy_backend_states[service].up then
state = consts.CRIT
afd.add_to_alarms(consts.CRIT,
'last',
metric_name,
{service=service,state='down'},
{},
'>=',
haproxy_backend_states[service].down,
haproxy_backend_states[service].up,
nil,
nil,
string.format("More backends for %s are down than up", service))
elseif haproxy_backend_states[service].down > 0 then
state = consts.WARN
afd.add_to_alarms(consts.WARN,
'last',
metric_name,
{service=service,state='down'},
{},
'>',
haproxy_backend_states[service].down,
0,
nil,
nil,
string.format("At least one %s backend is down", service))
end
afd.inject_afd_service_metric(service,
state,
read_message('Fields[hostname]'),
0,
'backends')
-- reset the cache for this service
haproxy_backend_states[service] = {}
return 0
end