usr bin env python from prometheus_client import start_http_server Gau

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
from prometheus_client import start_http_server, Gauge
import random
import time
status = Gauge('shit_status', 'Yohoho, mothefucker!', ['deps'])
def process_request(t):
"""A dummy function that takes some time."""
time.sleep(t)
if __name__ == '__main__':
# Start up the server to expose the metrics.
start_http_server(8000)
status.labels('postgres').set(1)
status.labels('kafka').set(0)
# Generate some shit requests.
while True:
process_request(random.random())