Skip to content

Instantly share code, notes, and snippets.

@dhiren051
Created August 13, 2019 23:50
Show Gist options
  • Save dhiren051/3ca969bf0a24a229a86b69f8e2c0ee36 to your computer and use it in GitHub Desktop.
Save dhiren051/3ca969bf0a24a229a86b69f8e2c0ee36 to your computer and use it in GitHub Desktop.
prometheus pushgateway python test metrics
#!/usr/bin/env python
from prometheus_client import start_http_server,Summary,Counter,Gauge,CollectorRegistry,push_to_gateway
import random
import time
import sys
def test_push_with_groupingkey(n,t):
registry = CollectorRegistry()
m = random.randint(1,100)
g = Gauge('test_push', 'ce shi', registry=registry).set(m)
push_to_gateway('localhost:9091', job="test",registry=registry)
print "-------------------------\n"
time.sleep(t)
if 'name' == 'main':
num = int(sys.argv[1])
for n in range(0,num):
test_push_with_groupingkey(n+1,1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment