k6

How to add tag into "iteration_duration"

Hi,

I have a requirement to run different profile on k6 and need to show the results on Grafana. I could able to add profile tag for user created metrics as follows. My problem is I want to distinguish “iteration_duration” by profile.

`profile_trend.add(value, { profile: 'profileName'});`

Or else is there way to access iteration_duration end of each default function ?

Hi @arunaxp,

Will test wide tags work in your case?

Hi @mstoykov,

my existing code as follows, recordings are all the profiles and call method function.

` export default function() {

  let recording = recordings[Math.floor(Math.random()*recordings.length)];

  console.log('FILE :'+recording.key);
  console.log(`VU: ${__VU}  -  ITER: ${__ITER}`);

    group('profile-'+recording.key, function() {
      let st = Date.now();
      recording.method();
      myTrend.add(Date.now() - st, { profile: recording.key});
      //recordingTrends[i].add(Date.now() - st, { profile: x.key});
      profile_trend.add(Date.now() - st, { profile: recording.key});
    });

    group('idle-time', function() {
      sleep(Math.floor(Math.random() * 30 + 10));
    });
}`

I have tried to use

wide tag

as you mentioned, But please let me know how it helps to my scenario?

Please let me know if you need a clerification

I misunderstood that you will have a single profile for the whole test runs but will have different ones between test runs.

I don’t think it’s currently possible to change/add tags to iteration_duration from inside the script except with test wide tags.
If what you need is though to measure the duration of the iteartion of profileX you can use group_duration. You can’t add custom tags to it either but it will have group=<groupname> so in your case above 'profile-'+ recording.key which should be sufficient, I think .

1 Like