Minor fixes to grafana
Change-Id: I3143b4c699be949d4b0ed0b2d70446dac16e0360
diff --git a/compose/docker-compose-system-test.yml b/compose/docker-compose-system-test.yml
index 87d42ff..6cd3c48 100644
--- a/compose/docker-compose-system-test.yml
+++ b/compose/docker-compose-system-test.yml
@@ -107,7 +107,7 @@
"/shovel/shovel/main.py",
"--kafka=@kafka",
"--consul=${DOCKER_HOST_IP}:8500",
- "--topic=voltha.kpi",
+ "--topic=voltha.kpis",
"--host=${DOCKER_HOST_IP}"
]
depends_on:
diff --git a/shovel/main.py b/shovel/main.py
index 60a9d62..3854601 100755
--- a/shovel/main.py
+++ b/shovel/main.py
@@ -14,6 +14,7 @@
from optparse import OptionParser
import simplejson
+import structlog
from kafka import KafkaConsumer
import pickle
import struct
@@ -27,6 +28,9 @@
from common.utils.consulhelpers import get_endpoint_from_consul
+log = structlog.get_logger()
+
+
class Graphite:
def __init__(self, host='localhost', port=2004, retry=5, delay=3,
@@ -179,6 +183,7 @@
except socket.gaierror, e:
print "Invalid hostname for graphite host %s" % (host)
sys.exit(1)
+ log.info('Connected to graphite at {}:{}'.format(host, port))
# Resolve Kafka value if it is based on consul lookup
if kafka.startswith('@'):
@@ -186,14 +191,14 @@
# Connect to Kafka
try:
- print 'Connecting to Kafka at {}'.format(kafka)
+ log.info('connect-to-kafka', kafka=kafka)
consumer = KafkaConsumer(topic, bootstrap_servers=kafka)
except KafkaError, e:
- print "Could not connect to kafka bootstrap server {}: {}".format(
- kafka, e)
+ log.error('failed-to-connect-to-kafka', kafka=kafka, e=e)
sys.exit(1)
# Consume Kafka topic
+ log.info('start-loop', topic=topic)
for record in consumer:
assert isinstance(record, ConsumerRecord)
msg = record.value
@@ -201,9 +206,11 @@
try:
batch = _convert(simplejson.loads(msg))
except Exception, e:
- print "Unknown format, could not extract data: {}".format(msg)
+ log.warn('unknown-format', msg=msg)
continue
pickled = _pickle(batch)
graphite.send(pickled)
- print "Sent %s metrics to Graphite" % (len(batch))
+ log.debug('sent', batch_len=len(batch))
+
+ log.info('exited')