Skip to content

Commit

Permalink
Merge pull request #61 from braedon/60-extra-status-metrics
Browse files Browse the repository at this point in the history
Add new metrics for the three cluster/index/shard status colours
  • Loading branch information
braedon authored Mar 26, 2020
2 parents 7f7f98d + 6082619 commit 6fd1161
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions prometheus_es_exporter/cluster_health_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def parse_block(block, metric=None, labels=None):
elif status == 'red':
status_int = 2
metrics.append((metric + ['status'], '', labels, status_int))
for colour in ['green', 'yellow', 'red']:
metrics.append((metric + ['status', colour], '', labels,
1 if status == colour else 0))

for key, value in block.items():
if isinstance(value, bool):
Expand Down
21 changes: 21 additions & 0 deletions tests/test_cluster_health_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def test_endpoint(self):

expected = {
'status': 1,
'status_green': 0,
'status_yellow': 1,
'status_red': 0,
'number_of_nodes': 1,
'number_of_data_nodes': 1,
'active_primary_shards': 5,
Expand All @@ -101,6 +104,9 @@ def test_endpoint(self):
'task_max_waiting_in_queue_millis': 0,
'active_shards_percent_as_number': 50.0,
'indices_status{index="foo"}': 1,
'indices_status_green{index="foo"}': 0,
'indices_status_yellow{index="foo"}': 1,
'indices_status_red{index="foo"}': 0,
'indices_number_of_shards{index="foo"}': 5,
'indices_number_of_replicas{index="foo"}': 1,
'indices_active_primary_shards{index="foo"}': 5,
Expand All @@ -109,30 +115,45 @@ def test_endpoint(self):
'indices_initializing_shards{index="foo"}': 0,
'indices_unassigned_shards{index="foo"}': 5,
'indices_shards_status{index="foo",shard="0"}': 1,
'indices_shards_status_green{index="foo",shard="0"}': 0,
'indices_shards_status_yellow{index="foo",shard="0"}': 1,
'indices_shards_status_red{index="foo",shard="0"}': 0,
'indices_shards_primary_active{index="foo",shard="0"}': 1,
'indices_shards_active_shards{index="foo",shard="0"}': 1,
'indices_shards_relocating_shards{index="foo",shard="0"}': 0,
'indices_shards_initializing_shards{index="foo",shard="0"}': 0,
'indices_shards_unassigned_shards{index="foo",shard="0"}': 1,
'indices_shards_status{index="foo",shard="1"}': 1,
'indices_shards_status_green{index="foo",shard="1"}': 0,
'indices_shards_status_yellow{index="foo",shard="1"}': 1,
'indices_shards_status_red{index="foo",shard="1"}': 0,
'indices_shards_primary_active{index="foo",shard="1"}': 1,
'indices_shards_active_shards{index="foo",shard="1"}': 1,
'indices_shards_relocating_shards{index="foo",shard="1"}': 0,
'indices_shards_initializing_shards{index="foo",shard="1"}': 0,
'indices_shards_unassigned_shards{index="foo",shard="1"}': 1,
'indices_shards_status{index="foo",shard="2"}': 1,
'indices_shards_status_green{index="foo",shard="2"}': 0,
'indices_shards_status_yellow{index="foo",shard="2"}': 1,
'indices_shards_status_red{index="foo",shard="2"}': 0,
'indices_shards_primary_active{index="foo",shard="2"}': 1,
'indices_shards_active_shards{index="foo",shard="2"}': 1,
'indices_shards_relocating_shards{index="foo",shard="2"}': 0,
'indices_shards_initializing_shards{index="foo",shard="2"}': 0,
'indices_shards_unassigned_shards{index="foo",shard="2"}': 1,
'indices_shards_status{index="foo",shard="3"}': 1,
'indices_shards_status_green{index="foo",shard="3"}': 0,
'indices_shards_status_yellow{index="foo",shard="3"}': 1,
'indices_shards_status_red{index="foo",shard="3"}': 0,
'indices_shards_primary_active{index="foo",shard="3"}': 1,
'indices_shards_active_shards{index="foo",shard="3"}': 1,
'indices_shards_relocating_shards{index="foo",shard="3"}': 0,
'indices_shards_initializing_shards{index="foo",shard="3"}': 0,
'indices_shards_unassigned_shards{index="foo",shard="3"}': 1,
'indices_shards_status{index="foo",shard="4"}': 1,
'indices_shards_status_green{index="foo",shard="4"}': 0,
'indices_shards_status_yellow{index="foo",shard="4"}': 1,
'indices_shards_status_red{index="foo",shard="4"}': 0,
'indices_shards_primary_active{index="foo",shard="4"}': 1,
'indices_shards_active_shards{index="foo",shard="4"}': 1,
'indices_shards_relocating_shards{index="foo",shard="4"}': 0,
Expand Down

0 comments on commit 6fd1161

Please sign in to comment.