Change dimension 'service' to 'component' on HAProxy plugin

Following the pattern of other plugins, the 'service' dimension
is generally used to identify which service is providing the metrics,
and the 'component' dimension is used to identify specifically
wich component of the service is being monitored.

Example:
  monasca_agent:
    service=monitoring component=monasca-agent

This patch applies this same concept to the HAProxy plugin by
changing the service dimension value to 'service=haproxy' and
adding a 'component' dimension 'component=haproxy_[back|front]end_name'

TLDR:
The following dimension will be changed from:
  service='haproxy_[back|front]end_name'
to:
  service=haproxy component='haproxy_[back|front]end_name'

Change-Id: Ic5203a607d9d0bec06f5e4a542d68dda3a3b67ba
This commit is contained in:
Flávio Ramalho 2017-05-16 13:43:09 -03:00
parent 50ca49b7a0
commit f71394423f
1 changed files with 4 additions and 5 deletions

View File

@ -50,7 +50,7 @@ class HAProxy(AgentCheck):
}
def check(self, instance):
self.dimensions = self._set_dimensions(None, instance)
self.dimensions = self._set_dimensions({'service': 'haproxy'}, instance)
url = instance.get('url')
username = instance.get('username')
password = instance.get('password')
@ -156,7 +156,7 @@ class HAProxy(AgentCheck):
for (service, status), count in hosts_statuses.items():
status = status.lower()
status_dimensions.update({'status': status, 'service': service})
status_dimensions.update({'status': status, 'component': service})
self.gauge("haproxy.count_per_status", count, dimensions=status_dimensions)
if 'up' in status:
@ -166,7 +166,7 @@ class HAProxy(AgentCheck):
for service in agg_statuses:
for status, count in agg_statuses[service].items():
status_dimensions.update({'status': status, 'service': service})
status_dimensions.update({'status': status, 'component': service})
self.gauge("haproxy.count_per_status", count, dimensions=status_dimensions)
def _process_metrics(self, data_list, service, url):
@ -188,8 +188,7 @@ class HAProxy(AgentCheck):
metric_dimensions.update({'type': service,
'instance_url': url,
'service_name': service_name,
'service': 'haproxy'})
'component': service_name})
if service == Services.BACKEND:
metric_dimensions.update({'backend': hostname})