Meliodas
Meliodas

Reputation: 337

How to authenticate to influxdb when using k6

I am using k6 for as a load testing tool and I want to write data to influxdb. It all works fine except I do not know how to send user credentials for influxdb.

Example:

./k6.exe run --out "influxdb=http://localhost:8086/stresstest" script.js --vus 10 --duration 3s

I tried to pass influxdb username and password like this, but it doesn't work

./k6.exe run --out "influxdb=http://localhost:8086/stresstest?u=<USERNAME>&p=<PASSWORD>" script.js --vus 10 --duration 3s

I do not want to disable influxdb auth!

Upvotes: 2

Views: 3409

Answers (1)

na--
na--

Reputation: 1106

You can pass them as HTTP auth in the InfluxDB URL like this: --out "influxdb=http://<username>:<password>@localhost:8086/stresstest"

Alternatively, you could also specify them via the K6_INFLUXDB_USERNAME and K6_INFLUXDB_PASSWORD environment variables.

Upvotes: 11

Related Questions