Created
August 13, 2019 23:50
-
-
Save dhiren051/3ca969bf0a24a229a86b69f8e2c0ee36 to your computer and use it in GitHub Desktop.
prometheus pushgateway python test metrics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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