I have filtered the bitrates from live streams and got the output below. I have constructed an API with Python and piped continuous data into influxdb, which should be monitored, like python api.py | python influx.py. However, I am unable to store this output into influxdb. If necessary I can show my API code.
Click here to show output to be stored in influxdb
#!usr/bin/python
import sys
import datetime
from influxdb import InfluxDBClient
from influxdb.client import InfluxDBClientError
from influxdb import DataFrameClient
import os
import time
client=InfluxDBClient('localhost',8086,'admin','admin',database='stackanm')
client.create_database('stackanm')
def store(bitrate,time):
json=[
{
"measurement":"bitrates",
"tags":{
"time":time,
"fields":{
"bitrate":bitrate
}
}
}
]
client.write_points(json,time_precision='u')
f = os.fdopen(sys.stdin.fileno(),'r',0)
for line in f:
elements = line.strip().split()
if len(elements) == 1:
bitrate = elements[0]
unixtime = elements[1].split('.')
stdtime = datetime.datetime.utcfromtimestamp(long(float(unixtime[1]))).strftime('%Y-%m-%dT%H:%M:%S')
influxtime = ".".join([stdtime,unixtime[1]])
store(bitrate,float(elements[1]),influxtime)