-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[prometheus] Cannot scrape only from required namespaces #5049
Comments
If The likely reason for the error is that scrape configs do not indicate namespaced discovery - prometheus attempts cluster-wide discovery but finds no targets as it does not have permissions for such discovery. - job_name: 'myapps'
kubernetes_sd_configs:
- role: endpoints
scheme: http If setting e.g server:
namespaces:
- ns1
- ns2
- ns3
releaseNamespace: true
useExistingClusterRoleName: myclusterrole then each kubernetes_sd_config must be adjusted with the namespaces field: - job_name: 'myapps'
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- ns1
- ns2
- ns3
own_namespace: true See also kubernetes_sd_config. |
Hi @zeritti, thanks for the brief input. |
There is an example of the namespaced discovery in the chart's CI directory which works as intended (validated in different clusters) - prometheus executes SD against its own namespace and successfully discovers and scrapes targets in this namespace, in this case at least that of kube-state-metrics. NOTE This example assumes the permission to create a cluster role is available to the deployer. |
Describe the bug a clear and concise description of what the bug is.
Use case: I want my Prometheus to scrape metrics only from a few namespaces inside my Kubernetes cluster
I am using Prometheus helm chart v26.0.0 and it has Prometheus v3.0.0.
I only want to scrape metrics from a few namespaces. So I used the below parameters in values.yaml, which tells that it can help in achieving that use case.
Actual Behaviour: It stops scraping from all namespaces, including
namespace1
&namespace2
from which we want to scrape.Also, below are the Prometheus logs from that time.
Expected Behaviour: It should only scrape from
namespace1
&namespace2
, and should not scrape from other namespaces.Note: If I comment out the above-mentioned parameters or do not set the, then my Prometheus scrape from all namespaces smoothly without any error in the logs.
I think these parameters are not doing their intended work and are misbehaving. Experts, could you please help with this?
What's your helm version?
v3.16.3
What's your kubectl version?
v1.31.3
Which chart?
prometheus
What's the chart version?
26.0.0
What happened?
No response
What you expected to happen?
No response
How to reproduce it?
No response
Enter the changed values of values.yaml?
No response
Enter the command that you execute and failing/misfunctioning.
NA
Anything else we need to know?
No response
The text was updated successfully, but these errors were encountered: