Merge "Rabbitmq reporting too many metrics"

This commit is contained in:
Jenkins 2015-10-16 02:31:20 +00:00 committed by Gerrit Code Review
commit 9243da88de
2 changed files with 42 additions and 0 deletions

View File

@ -33,6 +33,11 @@ instances:
# for these nodes. For the other nodes, aggregate will be calculated.
#
# Warning: aggregate are calculated on the 100 first queues/nodes.
#
# The whitelist limits the collected metrics based on their path. The whitelist shown
# includes all the metrics collected by default if no list is specified. If any section
# is not specified, the defaults will be collected for that section (i.e. if the key 'node'
# is not present, the 'node' metrics shown in this example will be collected)
- rabbitmq_api_url: http://localhost:15672/api/
@ -44,3 +49,18 @@ instances:
queues:
- queue1
- queue2
whitelist:
queue:
- message_stats/deliver_details/rate
- message_stats/publish_details/rate
- message_stats/redeliver_details/rate
exchange:
- message_stats/publish_out
- message_stats/publish_out_details/rate
- message_stats/publish_in
- message_stats/publish_in_details/rate
node:
- fd_used
- mem_used
- run_queue
- sockets_used

View File

@ -62,6 +62,21 @@ ATTRIBUTES = {QUEUE_TYPE: QUEUE_ATTRIBUTES,
EXCHANGE_TYPE: EXCHANGE_ATTRIBUTES,
NODE_TYPE: NODE_ATTRIBUTES}
# whitelist of metrics to collect
DEFAULT_WHITELIST = {
QUEUE_TYPE: ['message_stats/deliver_details/rate',
'message_stats/publish_details/rate',
'message_stats/redeliver_details/rate'],
EXCHANGE_TYPE: ['message_stats/publish_out',
'message_stats/publish_out_details/rate',
'message_stats/publish_in',
'message_stats/publish_in_details/rate'],
NODE_TYPE: ['fd_used',
'mem_used',
'run_queue',
'sockets_used']
}
DIMENSIONS_MAP = {
'queues': {'name': 'queue',
'vhost': 'vhost',
@ -198,6 +213,9 @@ class RabbitMQ(checks.AgentCheck):
self._get_metrics(data_line, object_type, instance)
def _get_metrics(self, data, object_type, instance):
whitelist = instance.get('whitelist', {})
object_whitelist = whitelist.get(object_type, DEFAULT_WHITELIST[object_type])
dimensions_list = DIMENSIONS_MAP[object_type].copy()
dimensions = self._set_dimensions({'component': 'rabbitmq', 'service': 'rabbitmq'},
instance)
@ -207,6 +225,10 @@ class RabbitMQ(checks.AgentCheck):
dimensions[dimensions_list[d]] = dim
for attribute, metric_name in ATTRIBUTES[object_type]:
# Check if the metric should be collected
if attribute not in object_whitelist:
continue
# Walk down through the data path, e.g. foo/bar => d['foo']['bar']
root = data
keys = attribute.split('/')