Removing or reducing metrics in k6

I am doing some load tests and running out of memory. I suspect that metrics is the problem, as the memory usage slowly rises and I get tons of warnings saying the test is generating to many metrics. In the warning it suggest a limit of 100k and we are into the millions, the test is using more than 100GB memory, so I cannot simply add more memory.

The exact warning is “The test has generated metrics with 100163 unique time series, which is higher than the suggested limit of 100000 and could cause high memory usage. Consider not using high-cardinality values like unique IDs as metric tags or, if you need them in the URL, use the name metric tag or URL grouping. See Tags and Groups | Grafana k6 documentation for details. component=metrics-engine-ingester”

I have tried as the warning suggest to put tags on the request, however they do not follow http standards, so every request is a POST. And i suspec that is why the tag is not working, however i could also just be using it wrong.
This is an example of the request i have:
`export function getThings(userInfo) {
var url = GetUrl()
var body = GetBaseBody(userInfo)
body.cmd = “getThings”

var response = http.post(url.toString(), body, {
    tags: {group: 'PostsItemURL', name: 'PostsItemURL'},
})
return response.body.data

}
`

I have looked here for the URL grouping: HTTP Requests
Am i doing it wrong, or does it not work with this somewhat special api? Can i simply turn of the metrics, as i dont need them in the particular scenario where i run out of memory?

Hey @mja4,
you should not use the group tag as it can conflict with group(), if you add it in the future. Did you find used in the same way somewhere in the documentation?

The code you posted sounds fine to me and should resolve the issue. Are you sure that you’re applying the name tag for every request that you’re generating?

Are you using additional extensions when you run the test?

Hey
I have tried with and without the tags, and with and without group inside the tags. I pretty sure that I had it on every request.
I dont have access to run a large machine all the time, so i tried outputting to a file and looked through logs on a smaller scale, but i didn’t find much that helped.

We are running 150k + VU’s when doing the test and we have a great observability setup on our end, so i would like to just turn off every k6 metric and more or less use the tool only to simulate the traffic, but that does not seem possible.

We are rewriting all our test to get a more accurate representation of the userflow we have, so for now the optimization of the tests are on hold, until we find out if we have the same problem with the new test setup.

Hi,
the way to shut down the metrics system is by using at the same time the following flags --no-threshold --no-summary.

An example:

k6 run --no-threshold --no-summary script.js

Let me know if helps.