Skip to content

Fix kubernetes job and workload labeling#75

Open
westaylor wants to merge 2 commits intografana:mainfrom
westaylor:fix-kube-job-labels
Open

Fix kubernetes job and workload labeling#75
westaylor wants to merge 2 commits intografana:mainfrom
westaylor:fix-kube-job-labels

Conversation

@westaylor
Copy link

Hi, this is my first contribution to Grafana, let me know if there's anything else this needs thanks!

This PR has two commits:

fix kube label used for metrics job label

there's one spot in code using __meta_kubernetes_pod_controller_type but everywhere else this is controller_kind

prometheus docs and alloy docs both say controller_kind is the correct label and there is no controller_type

I checked, and unfortunately looks like chatgpt and google gemini are both saying controller_type is a real value when it's not

update regex used for workload and job labels

there's 4 labels to consider here: workload and job in metrics, and workload and job in logs

workload and job share the same processing step, and in the log pipeline it directly copies the workload value to the job label making them identical

the input to the regex is the controller_kind label. before it was only running on ReplicaSet but at minimum it needs to be ReplicaSet|Job

To Note: there are 18 other instances of regex = "(ReplicaSet/.+)-.+" across the named modules. I've only updated the regex in the generic kubernetes log and metric scrape jobs. I wanted to ask if you think we should just update this regex everywhere in this or another PR, or if the maintainers of database/networking/etc know it only ever runs ReplicaSets and doesn't need a Job check


the reason these two commits are paired together is because the metrics job label, by using a nonexistent name controller_kind, never ran the regex and ended up with the correct value in the job label from an earlier step.

current state on main: 1/4 labels works by accident
commit 1: corrects label, breaking the end result
commit 2: fixes 4/4 labels

@CLAassistant
Copy link

CLAassistant commented Apr 21, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@westaylor westaylor force-pushed the fix-kube-job-labels branch from 0ddac61 to 8a6ede0 Compare June 6, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants