initial commit

main
n0emis 4 years ago
commit 4e69e2de72
Signed by: n0emis
GPG Key ID: 00FAF748B777CF10

1
.gitignore vendored

@ -0,0 +1 @@
.venv

@ -0,0 +1,30 @@
import time
import json
import requests
import prometheus_client as pc
class CoronaExporter:
def __init__(self):
self.cases7_per_100k = pc.Gauge('cases7_per_100k', 'Fälle der letzten 7 Tage/100.000 EW', ['county'])
def get_metrics(self):
r = requests.get('https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=*&returnGeometry=false&outSR=4326&f=json')
j = json.loads(r.text)
for lk in j['features']:
name = lk['attributes']['county']
self.cases7_per_100k.labels(county=name).set(lk['attributes']['cases7_per_100k'])
def run(self):
pc.start_wsgi_server(9000)
while True:
self.get_metrics()
time.sleep(120)
if __name__ == "__main__":
c = CoronaExporter()
c.run()

@ -0,0 +1,2 @@
requests
prometheus_client
Loading…
Cancel
Save