X-Git-Url: https://piware.de/gitweb/?p=learn-metrics.git;a=blobdiff_plain;f=things-series;fp=things-series;h=c67cd62d9a774463d4b78b70048cf23e108fba00;hp=0000000000000000000000000000000000000000;hb=1948264b92c88ebfe5176a4d61a23f01b457009a;hpb=762850f8170ad2411fe014b5af63d4820ac9301f diff --git a/things-series b/things-series new file mode 100755 index 0000000..c67cd62 --- /dev/null +++ b/things-series @@ -0,0 +1,28 @@ +#!/usr/bin/python3 +import time + +# time series in 5s steps +series = { + 'thing_count': { + 'type': 'counter', + 'help': 'how many things ran', + 'series': [0] * 6 + [1] * 6 + [2] * 6 + [7] * 12 + [8] * 12 + }, + 'thing_failures': { + 'type': 'counter', + 'help': 'how many things failed', + 'series': [0] * 12 + [1] * 6 + [5] * 24 + }, +} + +num = len(series[list(series)[0]]['series']) +now = int(time.time() * 1000) +timestamps = [now - 5000 * (num - i) for i in range(num)] + +for metric, data in series.items(): + assert len(data['series']) == num + print(f'# TYPE {metric} {data["type"]}') + print(f'# HELP {metric} {data["help"]}') + for (time, datum) in zip(timestamps, data['series']): + print(f'{metric} {datum} {time}') + print()