Threshold results in influx + grafana

Hi Team,

I am using K6, Influx and Grafana on our premises.

I am trying to grab “Threshold” values from k6 code to grafana, same as given in GitHub - grafana/xk6-output-timescaledb (Grafana screenshot shows threshold values with pass and fail e.g. http_req_duration(static:assest yes) - failed)

Issue is I am not getting threshold which I have defined in my code like -

‘http_req_duration{name:appointmentTab}’: [‘p(95)<5000’],
‘http_req_failed{name:appointmentTab}’: [‘rate==0’],
‘http_req_duration{name:Search}’: [‘p(95)<5000’],
‘group_duration{group:::Login::Login xhr}’: [‘p(95)<=2000’],
“check_failure_rate{page:login}”: [“rate<0.3”],

to influx db, so that i can query this in Grafana

Hi @vish_s02

Welcome to the community forums :wave:

I was testing the docker compose example in GitHub - grafana/xk6-output-timescaledb, and what I find in my case is that sometimes the threshold don’t show with the selected time range.

For example, selecting a test from the list:

I sometimes see the thresholds are empty. E.g. for immatest-1 below it does show empty. However, it does not happen for all the test runs I tried:

When I increase the window a bit, the thresholds show. In the example, I went from:

to:

(a very minor time range increase)

And then the thresholds appear:

Is that what you are seeing?

I did try another example with custom metrics based on the thresholds on tags example, and the same seems to happen. I need to increase a bit the time range that the test list defines.

As mentioned it does not happen for all tests. In the below test, submetrics-1, I do not need to increase the time range.

If that is what you see, I will further investigate in that direction: why the time range selected in the test list seems to bee too strict for thresholds in this panel. Just wanted to check with you this is the same issue you are reporting, or if it’s another issue that we should be looking into.

Cheers!

Thanks @eyeveebe for the response.

I am not seeing threshold at all which I defined in my test while trying to integrate k6 result in Grafana using influx db .

For example if i have to fetch “checks” which I mentioned in code e.g.


then I am able to see this in Grafana

but in same way when I defined threshold, I am not seeing this in Grafana



I am using influx db to store k6 output. Please confirm if I am missing anything here or if we can hava a quick call to understand the issue

Hi @vish_s02

Are you using the predefined dashboards/panels or trying to build your own panels? Does the predefined ones work for you?

What versions are you working with for timescaledb, grafana and k6?

Can you also share your (sanitized) test? I can try to reproduce this on my lab.

Cheers

Hi @eyeveebe

I am not using timescaledb, I am using influx db.

Dashboard - I am using [

k6 Load Testing Results By Groups

](k6 Load Testing Results By Groups | Grafana Labs)

And trying to create a new panel, where I can show the threshold which I have defined in code.

Lets consider the below code -

import http from 'k6/http';
import { sleep, check } from 'k6';
import { Counter } from 'k6/metrics';

// A simple counter for http requests

export const requests = new Counter('http_reqs');
const server = 'http://example.com';

// you can specify stages of your test (ramp up/down patterns) through the options object
// target is the number of VUs you are aiming for

export const options = {
  thresholds: {
    'http_req_duration{name:${}/endpoint1}': [ 'avg>0' ], // arbitrary threshold
    'http_req_duration{name:${}/endpoint2}': [ 'avg>0' ],
  },
};

export default function() {
  
  const token = http.get(http.url`${server}/endpoint1`).json('token');
  check(
    http.post(http.url`${server}/endpoint2`, 'token=' + token),
    {
      'token accepted': r => r.status === 200,
    });
}

I am running this code using command

k6 run test.js --out influxdb=http://127.0.0.1:8086/k6

So in Grafana I want to show threshold with threshold value and pass/fail status

Hi @vish_s02

Apologies for the confusion, since you mentioned GitHub - grafana/xk6-output-timescaledb I assumed that was the output being used and missed that you had mentioned influx.

Many thanks for clarifying this.

Let me have a look and I’ll get back to you.

Cheers!

Hi @eyeveebe any update?

Hi @vish_s02

Thanks for your patience on this topic. The InfluxDb output does not support sending thresholds, as you had well pointed out. We do have it in the JSON output, for example, and the TimescaleDb extension also supports it.

I was testing with the latest experimental-prometheus-rw, which can be used to output to InfluxDb, and it does not support it yet. We have an open issue for the experimental-prometheus-rw that you can follow: What happens to k6 thresholds when writing to prometheus? · Issue #28 · grafana/xk6-output-prometheus-remote · GitHub.

I hope this helps.

Cheers!