2
votes

I have created a dockerfile on which i have written telegraf and influxdb instalation and configuration. when i created image from dockerfile and run container, i am getting data from telegraf to influxdb telegraf database.

But when I am trying to set retention policies for telegraf database in influxdb using entrypoint script in dockerfile. the polcies are not set on the docker container.

I used below commands in script but nothing is worked.

curl -G "http://localhost:8086/query" --data-urlencode "q=CREATE RETENTION POLICY m5 ON telegraf DURATION 1d REPLICATION 1

curl -XPOST "http://localhost:8086/query" --data-urlencode "q=CREATE DATABASE mydb"

influx -port 8086 -execute "CREATE RETENTION POLICY mypolicy1 ON telegraf DURATION 10d REPLICATION 1 DEFAULT"

How to run influx commands from entrypoint script which reflects on docker container?. Can any body help me on this..

1

1 Answers

1
votes

If you are on the host machine use commands below, otherwise replace 'localhost' with your influxdb address and port.

Database creation:

curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"

Retention policy:

curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY "one_week_only" ON "mydb" DURATION 1w REPLICATION 1 DEFAULT"