grafana / k6-operator

An operator for running distributed k6 tests.
Apache License 2.0
593 stars 166 forks source link

Ability to set custom job_name #460

Closed artem-zherdiev-ingio closed 2 months ago

artem-zherdiev-ingio commented 2 months ago

Hey, we want to try metric relabeling and it seems impossible to set custom job_name in k6 operator. https://github.com/grafana/k6-operator/blob/64be967c7afe8a2ab4964a911f9752f789be0be6/pkg/resources/jobs/runner.go#L74

Is it possible to add some env var there?

yorugac commented 2 months ago

Hi @artem-zherdiev-ingio, job_name is set to the name of TestRun. You can add other tags to the script with .spec.arguments in TestRun. As for env vars in k6, IIRC, k6 does not send them as tags on its own. So they'll need to be explicitly configured as tags. Why not make metric relabeling on some other tag instead of job_name?

artem-zherdiev-ingio commented 2 months ago

Hey, @yorugac , neither --tag job_name in arguments, neither tag in options in js works. I think it's just it because hardcoded in code snippet above and filtered during sending to Prometheus RW or so.

Why not make metric relabeling on some other tag instead of job_name?

I tried by remoteWrite URL and it seems work. When created this ticket I saw scrape_config which by job_name only how I see.

EDITED. Also it seems write_relabel_configs not works for us very well, and need to try metric_relabel_configs and it's part of scrape_config where job_name needed

yorugac commented 2 months ago

job_name in scrape_config is meant to organize the scraping jobs, as described here: https://prometheus.io/docs/prometheus/latest/getting_started/#configuring-prometheus-to-monitor-itself It is being "renamed" into job by Prometheus itself.

IOW, it is not related to the job_name in TestRun: those two are separate.

artem-zherdiev-ingio commented 2 months ago

Thanks a lot for your answers