Bucket option is required influxdbv2

I used xk6-output-influxdb. (GitHub - grafana/xk6-output-influxdb: k6 extension for InfluxDB v2)

But it throws an error.

./k6 run -o xk6-influxdb=http://localhost:8086 script.js

ERRO[0001] could not create the ‘xk6-influxdb’ output: the Bucket option is required

I tried to

K6_INFLUXDB_BUCKET=testBucket ./k6 run -o xk6-influxdb=http://localhost:8086 script.js

K6_INFLUXDB_BUCKET= : The term ‘K6_INFLUXDB_BUCKET=’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • K6_INFLUXDB_BUCKET= ./k6 run -o xk6-influxdb …
  •   + CategoryInfo          : ObjectNotFound: (K6_INFLUXDB_BUC...re-bucket-name>:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

Please help me on this.

Hi @cpolat,
welcome to the community forum! :tada:

I think you are facing the same problem reported in this topic Issue with xk6 output Prometheus remote extension - #3 by olha

You can try the workaround proposed in that response otherwise the unique alternative currently available is to use Docker.

1 Like

I tried many times but couldn’t get it to work. :frowning:

not working code

./k6 run script.js --out K6_INFLUXDB_TOKEN=abcd xk6-influxdb=http://localhost:8086/myk6db
./k6 run script.js --out xk6-influxdb=http://localhost:8086/myk6db K6_INFLUXDB_TOKEN=abcd

Do I really have to use docker ?

Please help me on this.

I solved the problem by running the following code in PowerShell. Thank you

$env:K6_INFLUXDB_BUCKET="myk6db" ./k6 run script.js --out xk6-influxdb=http://localhost:8086

Thank you folks, literally the only spot that explains the use of environment variables for us poor windows users. I used the following in powershell, will turn into a PS script.

PS C:\Windows\system32> $env:K6_INFLUXDB_BUCKET=“MyBucket”
PS C:\Windows\system32> $env:K6_INFLUXDB_ORGANIZATION=“MyOrg”
PS C:\Windows\system32> $env:K6_INFLUXDB_TOKEN=“API token generated in InfluxDB UI”
PS C:\Windows\system32>> $env:K6_INFLUXDB_PUSH_INTERVAL=“2”
PS C:\Windows\system32> Set-Location -Path “My Path to Script”
PS C:>My Path to Script>
PS C:>./k6 run -o xk6-influxdb=http://localhost:8086 simple_loop.js