grafana / k6

A modern load testing tool, using Go and JavaScript - https://k6.io
GNU Affero General Public License v3.0
25.5k stars 1.26k forks source link

Add support for additional labels when doing prometheus remote writes #3716

Open amarao opened 5 months ago

amarao commented 5 months ago

Feature Description

Currently, when k6 is doing remote writes into Prometheus, it does add a single label 'scenario'. When multiple k6 copies are run from multiple servers, they don't work together with a single Prometheus server.

It would be nice to be able to distinct different jobs in the Prometheus with different labels.

Suggested Solution (optional)

Add an environment variable (e.g. K6_PROMETHEUS_REMOTE_LABELS="environment=production,server=srv1") to specify list of labels to be set on the series send to the Prometheus.

Any other solution (e.g. configuration within js file) will solve the problem too.

joanlopez commented 4 months ago

Hi @amarao,

Thanks for the feature request, we'll consider it within the team during one of our following issues review, as it goes through the pipeline.

jameshounshell commented 4 months ago

@amarao We ran into a similar problem in kubernetes. There is a way to add tags using command line flags so we inject the kubernetes pod ID as it's own tag. This eliminated the collision of data into one series.

For example:

k6 run .... --tag pod=${POD_NAME} ...