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

Using k8s labels in prometheus rules expr #2338

Open
vlogachev-bd opened this issue Mar 13, 2024 · 1 comment
Open

Using k8s labels in prometheus rules expr #2338

vlogachev-bd opened this issue Mar 13, 2024 · 1 comment
Labels
needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@vlogachev-bd
Copy link

Hello,

I am new to Prometheus so I would ask for some advice.

I am trying to use custom labels from k8s deployment in the prometheus rules expression.

Here is my setup:

k8s labels:

labels:
app: nginx-test
ignore-desired-replicas: "true"
ignore-ram-usage: "true"
ignore-cpu-usage: "true"
ignore-container-restarts: "true"
team: xxx

kube-state-metrics deployment.

args:
- '--metric-labels-allowlist=pods=[team, ignore-ram-usage, ignore-cpu-usage, ignore-container-restarts],deployments=[team, ignore-desired-replicas],persistentvolumeclaims=[team]'

Prometheus rule
expr: kube_deployment_labels * on (deployment, namespace) group_right(label_team) ((kube_deployment_status_replicas_available / kube_deployment_spec_replicas) < 1 )

I also tried to add group_right(label_team, ignore-desired-replicas) and ( (label_team, label_ignore-desired-replicas), but I am not even able to startup the container, I assume due to the fact that it does not recognize the label.

It looks to me that I am making a mistake somewhere in the kube-state-metrics configuration.

Currently, when I receive an alert I can see that it groups only be team and it is ignoring my second label ignore-desired-replicas.

Any thoughts, folks?

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Mar 13, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

2 participants