How to group by url for vital metric?

Hello,
Im executing k6 browser test and sending metrics to a influxdb and can select and view the vitals but when i want to group by url then there is issues since the url is not a Tag in Influxdb.

SELECT percentile("value", 90) FROM browser_web_vital_fcp WHERE ("script" =~ /^Testscript$/) GROUP BY  "url"

I’ve tried to create a CONTINUOUS QUERIES and group by time, script and url, but still can’t get any data out of it.

CREATE CONTINUOUS QUERY "cq_url_as_tag" ON "loadtest" BEGIN SELECT max("value") AS "value" INTO "browser_web_vital_fcp_transformed" FROM "browser_web_vital_fcp" GROUP BY time(1m), "script", "url" END

Is there any other way that i can group by url?

Hi @shineakimchi,

You are correct, by default the url is set as a field and not a tag. In the soon to be released version of k6 (v0.55.0) you will be able to work with name instead of url, which is a tag and not a field to group by url (the url and name are the same value).

For now though you can override the default behaviour (which is that k6 will set vu, iter, and url to a field) by configuring it through K6_INFLUXDB_TAGS_AS_FIELDS, e.g.:

K6_INFLUXDB_TAGS_AS_FIELDS=vu:int,iter:int ./k6 run -o xk6-influxdb=http://localhost:8086 examples/fillform.js

This will allow the url to be set as a tag and therefore allowing you to group by in influxdb.

Hope this helps,
Ankur

1 Like

Thanks for the answer!