Hi @satheeshpandianj
I’m not sure why it does not work for you, unless the contents of grafana
directory are not the same I have (running on Mac OS).
I run the example from https://github.com/grafana/xk6-output-prometheus-remote/blob/main/docker-compose.yml. Using that repo, it loads the dashboard from https://github.com/grafana/xk6-output-prometheus-remote/tree/main/grafana/dashboards, and seems to work well for me. I do not have to change the Prometheus URL, http://localhost:9090/api/v1/write works well.
This is probably what you need to investigate further. Is your local environment working with the URL we expect from inside the container, http://prometheus:9090 (it should probably translate to 172.21.0.1:9090 in your case)?
You can probably check in the grafana container has issues connecting to prometheus:
$ docker exec -it <grafana-container> /bin/bash
2107a0272568:/usr/share/grafana$ wget http://prometheus:9090
And also double-check the Grafana docker logs, to see if anything is suspicious when you are running this dashboard.
In my case, I followed the instructions at Prometheus remote write and used your k6 test script. The only thing I changed was increasing VUs and duration so that I could see a bit more results. With the default script, you will run an interaction without much data to be seen. Though you should still see the one request:
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
vus: 10,
duration: '30s',
};
export default function () {
http.get('https://test.k6.io');
sleep(1);
}
I ran the test above with K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true k6 run -o experimental-prometheus-rw --tag testid=test-1 ./samples/test.js
and the results show as well, with no need to reconfigure anything as you had to:
You could also load Official k6 Test Result | Grafana Labs with similar results, I imagine. I do not think this will be related or help out.
I am sorry I cannot help more. I would probably investigate how the docker container’s network works in your platform, and if you need to change it to adjust in any way, which is not the usual use case with a docker-compose, but…
Cheers!