Skip to content

Commit

Permalink
mgr/prometheus: fix pool_objects_repaired and daemon_health_metrics f…
Browse files Browse the repository at this point in the history
…ormat

mgr/prometheus: fix pool_objects_repaired and daemon_health_metrics format

- fix "error reading metrics for http://****:***/metrics: reading text format failed: text format parsing error in line 2010: second HELP line for metric name "ceph_pool_objects_repaired" error

- rename label name "poolid" to "pool_id" like all other metrics
- change type for the "daemon_health_metrics" to gauge

Fixes: https://tracker.ceph.com/issues/59505
Signed-off-by: banuchka <tyrchenok@gmail.com>
  • Loading branch information
banuchka committed Apr 27, 2023
1 parent 7dd2397 commit 95d5303
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/pybind/mgr/prometheus/module.py
Expand Up @@ -760,6 +760,20 @@ def _setup_static_metrics(self) -> Dict[str, Metric]:
HEALTHCHECK_DETAIL
)

metrics['pool_objects_repaired'] = Metric(
'counter',
'pool_objects_repaired',
'Number of objects repaired in a pool',
('pool_id',)
)

metrics['daemon_health_metrics'] = Metric(
'gauge',
'daemon_health_metrics',
'Health metrics for Ceph daemons',
('type', 'ceph_daemon',)
)

for flag in OSD_FLAGS:
path = 'osd_flag_{}'.format(flag)
metrics[path] = Metric(
Expand Down Expand Up @@ -1600,14 +1614,7 @@ def get_collect_time_metrics(self) -> None:
def get_pool_repaired_objects(self) -> None:
dump = self.get('pg_dump')
for stats in dump['pool_stats']:
path = f'pool_objects_repaired{stats["poolid"]}'
self.metrics[path] = Metric(
'counter',
'pool_objects_repaired',
'Number of objects repaired in a pool Count',
('poolid',)
)

path = 'pool_objects_repaired'
self.metrics[path].set(stats['stat_sum']['num_objects_repaired'],
labelvalues=(stats['poolid'],))

Expand All @@ -1616,13 +1623,7 @@ def get_all_daemon_health_metrics(self) -> None:
self.log.debug('metrics jeje %s' % (daemon_metrics))
for daemon_name, health_metrics in daemon_metrics.items():
for health_metric in health_metrics:
path = f'daemon_health_metrics{daemon_name}{health_metric["type"]}'
self.metrics[path] = Metric(
'counter',
'daemon_health_metrics',
'Health metrics for Ceph daemons',
('type', 'ceph_daemon',)
)
path = 'daemon_health_metrics'
self.metrics[path].set(health_metric['value'], labelvalues=(
health_metric['type'], daemon_name,))

Expand Down

0 comments on commit 95d5303

Please sign in to comment.