Commit 846b6958 authored by ale's avatar ale
Browse files

Add probeset=service to exported metrics

parent b5b85225
Pipeline #6611 passed with stages
in 2 minutes and 9 seconds
......@@ -3,14 +3,18 @@ import logging
import time
try:
from prometheus_client import Gauge
probe_success = Gauge('probe_success', 'Probe success', ['probe'])
probe_success = Gauge('probe_success', 'Probe success', ['probe', 'probeset'])
probe_last_run_ts = Gauge(
'probe_last_run_seconds', 'Timestamp of last probe run', ['probe'])
'probe_last_run_seconds', 'Timestamp of last probe run', ['probe', 'probeset'])
has_prometheus = True
except ImportError:
has_prometheus = False
# A way to distinguish these prober metrics from all others.
PROBESET = 'service'
class Context(dict):
def copy(self):
......@@ -35,6 +39,7 @@ class Probe(object):
def __init__(self, fn, name, ctx):
self.fn = fn
self.name = name
self.probeset = PROBESET
# Create a logger for this probe, and make a copy of the Context.
if not isinstance(ctx, Context):
......@@ -64,9 +69,9 @@ class Probe(object):
result['elapsed'] = end_timestamp - start_timestamp
result['log'] = log_buffer.getvalue()
if has_prometheus:
probe_success.labels(self.name).set(
probe_success.labels(self.name, self.probeset).set(
1 if result['status'] == 'ok' else 0)
probe_last_run_ts.labels(self.name).set(end_timestamp)
probe_last_run_ts.labels(self.name, self.probeset).set(end_timestamp)
results.add(self.name, int(end_timestamp), result)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment