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


#1

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


#2

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


#3

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

#4

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


#5


#6


#7

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


#8

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


#9

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 ```


#11

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


#12

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

So the file should read:

INSERT ServerState,state=1 value=1

#13

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


#14

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

#15

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


#16

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


#17

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