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 -
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.
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.
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.
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
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.