Update format
This commit is contained in:
parent
bd6781e3ca
commit
75b6b1c3c2
15
main.py
15
main.py
|
@ -57,12 +57,19 @@ def metrics():
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
ret_str = ''
|
ret_strs = list()
|
||||||
for item in ret_data:
|
for item in ret_data:
|
||||||
ret_str += f'# TYPE {item["key"]} {item["type"]}\r\n'
|
ret_strs.append(f'# HELP {item["key"]} Weather metric')
|
||||||
ret_str += f'{item["key"]} {item["value"]}\r\n'
|
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'
|
resp.headers['Content-type'] = 'text/plain'
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
Loading…
Reference in a new issue