<p>I have installed below kube-prometheus-stack and getting an error when trying to access Grafana dashboard using it's own Ingress URL. I believe I am missing something silly here but unable to find any clues. I have looked at <a href="https://stackoverflow.com/questions/57170106/trying-to-rewrite-url-for-grafana-with-ingress">similar post</a> here and others as well.</p>
<p>Chart: kube-prometheus-stack-9.4.5
App Version: 0.38.1</p>
<p>When I navigate to <a href="https://myorg.grafanatest.com" rel="nofollow noreferrer">https://myorg.grafanatest.com</a> URL, I get redirected to <a href="https://myorg.grafanatest.com/login" rel="nofollow noreferrer">https://myorg.grafanatest.com/login</a> with following message.</p>
<p><a href="https://i.stack.imgur.com/BRboa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BRboa.png" alt="enter image description here" /></a></p>
<p>Changes made to grafana/values.yaml:</p>
<pre><code>grafana.ini:
  server:
  # The full public facing url you use in browser, used for redirects and emails
  root_url: https://myorg.grafanatest.com
</code></pre>
<p>Helm command used to install Prometheus-Grafana operator after making above changes.</p>
<pre><code> helm install  pg kube-prometheus-stack/ -n monitoring
</code></pre>
<p>I see below settings in grafana.ini file inside Grafana pod.</p>
<pre><code>[analytics]
check_for_updates = true
[grafana_net]
url = https://grafana.net
[log]
mode = console
[paths]
data = /var/lib/grafana/data
logs = /var/log/grafana
plugins = /var/lib/grafana/plugins
provisioning = /etc/grafana/provisioning
[server]
root_url = https://myorg.grafanatest.com/
</code></pre>

<p>Posting a solution here as it's working now. Followed steps as gumelaragum mentioned above to create values.yaml and updated below values in that, and passed that values.yaml to helm install step. Not sure why it didn't work without enabling serve_from_sub_path, but it's ok as it's working now. Note that I didn't enable Ingress section since I have already created Ingress route outside the installation process.</p>
<p><code>helm show values prometheus-com/kube-prometheus-stack &gt; custom-values.yaml</code></p>
<p>Then install by changing below values in custom-values.yaml. Change namespace as needed.</p>
<p><code>helm -n monitoring install -f ./custom-values.yaml pg prometheus-com/kube-prometheus-stack</code></p>
<pre><code>grafana:
  enabled: true
  namespaceOverride: &quot;&quot;
  # set pspUseAppArmor to false to fix Grafana pod Init errors
  rbac:
    pspUseAppArmor: false
  grafana.ini:
    server:
      domain: mysb.grafanasite.com
      #root_url: &quot;%(protocol)s://%(domain)s/&quot;
      root_url: https://mysb.grafanasite.com/grafana/
      serve_from_sub_path: true

  ## Deploy default dashboards.
  ##
  defaultDashboardsEnabled: true

  adminPassword: prom-operator

  ingress:
    ## If true, Grafana Ingress will be created
    ##
    enabled: false

    ## Annotations for Grafana Ingress
    ##
    annotations: {}
      # kubernetes.io/ingress.class: nginx
      # kubernetes.io/tls-acme: &quot;true&quot;

    ## Labels to be added to the Ingress
    ##
    labels: {}

    ## Hostnames.
    ## Must be provided if Ingress is enable.
    ##
    # hosts:
    #   - grafana.domain.com
    hosts:
      - mysb.grafanasite.com

    ## Path for grafana ingress
    path: /grafana/
</code></pre>
<p>I see same values being reflected in grafana.ini file inside Grafana container mount path(/etc/grafana/grafana.ini).</p>
<pre><code>[analytics]
check_for_updates = true
[grafana_net]
url = https://grafana.net
[log]
mode = console
[paths]
data = /var/lib/grafana/data
logs = /var/log/grafana
plugins = /var/lib/grafana/plugins
provisioning = /etc/grafana/provisioning
[server]
domain = mysb.grafanasite.com
root_url = https://mysb.grafanasite.com/grafana/
serve_from_sub_path = true
</code></pre>
