K6 and influxdb v2 not create database and add data

Hi,

I am using influxdb v2.1

When I run the k6 script, the influxdb side does not create a database or add data.

for more details :

$env:K6_INFLUXDB_BUCKET="myk6db" ; ./k6 run uiRequests.js --out xk6-influxdb=http://localhost:8086 --verbose
DEBU[0000] Logger format: TEXT
DEBU[0000] k6 version: v0.35.0 ((devel), go1.17.6, windows/amd64)

          /\      |‾‾| /‾‾/   /‾‾/
     /\  /  \     |  |/  /   /  /
    /  \/    \    |     (   /   ‾‾\
   /          \   |  |\  \ |  (‾)  |
  / __________ \  |__| \__\ \_____/ .io

DEBU[0000] Initializing the runner...
DEBU[0000] Loading...                                    moduleSpecifier="file:///C:/K6Learning/netsparker-cloud/Tests/uiRequests.js" originalModuleSpecifier=uiRequests.js
DEBU[0000] Babel: Transformed                            t=258.0215ms
DEBU[0000] Loading...                                    moduleSpecifier="https://jslib.k6.io/k6-utils/1.1.0/index.js" originalModuleSpecifier="https://jslib.k6.io/k6-utils/1.1.0/index.js"
DEBU[0000] Fetching source...                            url="https://jslib.k6.io/k6-utils/1.1.0/index.js?_k6=1"
DEBU[0001] Fetched!                                      len=934 t=318.0454ms url="https://jslib.k6.io/k6-utils/1.1.0/index.js?_k6=1"
DEBU[0001] Babel: Transformed                            t=104.6315ms
DEBU[0001] Getting the script options...
DEBU[0001] Initializing the execution scheduler...
DEBU[0001] Starting 1 outputs...                         component=engine
DEBU[0001] Starting...                                   output=InfluxDBv2
DEBU[0001] Starting the REST API server on localhost:6565
DEBU[0001] Started                                       output=InfluxDBv2
  execution: local
     script: uiRequests.js
     output: InfluxDBv2 (http://localhost:8086)

  scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
           * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)

DEBU[0001] Initialization starting...                    component=engine
DEBU[0001] Start of initialization                       executorsCount=1 neededVUs=1 phase=local-execution-scheduler-init
DEBU[0001] Initialized VU #1                             phase=local-execution-scheduler-init
DEBU[0001] Finished initializing needed VUs, start initializing executors...  phase=local-execution-scheduler-init
DEBU[0001] Initialized executor default                  phase=local-execution-scheduler-init
DEBU[0001] Initialization completed                      phase=local-execution-scheduler-init
DEBU[0001] Execution scheduler starting...               component=engine
DEBU[0001] Start of test run                             executorsCount=1 phase=local-execution-scheduler-run
DEBU[0001] Running setup()                               phase=local-execution-scheduler-run
DEBU[0001] Metrics processing started...                 component=engine
DEBU[0001] Starting emission of VU metrics...            component=engine
DEBU[0001] Start all executors...                        phase=local-execution-scheduler-run
DEBU[0001] Starting executor                             executor=default startTime=0s type=per-vu-iterations
DEBU[0001] Starting executor run...                      executor=per-vu-iterations iterations=1 maxDuration=10m0s scenario=default type=per-vu-iterations vus=1
DEBU[0002] Sending metrics points...                     output=InfluxDBv2 points=49 samples=15
DEBU[0002] Metrics points have been sent                 elapsed=16.001ms output=InfluxDBv2
DEBU[0002] Executor finished successfully                executor=default startTime=0s type=per-vu-iterations
DEBU[0002] Running teardown()                            phase=local-execution-scheduler-run
DEBU[0002] Regular duration is done, waiting for iterations to gracefully finish  executor=per-vu-iterations gracefulStop=30s scenario=default
DEBU[0003] Execution scheduler terminated                component=engine error="<nil>"
DEBU[0003] Processing metrics and thresholds after the test run has ended...  component=engine
DEBU[0003] Engine run terminated cleanly

running (00m01.9s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs  00m00.8s/10m0s  1/1 iters, 1 per VU
DEBU[0003] Metrics emission terminated                   component=engine
DEBU[0003] Engine: Thresholds terminated                 component=engine
DEBU[0003] run: execution scheduler terminated           component=engine

     █ setup

       ✓ status is 200
       ✓ is authenticated

       █ Main Page

         ✓ Status is 200
         ✓ transaction time OK

     █ Websites

       ✓ Status is 200
       ✓ is Websites page

     █ Technologies Dashboard

       ✓ Status is 200
       ✓ is Technologies Dashboard page

     █ teardown

     checks.........................: 100.00% ✓ 8        ✗ 0
     data_received..................: 94 kB   51 kB/s
     data_sent......................: 2.7 kB  1.5 kB/s
     error_rate.....................: 0.00%   ✓ 0        ✗ 3
     group_duration.................: avg=412.05ms min=357.95ms med=404.45ms max=473.77ms p(90)=459.91ms p(95)=466.84ms
     http_req_blocked...............: avg=92.64ms  min=0s       med=0s       max=262.22ms p(90)=237.74ms p(95)=249.98ms
     http_req_connecting............: avg=24ms     min=0s       med=0s       max=60.29ms  p(90)=60.06ms  p(95)=60.18ms
     http_req_duration..............: avg=171.58ms min=66.66ms  med=93.67ms  max=355.16ms p(90)=321ms    p(95)=338.08ms
       { expected_response:true }...: avg=171.58ms min=66.66ms  med=93.67ms  max=355.16ms p(90)=321ms    p(95)=338.08ms
     http_req_failed................: 0.00%   ✓ 0        ✗ 5
     http_req_receiving.............: avg=1.62ms   min=0s       med=954µs    max=3.97ms   p(90)=3.66ms   p(95)=3.81ms
     http_req_sending...............: avg=306µs    min=0s       med=0s       max=874µs    p(90)=786.8µs  p(95)=830.4µs
     http_req_tls_handshaking.......: avg=56.6ms   min=0s       med=0s       max=142.32ms p(90)=141.68ms p(95)=142ms
     http_req_waiting...............: avg=169.65ms min=66ms     med=92.79ms  max=351.96ms p(90)=317.49ms p(95)=334.72ms
     http_reqs......................: 5       2.692179/s
     iteration_duration.............: avg=613.43ms min=499.47ms med=508.43ms max=832.38ms p(90)=767.59ms p(95)=799.99ms
     iterations.....................: 1       0.538436/s
     vus............................: 1       min=1      max=1
     vus_max........................: 1       min=1      max=1

DEBU[0003] Waiting for engine processes to finish...
DEBU[0003] Metrics processing winding down...            component=engine
DEBU[0003] Everything has finished, exiting k6!
DEBU[0003] Sending metrics points...                     output=InfluxDBv2 points=22 samples=8
DEBU[0003] Metrics points have been sent                 elapsed=10.2533ms output=InfluxDBv2
DEBU[0003] Stopping 1 outputs...                         component=engine
DEBU[0003] Stopping...                                   output=InfluxDBv2
DEBU[0003] Stopped                                       output=InfluxDBv2

Do I need to create a database manually on the influxdb side?
I don’t know how to create a database in influxdbv2

Please help me on this.

Hi @cpolat !

Yes, it should have a bucket if you use the Influxdb v2, it should have a bucket. You can find the article on how to do it in the Influxdb documentation.

However, if you want to try it locally, I’d recommend using the docker :slight_smile:

For example, in the repository of the grafana/xk6-output-influxdb repository, you can find a good docker-compose example.

If you want to try it with the Influxdb v2.1, here is the way how to run pre-configured container:

docker run --rm -t -p 8086:8086 \
      --env "DOCKER_INFLUXDB_INIT_MODE=setup" \
      --env "DOCKER_INFLUXDB_INIT_USERNAME=root" \
      --env "DOCKER_INFLUXDB_INIT_PASSWORD=password1" \
      --env "DOCKER_INFLUXDB_INIT_ORG=k6io" \
      --env "DOCKER_INFLUXDB_INIT_BUCKET=demo" \
      --env "DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=secret_token" \
      influxdb:2.1

and after you can run the k6

K6_INFLUXDB_ORGANIZATION=k6io \
K6_INFLUXDB_BUCKET=demo \
K6_INFLUXDB_TOKEN=secret_token \
./k6 run -o xk6-influxdb=http://localhost:8086 script.js

Let me know if that helps,
Cheers

Hi @olegbespalov

I solved the problem by looking at influxdb side. Thank you for your attention.

Best regards