Grafana Alert Test Rule returns 403 error and Prometheus prom_proxy logs system:anonymous" cannot get namespaces in project "openshift-metrics"
[Trying to set an Alert Rule in Grafana and getting error: tsdb.HandleRequest() error bad_response: bad response code 403. When checking prometheus pod logs, find User "system:anonymous" cannot get namespaces in project "openshift-metrics" oauthproxy.go:657: 10.131.0.1:45352 Cookie "_oauth_proxy" not present]
Version
[oc version oc v3.9.0+191fece kubernetes v1.9.1+a0ce1bc657 features: Basic-Auth
Server https://master.apps.shared.openshift.local:443 openshift v3.9.0+ba7faec-1 kubernetes v1.9.1+a0ce1bc657]
Steps To Reproduce
- [clone ansible-playbooks openshift-ansible-3.9.32-1
- [Update OSEv3 vars as shown: #Prometheus openshift_hosted_prometheus_deploy: true openshift_prometheus_namespace: openshift-metrics openshift_prometheus_node_selector: {"region":"infra"} openshift_prometheus_storage_type: pvc openshift_prometheus_alertmanager_pvc_name: alertmanager openshift_prometheus_alertbuffer_pvc_size: 10G openshift_prometheus_pvc_access_modes: [ReadWriteOnce] #Grafana openshift_grafana_namespace: openshift-metrics openshift_grafana_storage_type: pvc openshift_grafana_pvc_name: grafana openshift_grafana_pvc_size: 5G openshift_grafana_pvc_access_modes: [ReadWriteOnce]
- [Install prometheus via ansible-playbook -vvv /usr/share/ansible/openshift-ansible/playbooks/openshift-prometheus/config.yml]
- [Install grafana via ansible-playbook -vvv /usr/share/ansible/openshift-ansible/playbooks/openshift-grafana/config.yml]
- [Login to grafana console, create new Test Dasboard using Prometheus datasource and Query http_requests_total, then save dasboard] 6.[Edit Dashboard, got to Alerts Tab and create an alert condition: WHEN avg of query(A, 10s, now) IS ABOVE 20 Click Test Rule ]
Current Result
tsdb.HandleRequest() error bad_response: bad response code 403. When checking prometheus pod logs, find User "system:anonymous" cannot get namespaces in project "openshift-metrics" oauthproxy.go:657: 10.131.0.1:45352 Cookie "_oauth_proxy" not present
Expected Result
No errors and working Alert with Notifications being processed.
Additional Information
[try to run $ oc adm diagnostics (or oadm diagnostics) command if possible]
[if you are reporting issue related to builds, provide build logs with BUILD_LOGLEVEL=5]
[consider attaching output of the $ oc get all -o json -n <namespace> command to the issue]
[visit https://docs.openshift.org/latest/welcome/index.html]
After doing more troubleshooting today and turning up log level on the prometheus proxy container, we found the query being sent by the Alert Rule was going to /api/v1/query_range while the query being sent to prometheus for the dashboard metric was going to /metrics. We also found that in the prometheus stateful set configuration the following container arg was being set for oath-proxy - '-skip-auth-regex=^/metrics'. We modified the regex to include /api/vi/query_ranges as shown here: - '-skip-auth-regex=^/metrics,/api/v1/query_range' This resolves the issue and the Grafana Alert and notifications are working.
@mrogers950 @simo5 I have a feeling that skipping auth is not the right solution. Who do we ping for this?
The installation and configuration of the prometheus monitoring stack are changing significantly in 3.11 so this issue may no longer even be valid
@pgier for the 3.9 stack @brancz for the latest stuff
@openshift/sig-monitoring
In 3.11 Grafana will come preconfigured with the cluster monitoring stack so this is not something you will need to worry about. To my knowledge there is no solution to this pre 3.11 any type of bearer authentication was only recently added to Grafana. @mrsiano has more information on the Grafana authentication via ServiceAccount tokens and when this will land in OpenShift (separate from the cluster-monitoring-stack).
@skynardo How did you deploy your Grafana? there is some changes going on due to the openshift-monitoring changes
I installed grafana via ansible-playbook -vvv /usr/share/ansible/openshift-ansible/playbooks/openshift-grafana/config.yml
can you try to clone https://github.com/openshift/openshift-ansible and run it from there I'm afraid you use older version
@mrsiano I'm using the last update of release-3.10 branch and the problem is happening to me.
@brancz Which version of Grafana are we shipping with OpenShift 3.10?
@davivcgarcia grafana ships since 3.11 .. and its version is 5.2.x
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle rotten /remove-lifecycle stale
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.
/close
@openshift-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting
/reopen. Mark the issue as fresh by commenting/remove-lifecycle rotten. Exclude this issue from closing again by commenting/lifecycle frozen./close
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.