-
Notifications
You must be signed in to change notification settings - Fork 0
/
timely.py
45 lines (38 loc) · 1.03 KB
/
timely.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import requests
import json
import time
rangeInSec = 3600
now = int(time.time() * 1000)
host = ''
port = ''
url = host + ':' + port + '/api/query'
session = requests.Session();
headers = \
{
'Accepts' : 'text/json',
'content-type' : 'application/json'
}
payload = \
{
'msResolution' : 'true',
'globalAnnotations' : 'true',
'showQuery' : 'true',
'start' : now - (rangeInSec * 1000),
'end' : now,
'queries' :
[
{
'metric' : 'statsd.tserver.QueueNumOps',
'aggregator' : 'count',
'downsample' : '30s-count',
'tags' :
{
'instance' : 'TabletServer',
'sampleType' : 'GAUGE'
}
}
]
}
response = session.post(url, headers=headers, data=json.dumps(payload), verify=False)
obj = json.loads(response.content)
print json.dumps(obj, indent=2)