<p>In my kubernetes cluster I would like to do monitoring so I installed grafana. </p>

<p>I would like to access the grafana dashboard as <code>http://example.com/monitoring</code>, so I tried to include this in my ingress configuration</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - host: example.com
  http:
    paths:
    - path: /monitoring/(.*)
    backend:
     serviceName: grafana
     servicePort: 80
</code></pre>

<p>The idea is to add other paths there as well, for example <code>/</code> for the website. </p>

<p>I noticed that Grafana redirects <code>http://example.com/monitoring</code> to <code>http://example.com/login</code>. Of course this should have been <code>http://example.com/monitoring/login</code>. What would be the preferred way to fix this. Can it be done with <code>ingress</code> or should I somehow tell Grafana that it is behind a <code>/monitoring</code> path (if possible)?</p>

<p>I've installed grafana using <a href="http://www.allaboutwindowssl.com/2019/03/setup-prometheus-grafana-monitoring-on-azure-kubernetes-cluster-aks/" rel="nofollow noreferrer">this</a> using Helm. </p>

<p>UPDATE: I've modified as suggested below the grafana chart's file values.yaml as follows</p>

<pre><code>grafana.ini:
  server:
    domain: example.com
    root_url: http://example.com/monitoring/
</code></pre>

<p>Now I get:</p>

<p><a href="https://i.stack.imgur.com/D98oE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D98oE.png" alt="enter image description here"></a></p>

<p>And the heml command I use to install grafana: </p>

<pre><code>$&gt; helm install stable/grafana -f values.yaml --set persistence.enabled=true --set persistence.accessModes={ReadWriteOnce} --set persistence.size=8Gi -n grafana
</code></pre>

<p>This is a common problem with services that are behind an HTTP reverse-proxy. Luckily, Grafana offers a way to let it know the context path it is running behind.</p>

<p>In <code>grafana.ini</code> (which is most possibly supplied via a ConfigMap to its Kubernetes deployment), you need to specify the variables like the following:</p>

<pre><code>[server]
domain = example.com
root_url = http://example.com/monitoring/
</code></pre>

<p>See the full documentation here: <a href="https://grafana.com/docs/installation/behind_proxy/" rel="nofollow noreferrer">https://grafana.com/docs/installation/behind_proxy/</a></p>
