<p>Hi I am trying to add built-in OpenShift(v4.8) prometheus data source to a local grafana server. I have given basic auth with username and password and as of now I have enabled skip tls verify also. Still I'm getting this error</p>
<p><a href="https://i.stack.imgur.com/xvKu8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xvKu8.png" alt="error" /></a></p>
<p>Prometheus URL = <code>https://prometheus-k8s-openshift-monitoring.apps.xxxx.xxxx.xxxx.com</code></p>
<p>this is the grafana log</p>
<pre><code>
logger=tsdb.prometheus t=2022-04-12T17:35:23.47+0530 lvl=eror msg=&quot;Instant query failed&quot; query=1+1 err=&quot;client_error: client error: 403&quot;
logger=context t=2022-04-12T17:35:23.47+0530 lvl=info msg=&quot;Request Completed&quot; method=POST path=/api/ds/query status=400 remote_addr=10.100.95.27 time_ms=36 size=65 referer=https://grafana.xxxx.xxxx.com/datasources/edit/6TjZwT87k
</code></pre>

<p>You cannot authenticate to the OpenShift prometheus instance using basic authentication. You need to authenticate using a bearer token, e.g. one obtained from <code>oc whoami -t</code>:</p>
<pre><code>curl -H &quot;Authorization: Bearer $(oc whoami -t)&quot; -k https://prometheus-k8s-openshift-monitoring.apps.xxxx.xxxx.xxxx.com/
</code></pre>
<p>Or from a <code>ServiceAccount</code> with appropriate privileges:</p>
<pre><code>secret=$(oc -n openshift-monitoring get sa prometheus-k8s -o jsonpath='{.secrets[1].name}')
token=$(oc -n openshift-monitoring get secret $secret -o jsonpath='{.data.token}' | base64 -d)
curl -H &quot;Authorization: Bearer $token&quot; -k https://prometheus-k8s-openshift-monitoring.apps.xxxx.xxxx.xxxx.com/

</code></pre>
