Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a global job tag to all instances of a given job #483

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrissnell
Copy link

@chrissnell chrissnell commented Oct 30, 2024

When outputting Prometheus metrics, k6-operator includes a job_name tag, but the value of this tag corresponds to the individual instance (== Pod) running a test. So, for a job called test, the values of job_name look like test-1, test-2, etc.

This makes it very difficult to build a dashboard that displays all jobs running a particular test. We need a tag that provides the name of the job without any instance numbers.

People want test-wide tags:

https://community.grafana.com/t/k6-operator-pass-local-environment-variable-as-test-wide-tag/99639

People are struggling with bugs:

#162
#211

This PR adds a base_job_name tag that contains only the job name.

In the example above, this PR adds a base_job_name tag with a value of test.

@yorugac
Copy link
Collaborator

yorugac commented Nov 7, 2024

Hi @chrissnell, thank for the PR! I believe this is the case when it's preferable to open an issue / forum question first and have a discussion there 😅

The links you added are actually about troubles around quotes and env vars specifically, and the forum question was resolved. So this seems unrelated to the dashboard problem you described. Specifically:

This makes it very difficult to build a dashboard that displays all jobs running a particular test. We need a tag that provides the name of the job without any instance numbers.

Currently, there are as many Jobs per TestRun as parallelism value + 2. These jobs are named with suffix attached to the name of a TestRun. So "all jobs" is basically the name of a test run CR. That information is being added to all Jobs already with the .metadata.labels:

metadata:
  labels:
    k6_cr: <name>

So if you scrape your Kubernetes metrics to Prometheus, it should be possible to insert those labels as well. IOW, it makes sense to double-check your metrics scraping config.

For example, in Loki, I have been doing the following to get logs from all jobs per test run:

{cluster="...", namespace="k6-op", k6_cr="my-test"}

Let me know if this workaround works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants