From 777e3441cbe846b6b3d0fd5407a04f95a517856c Mon Sep 17 00:00:00 2001 From: Alexey Date: Mon, 8 Oct 2018 21:07:59 +0300 Subject: [PATCH] Changing json format --- geoparser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/geoparser.py b/geoparser.py index be7606b..c4d4915 100755 --- a/geoparser.py +++ b/geoparser.py @@ -23,6 +23,7 @@ def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSER IPS = {} GEOHASH = {} COUNT = {} + METRICS = [] with open(LOGPATH, "r") as FILE: STR_RESULTS = os.stat(LOGPATH) ST_SIZE = STR_RESULTS[6] @@ -41,10 +42,11 @@ def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSER HASH = Geohash.encode(INFO['latitude'], INFO['longitude']) # NOQA GEOHASH['geohash'] = HASH COUNT['count'] = 1 - IPS['measurement'] = 'MEASUREMENT' + IPS['measurement'] = MEASUREMENT IPS['tags'] = GEOHASH IPS['fields'] = COUNT - RESULT = json.dumps(IPS) + METRICS.append(IPS) + RESULT = json.dumps(METRICS) print(RESULT)