forked from keenlabs/capillary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats-to-datadog.py
42 lines (35 loc) · 921 Bytes
/
stats-to-datadog.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
import urllib2
import json
import sys
from statsd import statsd
statsd.connect('localhost', 8125)
topology = sys.argv[1]
toporoot = sys.argv[2]
topic = sys.argv[3]
state = urllib2.urlopen(
"http://localhost:9000/api/status?toporoot={}&topic={}".format(
toporoot, topic
)
).read()
data = json.loads(state)
amount = 0
for looplord in data:
if looplord['amount'] is not None:
statsd.gauge(
'razor.kafkamon.topology.partition',
amount,
tags = [
"topic:{}".format(topic),
"topology:{}".format(topology),
"partition:{}".format(looplord['partition'])
]
)
amount += looplord['amount']
print "Got {} for {}".format(amount, topology)
statsd.gauge(
'razor.kafkamon.total_delta',
amount, tags = [
"topic:{}".format(topic),
"topology:{}".format(topology)
]
)