I have f5 pool and node data details in a python dictionary in a loop for more than 10+ pools, I was able to create summary metrics and labels and populate values for one value but not able to do in loop pool={'pool_name': 'testing-prom-tool','pool_member_name': 'promtest', 'mem_port': '443', 'mem_address': 'xx.xx.xx.xx', 'mem_state': 'down'} when i use pool as variable in the following code and it returns values in a loop. this is how I tested and was able to get for one value, but I'm not able to get for a loop. It just gives the end value of the loop. How can I achieve this for values in the loop?
Code:
import prometheus_client as prom
import random
import time
pool={'pool_name': 'testing-prom-tool','pool_member_name': 'promtest', 'mem_port': '443', 'mem_address': 'xx.xx.xx.xx', 'mem_state': 'down'}
# Create a metric to track time spent and requests made.
REQUEST_TIME = prom.Summary('request_processing_seconds', 'Time spent processing request')
# Decorate function with metric.
@REQUEST_TIME.time()
def process_request():
time.sleep(1)
if __name__ == '__main__':
# name documentation label names ### I was able to populate all the keys from the dictionary using the pool.keys())
f5_prom_test = prom.Summary('f5_test,'f5_node_status',('pool_name','member_name','mem_port','mem_address','mem_status'))
prom.start_http_server(1234)
While True:
process_request()
f5_prom_test.labels(pool.get('pool'),pool.get('name'),pool.get('port'),pool.get('address'),pool.get('state'))
#f5_prom.labels(**pool), this works as well
curl -K http://localhost:1234
f5_test_created{mem_address="xx.xx.xx.xxx",mem_name="test-server",pool_name"=testpool",mem_port="5443",mem_state="down"} 1.658982617711136e+09
I used http://localhost in my Prometheus.The YAML file only shows when the URL is up, and the data is not stored in the Prometheus tsdb. How can I keep the data in Prometheus tsdb using /metrics