I am using InfluxDb and have simple line protocol line as shown below:
cpu,atag=test1 idle=100,usertime=10,system=1
I have python client using dictionary as shown below
client = InfluxDBClient(host, port, USER, PASSWORD, DBNAME)
client.create_database(DBNAME)
tagdic= {'Name': 'n1', 'data': 7}
fielddic= {'Name': 'field', 'f1': 70}
def main():
var = 1
while var == 1 :
client.write("cpu,atag=test1 idle=100,usertime=10,system=1")
#client.write_points([{"measurement": "cpu", "tags": tagdic, "fields": fielddic}])
Above program is working fine as long as I am using write_points using write_points and dictionary, but when i am using client.write i am getting errors.
How can i use client.write as mention here (line number -255) by using protocol value = 'line' instead of default protocol 'json'?
What errors are you getting? That is quite essential information.
Are you getting:
influxdb.exceptions.InfluxDBClientError: 400: {"error":"database is required"}
Then you should write your call like this:
client.write(['cpu,atag=test1 idle=100,usertime=10,system=1'],{'db':DBNAME},204,'line')
Things I changed:
A note for ubuntu users: if you install with the ubuntu package manager at the time of writing you will get an older version of the python client where the write function takes other arguments. So install with pip when in doubt.