Support for Ceph metrics with InfluxDB 0.9

This change updates the collectd plugins and decoder to support Ceph
metrics with InfluxDB 0.9.

It modifies the Base collectd plugin class used by the Ceph and RabbitMQ
plugins to leverage custom types instead of 'gauge' only. This allows to
have a cleaner definition for the collectd metrics and avoids encoding
too many information into the 'type_instance' field.

This patch also fixes a couple of bugs/inconsistencies in the Ceph
plugins inherited from the original plugins.

Change-Id: Ib070654ecb7128b647d6b9120d9d7dcc37a801bc
Implements: blueprint upgrade-influxdb-grafana
This commit is contained in:
Simon Pasquier
2015-08-20 08:18:53 +02:00
parent de882d154d
commit 790f346b2f
13 changed files with 434 additions and 146 deletions

View File

@@ -22,24 +22,30 @@ INTERVAL = 60
class CephOSDStatsPlugin(base.CephBase):
""" Collect per OSD stats about store size and commit latency."""
def get_metrics(self):
pgs = self.execute_to_json('ceph pg dump --format json')
if not pgs:
return {}
def __init__(self, *args, **kwargs):
super(CephOSDStatsPlugin, self).__init__(*args, **kwargs)
self.plugin = 'ceph_osd'
metrics = {}
for osd in pgs['osd_stats']:
metric = "osd.%s" % osd['osd']
used = "%s.used" % metric
metrics[used] = osd['kb_used'] * 1000
total = "%s.total" % metric
metrics[total] = osd['kb'] * 1000
apply_latency = "%s.apply_latency" % metric
metrics[apply_latency] = osd['fs_perf_stat']['apply_latency_ms']
commit_latency = "%s.commit_latency" % metric
metrics[commit_latency] = osd['fs_perf_stat']['commit_latency_ms']
def itermetrics(self):
osd_stats = self.execute_to_json('ceph pg dump osds --format json')
if not osd_stats:
return
return metrics
for osd in osd_stats:
osd_id = osd['osd']
yield {
'type_instance': osd_id,
'type': 'osd_space',
'values': [osd['kb_used'] * 1000, osd['kb'] * 1000],
}
yield {
'type_instance': osd_id,
'type': 'osd_latency',
'values': [osd['fs_perf_stat']['apply_latency_ms'],
osd['fs_perf_stat']['commit_latency_ms']],
}
plugin = CephOSDStatsPlugin()