-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
in k8s prometheus receiver does not have the ability to only scrape the metrics of pods on its own node #27642
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
You can use the receivercreator with the |
You can also use the field selector in the prometheus scrape config: scrape_configs:
- job_name: kubernetes_pods
kubernetes_sd_configs:
- role: pod
selectors:
- role: pod
field: spec.nodeName=$NODE_NAME Then on your pod spec: env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName |
But in my understanding, selectors.field does not recognize environment variables. Will this really work? @dashpole |
The collector does env var substitution. So $NODE_NAME is passed to the prometheus receiver config as the value of the env var, not as the "$NODE_NAME" string. This works in the otel collector, but does not work in upstream prometheus server. I've used this quite extensively myself. |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping |
working as intended. |
Component(s)
receiver/prometheus
Is your feature request related to a problem? Please describe.
The collector is deployed by deamonset in my project. I want to collect metrics of apps in each pod with the Prometheus receiver, but I found the receiver can't only scrape the metrics of pods on its own node. Is there any method to solve this problem?
Describe the solution you'd like
Prometheus receiver can scrape the metrics of pods on its own node.
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: