channel-exporter: add status, variant, current to CHANNEL_REVISION
Example query returning the latest stable NixOS version: channel_revision{current="1",status="stable",variant="primary"}
Cole Helbling committed
Nov 23, 2021 at 13:20 UTC
5bcd917d866ffe22c824b71cf9950295701845a1
1 file changed
+6
-3
delft/eris/channel-exporter.py
+6
-3
@@ -13,7 +13,7 @@ import json
13
CHANNEL_REVISION = Gauge(
14
"channel_revision",
15
"Current revision, exported as a hack",
16
- ["channel", "revision"],
16
+ ["channel", "revision", "status", "variant", "current"],
17
)
18
19
@@ -70,9 +70,12 @@ if __name__ == "__main__":
70
measurement = measure_channel(channel)
71
if measurement is not None:
72
revision = measurement['revision']
73
+ status = about.get('status', '')
74
+ variant = about.get('variant', '')
75
+ current = int(status != 'unmaintained')
76
CHANNEL_UPDATE_TIME.labels(channel=channel).set(measurement['timestamp'])
74
- CHANNEL_REVISION.labels(channel=channel, revision=measurement['revision']).set(1)
75
- CHANNEL_CURRENT.labels(channel=channel).set(int(about['current']))
77
+ CHANNEL_REVISION.labels(channel=channel, revision=revision, status=status, variant=variant, current=current).set(1)
78
+ CHANNEL_CURRENT.labels(channel=channel).set(current)
79
print('updated {}'.format(channel))
80
previous_revision = revisions.pop(channel, None)
81
revisions[channel] = revision