Skip to content

Commit

Permalink
Merge pull request #17 from dunkelbraun/health-status-label-selector-…
Browse files Browse the repository at this point in the history
…type

Add health status metrics for label selector types
  • Loading branch information
wacken89 authored Aug 19, 2023
2 parents 2681ef0 + 8f17808 commit 6f9e410
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion code/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,15 @@ def get_metrics(metrics_type, lbid):
hetzner_load_balancer_name=lb_name).set(get_metrics('bandwidth',load_balancer_id)["metrics"]["time_series"]["bandwidth.out"]["values"][0][1])

lb_info = get_load_balancer_info(load_balancer_id)['load_balancer']
for target in [x for x in lb_info['targets'] if x['type'] == 'server']:

targets = []
for x in lb_info['targets']:
if x['type'] == 'server':
targets.append(x)
elif x['type'] == 'label_selector':
targets.extend(x['targets'])

for target in targets:
for health_status in target['health_status']:
hetzner_service_state.labels(hetzner_load_balancer_id=load_balancer_id,
hetzner_load_balancer_name=lb_name,
Expand Down

0 comments on commit 6f9e410

Please sign in to comment.