Jay
Jay

Reputation: 381

K6-InfluxDB-Docker- msg="Couldn't write stats" - connect: connection refused"

My question about docker is limited. What I am trying to do it

  1. run the K6 load test in the docker container 2)save the results in influxdb
  2. create custom dashboards in grafana

My K6 script is ready. I downloaded docker desktop on my windows OS, pulled images of Influx DB 1.8(which is compatible with K6), grafana 3)loadimpact/k6

When I give the following command,

docker run -v //c/loadtesting:/src -i loadimpact/k6 run --out influxdb=http://localhost:8086/myk6db /src/K6-script.js

My loadtest runs fine but I receive following error at each api call:

time="2021-10-16T16:32:09Z" level=error msg="Couldn't write stats" error="Post \"http://localhost:8086/write?consistency=&db=myk6db&precision=ns&rp=\": dial tcp 127.0.0.1:8086: connect: connection refused" output=InfluxDBv1

On the docker container, the influxdb is running on port 8086 but since it's version 1.8, there is no web interface attached to it. ( I believe it is available for higher versions).

How do I make my script results output to influxdb database myk6db?

Upvotes: 0

Views: 1698

Answers (1)

knittl
knittl

Reputation: 265605

The Docker container loadimpact/k6, which you are running, does not ship with an InfluxDB. When you send data to localhost from inside the container, it will be sent to the container itself.

You have to make sure that your InfluxDB is reachable from your container. Either by running it in the same Docker virtual network, accessing it by IP (reachable from inside the container), or by running your container in host network mode.

Upvotes: 1

Related Questions