Getting Warn : Consider not using high-cardinality values like unique IDs as metric tags

Hi Team,

Below is test script

import k6 from 'k6';
import http from 'k6/http';
import { SharedArray } from 'k6/data';
import { scenario } from 'k6/execution';
import { check } from 'k6/execution';

const data = new SharedArray('Fetch Data', ()=> {
    //data.json has an array of test data around 1 million i.e 1 to 1000000
  return JSON.parse(open('./data.json'));
  });

export const options = {
  scenarios: {
    'constant-arrival-rate': {
      executor: 'constant-arrival-rate',
    rate: 500,
    timeUnit: '1s',
    duration: '30s',
    preAllocatedVUs: 500,
    },     
  },
  };

export default function (){
  const params = data[scenario.iterationInTest];  
  const requestUrl=`URL?param=${params}`;
  
    const result = http.request('GET', requestUrl,{
        headers: {
            'accept': '*/*',
            'Content-Type': 'application/json',
          },
      });

    k6.check(result, {
        'status was 200':  (response) => {
          if (response.status !== 200) {
            console.log(response.status, requestUrl);
          }
          return response.status === 200;
        },
      });
    }

While executing I am getting below Warn

WARN[0029] The test has generated metrics with 100358 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 https://k6.io/docs/using-k6/tags-and-groups for details.  component=metrics-engine-ingester

I couln’t understand it

Can you clarify & help me to resolve this ?

Note: Based on suggestion : SharedArray Data Parametrization usage
I am using below in script, not sure whether this is causing Warning
scenario.iterationInTest

Thank You

Hi @shailendrakumaromkar

In these situations, you can use the URL grouping. Otherwise, k6 is generating a different metric for each URL, and that is the message you are seeing in the output. High cardinality in the generated metrics.

You can also have a look at https://github.com/grafana/k6-learn/blob/main/Modules/III-k6-Intermediate/06-Organizing-code-in-k6-by-transaction_groups-and-tags.md#url-grouping.

I hope this helps.

Cheers!