Skip to content

Commit

Permalink
update metrics API gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Dec 16, 2024
1 parent 9a70e26 commit 46ce40b
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions wis2-gdc-monitoring/metrics-collector/metrics_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import paho.mqtt.client as mqtt_client
from prometheus_client import (
Counter, Gauge, Info, start_http_server, REGISTRY, GC_COLLECTOR,
Counter, Gauge, start_http_server, REGISTRY, GC_COLLECTOR,
PLATFORM_COLLECTOR, PROCESS_COLLECTOR
)

Expand All @@ -51,11 +51,6 @@

# sets metrics as per https://github.com/wmo-im/wis2-metric-hierarchy/blob/main/metric-hierarchy/gdc.csv # noqa

METRIC_INFO = Info(
'wmo_wis2_gdc_metrics',
'WIS2 GDC metrics'
)

METRIC_PASSED_TOTAL = Counter(
'wmo_wis2_gdc_passed_total',
'Number of metadata records passed validation',
Expand Down Expand Up @@ -116,6 +111,12 @@
['centre_id', 'report_by']
)

METRIC_API_STATUS = Gauge(
'wmo_wis2_gdc_api_status',
'Status of GDC API',
['centre_id']
)

METRIC_DOWNLOADED_ERRORS_TOTAL = Counter(
'wmo_wis2_gdc_downloaded_errors_total',
'Number of metadata download errors',
Expand Down Expand Up @@ -146,15 +147,12 @@ def init_metrics() -> None:

gb_centre_id = get_gb_centre_id()

METRIC_INFO.info({
'centre_id': CENTRE_ID,
'url': API_URL,
'subscribed_to': gb_centre_id
})

METRIC_CONNECTED_FLAG.labels(
centre_id=gb_centre_id, report_by=CENTRE_ID).inc(1)

METRIC_API_STATUS.labels(
centre_id=CENTRE_ID).inc(1)

with open(CENTRE_ID_CSV) as fh:
reader = csv.DictReader(fh)
for row in reader:
Expand Down

0 comments on commit 46ce40b

Please sign in to comment.