Update format

This commit is contained in:
Scott Wallace 2021-06-21 21:43:46 +01:00
parent bd6781e3ca
commit 75b6b1c3c2
Signed by: scott
GPG key ID: AA742FDC5AFE2A72

15
main.py
View file

@ -57,12 +57,19 @@ def metrics():
},
]
ret_str = ''
ret_strs = list()
for item in ret_data:
ret_str += f'# TYPE {item["key"]} {item["type"]}\r\n'
ret_str += f'{item["key"]} {item["value"]}\r\n'
ret_strs.append(f'# HELP {item["key"]} Weather metric')
ret_strs.append(f'# TYPE {item["key"]} {item["type"]}')
ret_strs.append(
item["key"]
+ '{'
+ " ".join([f'{key}="{val}"' for key, val in item["labels"].items()])
+ '} '
+ str(item["value"])
)
resp = Response(ret_str)
resp = Response('\n'.join(ret_strs))
resp.headers['Content-type'] = 'text/plain'
return resp