How do I graph response time for each API?

I’m having 2 APIs to be executed and I need to see response time distribution of each API (p95, p99 etc.), let’s say I have a simple block code as this:

export default function () {
    get_Data_User();
    update_NewUser();
}

On Grafana k6 doc, it seems that k6 did not have this type of measurement yet, only having below call, but logging on console (which is not matching use case):

import http from 'k6/http';

export default function () {
  const res = http.get('https://httpbin.test.k6.io');
  console.log('Response time was ' + String(res.timings.duration) + ' ms');
}

So is there a way to see each API response time distribution graph? Thank you in advance

you could add tags for individual requests
and create thresholds for each of them
so that the metric for each threshold is printed in the summary output

1 Like

Page with code example for tags: Thresholds | Grafana k6 documentation

If you use the Httpx module, use addTag instead: addTag( key, value ) | Grafana k6 documentation

If you have many distinct URLs, you may want to group them with tags to avoid too many distinct metrics: HTTP Requests | Grafana k6 documentation

The default end-of-test summary includes p(95) by default but you can define p(99) or other values using the summaryTrendStats option: Options reference | Grafana k6 documentation

You can then set up a threshold on your custom tag: Thresholds | Grafana k6 documentation

1 Like