Lgrech25
Lgrech25

Reputation: 1

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.

Contents of the file ServerInfluxdb.txt:

ServerState,state=1 value=1

Command used to import file:

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

Error Produced:

2019/02/07 10:39:40 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 is appreciated.

Thank you in advance,

Regards,

Luke

Upvotes: 0

Views: 515

Answers (1)

Samuel Toh
Samuel Toh

Reputation: 19298

The import option is use for importing an exported database. That is, your file (ServerInfluxdb.txt) will need to include the DDL for creating the database.

E.g.

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

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

treasures,captain_id=dread_pirate_roberts value=801 1439856000
treasures,captain_id=flint value=29 1439856000
treasures,captain_id=sparrow value=38 1439856000
treasures,captain_id=tetra value=47 1439856000
treasures,captain_id=crunch value=109 1439858880

See: https://docs.influxdata.com/influxdb/v1.7/tools/shell/#import-data-from-a-file-with-import

Upvotes: 1

Related Questions