Changing json format

This commit is contained in:
Alexey 2018-10-08 21:07:59 +03:00
parent 58d4cf394a
commit 777e3441cb

View file

@ -23,6 +23,7 @@ def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSER
IPS = {} IPS = {}
GEOHASH = {} GEOHASH = {}
COUNT = {} COUNT = {}
METRICS = []
with open(LOGPATH, "r") as FILE: with open(LOGPATH, "r") as FILE:
STR_RESULTS = os.stat(LOGPATH) STR_RESULTS = os.stat(LOGPATH)
ST_SIZE = STR_RESULTS[6] 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 HASH = Geohash.encode(INFO['latitude'], INFO['longitude']) # NOQA
GEOHASH['geohash'] = HASH GEOHASH['geohash'] = HASH
COUNT['count'] = 1 COUNT['count'] = 1
IPS['measurement'] = 'MEASUREMENT' IPS['measurement'] = MEASUREMENT
IPS['tags'] = GEOHASH IPS['tags'] = GEOHASH
IPS['fields'] = COUNT IPS['fields'] = COUNT
RESULT = json.dumps(IPS) METRICS.append(IPS)
RESULT = json.dumps(METRICS)
print(RESULT) print(RESULT)