Skip to content

Commit

Permalink
Fix station metrics (#555)
Browse files Browse the repository at this point in the history
* fix-station-metrics

* fix-mqtt-metrics
  • Loading branch information
maaikelimper authored Oct 18, 2023
1 parent fa888ca commit dc7cfc2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions wis2box-mqtt-metrics-collector/mqtt_metrics_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,22 @@ def sub_mqtt_metrics(client, userdata, msg):
if str(msg.topic).startswith('wis2box/stations'):
update_stations_gauge(m['station_list'])
elif str(msg.topic).startswith('wis2box/notifications'):
notify_wsi_total.labels(
m['properties']['wigos_station_identifier']).inc(1)
wsi = 'none'
if 'wigos_station_identifier' in m['properties']:
wsi = m['properties']['wigos_station_identifier']
notify_wsi_total.labels(wsi).inc(1)
failure_wsi_total.labels(wsi).inc(0)
station_wsi.labels(wsi).set(1)
notify_total.inc(1)
elif str(msg.topic).startswith('wis2box/failure'):
descr = m['description']
descr = m['description'] if 'description' in m else 'none'
wsi = 'none'
if 'wigos_station_identifier' in m:
wsi = m['wigos_station_identifier']
failure_descr_wsi_total.labels(descr, wsi).inc(1)
notify_wsi_total.labels(wsi).inc(0)
failure_wsi_total.labels(wsi).inc(1)
station_wsi.labels(wsi).set(1)
failure_total.inc(1)
elif str(msg.topic).startswith('wis2box/storage'):
if str(m["Key"]).startswith('wis2box-incoming'):
Expand Down

0 comments on commit dc7cfc2

Please sign in to comment.