Updating the Influxdb database every 1 minute by importing information through a text file

I am currently testing importing information from a text file to update an existing database called serverstate. I am trying to follow the Influxdb documentation but to no avail as I new to such system. I am trying to do like this( I am not sure whether the retention part is required or not):

USE serverstate
CREATE RETENTION POLICY oneday ON serverstate DURATION 1d Replication 1

ServerState,state=1 value=1

However when trying to import by using the following command:

influx -import -path=ServerInfluxdb.txt -precision=s

I am getting the following error:

2019/02/07 09:57:46 error: error parsing query: found USE, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1
2019/02/07 09:57:46 error: error parsing query: found ServerState, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1

Any help would be greatly appreciated.

Thank you in advance,

regards,

Luke

Instead of USE serverstate inside the file, please use -database serverstate on the command line

Thank you for you reply. I am still getting the following error unfortunately:

2019/02/07 10:17:28 error: error parsing query: found -, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1
2019/02/07 10:17:28 error: error parsing query: found ServerState, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1

Please post the contents of the file and the command you used to execute :+1:

I am unable to upload the file since I am a new member

Please remove -database serverstate from the file. This parameter should be used on the command line instead.

influx -database=serverstate -import -path=ServerInfluxdb.txt

Also be aware that you don’t need the retention policy line either and this will cause your data to be deleted after 1d

For any future requests, you can use code blocks :slight_smile:

Enter your code as text and then use the “</>” button in the toolbar to format.

Or surround your code with ```

Sorry for bothering you again:

So in text file I should have only the following?

ServerState,state=1 value=1

Because I am still getting the following error after using the command you gave me

2019/02/07 10:29:09 error: error parsing query: found ServerState, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1

Apologies, each line in the txt file should begin with INSERT

So the file should read:

INSERT ServerState,state=1 value=1

It still comes up with the following error:

2019/02/07 11:35:47 error: error parsing query: found INSERT, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1

Ah, I thought INSERT was an accepted command. You’ll need to use DML:

# DML
# CONTEXT-DATABASE: serverstate
# CONTEXT-RETENTION-POLICY: oneday

ServerState,state=1 value=1

If your database and retention policy do not exist, you can add this to the top of the file to create them:

# DDL
CREATE DATABASE serverstate
CREATE RETENTION POLICY oneday ON serverstate DURATION 1d REPLICATION 1

I’ll provide an example in an hour or so of using both DDL and DML

Thank you for your patience you SOLVED my Problem. I cannot thank you enough =)

I’ve published examples of this anyway. Glad we got it working:

HI, I am also facing same issue now. I changed my text file as you mentioned in the above suggestions , still i am getting the error. Can you please help me in resolving the issue?

DML
CONTEXT-DATABASE: import
CONTEXT-RETENTION-POLICY: oneyear

FO,type=FreshOrders avg_FreshOrders=1479.0840707964599,p95_FreshOrders=2589,FreshOrders=226 1593648000000
FO,type=FreshOrders avg_FreshOrders=2242.86170212766,p95_FreshOrders=5622,FreshOrders=188 1593475200000
FO,type=FreshOrders avg_FreshOrders=1682.3375,p95_FreshOrders=2738,FreshOrders=160 1593734400000

I am getting following error while executing it…

C:\Users\Administrator\Downloads\influxdb-1.8.0_windows_amd64\influxdb-1.8.0-1>influx -import -path=C:\Users\Administrator\Downloads\influxdb-1.8.0_windows_amd64\influxdb-1.8.0-1\data\import.txt -precision=s
2020/07/13 17:21:25 error: error parsing query: found DML, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1
2020/07/13 17:21:25 error: error parsing query: found CONTEXT, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1
2020/07/13 17:21:25 error: error parsing query: found CONTEXT, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1
2020/07/13 17:21:25 error: error parsing query: found FO, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1
2020/07/13 17:21:25 error: error parsing query: found FO, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1
2020/07/13 17:21:25 error: error parsing query: found FO, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1