origin icon indicating copy to clipboard operation
origin copied to clipboard

Grafana Alert Test Rule returns 403 error and Prometheus prom_proxy logs system:anonymous" cannot get namespaces in project "openshift-metrics"

Open skynardo opened this issue 8 years ago • 14 comments

[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
  1. [clone ansible-playbooks openshift-ansible-3.9.32-1
  2. [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]
  3. [Install prometheus via ansible-playbook -vvv /usr/share/ansible/openshift-ansible/playbooks/openshift-prometheus/config.yml]
  4. [Install grafana via ansible-playbook -vvv /usr/share/ansible/openshift-ansible/playbooks/openshift-grafana/config.yml]
  5. [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]

skynardo avatar Jun 12 '18 20:06 skynardo

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.

skynardo avatar Jun 13 '18 15:06 skynardo

@mrogers950 @simo5 I have a feeling that skipping auth is not the right solution. Who do we ping for this?

enj avatar Jun 14 '18 05:06 enj

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

jwforres avatar Jul 03 '18 17:07 jwforres

@openshift/sig-monitoring

jwforres avatar Jul 03 '18 17:07 jwforres

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).

brancz avatar Jul 03 '18 18:07 brancz

@skynardo How did you deploy your Grafana? there is some changes going on due to the openshift-monitoring changes

mrsiano avatar Jul 04 '18 15:07 mrsiano

I installed grafana via ansible-playbook -vvv /usr/share/ansible/openshift-ansible/playbooks/openshift-grafana/config.yml

skynardo avatar Jul 05 '18 12:07 skynardo

can you try to clone https://github.com/openshift/openshift-ansible and run it from there I'm afraid you use older version

mrsiano avatar Jul 05 '18 15:07 mrsiano

@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 avatar Sep 28 '18 18:09 davivcgarcia

@davivcgarcia grafana ships since 3.11 .. and its version is 5.2.x

mrsiano avatar Oct 02 '18 13:10 mrsiano

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

openshift-bot avatar Dec 31 '18 14:12 openshift-bot

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

openshift-bot avatar Jan 30 '19 16:01 openshift-bot

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 avatar Mar 01 '19 20:03 openshift-bot

@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.

openshift-ci-robot avatar Mar 01 '19 20:03 openshift-ci-robot