`saveInterval` option not working in CSV output

Hi everyone! I’m attempting to run a load test on my test website and save the results to a CSV file. However, I’ve run into a problem where the ‘saveInterval’ option isn’t working. K6 is still writing to the CSV file every second, despite setting the saveInterval to 1 minute.

Here’s the command I’m using to run my test:

k6 run -e IP_ADDRESS=192.168.100.151:8080 -e ENVNAME=testEnv stressTest.js -o csv=fileName=testEnv.csv,saveInterval=1m

I’ve also tried setting the K6_CSV_SAVE_INTERVAL environment variable to 1m , but this doesn’t seem to have any effect either. Is anyone else experiencing this issue, or am I doing something wrong?

Thanks in advance for any help!

Hi @Kaz

Welcome to the community forum :wave:

I have tested with the following script:

import http from 'k6/http';

export const options = {
    vus: 1,
    duration: '5m',
};

export default function () {
    http.get('https://test-api.k6.io/');
}

With K6_CSV_SAVE_INTERVAL="1m" k6 run -o csv=test_results.csv script.js.

And what I see seems coherent with the documentation for the options: CSV.

During the first minute nothing is written except the CSV headers.

After a minute the results are written, I get around 6500 lines in the CSV. After another minute of not writing to the file, it writes the next 6500 metric points. Up to the 5 minutes of the test duration.

Similarly with k6 run -o csv=fileName=test_results.csv,saveInterval=1m metrics.js.

I’m using version 0.43.0 on a Mac OS. What version are you running with and what OS?

I hope this helps. If you can provide a bit more context we can determine if there is any platform-related issue, or if it’s an older version, etc.

Cheers!

Hi @eyeveebe

Thank you for your quick response!

I ran the same test script you provided with the command k6 run -o csv=fileName=test_results.csv,saveInterval=1m metrics.js, but unfortunately, the CSV file still outputs every second rather than every minute. I also tried setting the K6_CSV_SAVE_INTERVAL environment variable to 1m, but this did not work either.

I’m running the test on Windows 11 Education (22H2, 22623.1325), and my k6 version outputs the following: k6 v0.42.0 (2022-12-20T09:27:48+0000/v0.42.0-0-ga45ab5a4, go1.19.3, windows/amd64).

Update:

I’ve now tried running the same script and command with the newest version of k6 (k6 v0.43.0 (2023-02-20T11:15:24+0000/v0.43.0-0-g86013032, go1.19.6, windows/amd64)), but I’m still encountering the same issue.

After some testing with powershell I can confirm that it works as expected for me under windows.

I did not manage to set my env variable correctly the first time around as it turns out there are different ways depending on what shell you are using - so you might want to check that.

Also just to reitarate this is a setting tha says how often k6 writes the data to the disk as such:

  1. Doing it once a minute is likely a bad idea as it will need to keep the data in memory. So maybe it is interesting why you want ot increase this in the first place.
  2. The timestamp inside will still be of when the actual metric sample was emitted/recorded not of when it will be written to disk in case you are using that to determine when it writes to disk. If this is not your problem can you tell us what you are using to detect that it is being written more often?
2 Likes

Hi @mstoykov

Thanks for the clarification on the saveInterval option and how it works.

I think I may have misunderstood its purpose. Sorry about that :sweat_smile:. My intention was to group the data into 1-minute intervals so that I could create a graph of a 40-minute test without having too many data points. I’ll try using something like Python with the Pandas library to group the data into 1-minute intervals. Thanks!

1 Like