Is this a request for help?:
Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT
Version of Helm and Kubernetes: helm version v2.12.3, kubernetes version 1.11.7-gke.12
Which chart: grafana
What happened:
When deploying the grafana helm chart under the path of a domain I get this error in the browser:
If you're seeing this Grafana has failed to load its application files
1. This could be caused by your reverse proxy settings.
2. If you host grafana under subpath make sure your grafana.ini root_url setting includes subpath
3. If you have a local dev build make sure you build frontend using: npm run dev, npm run watch, or npm run build
4. Sometimes restarting grafana-server can help
This is despite following the directions here: http://docs.grafana.org/installation/behind_proxy/
Here are relevant portions of my values.yaml file with my domain redacted:
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
labels: {}
path: /grafana/
server:
domain: <mydomain>
root_url: https://<mydomain>/grafana/
What you expected to happen:
I would expect grafana to be available at https://mydomain/grafana/ but instead I get the error message.
How to reproduce it (as minimally and precisely as possible): Deploy the helm chart with the above modifications to the values.yaml file.
Anything else we need to know:
depending on your reverse proxy, you may be missing some ingress annotations.
two i have used in the past to be able to setup grafana under a url with a path are:
ingress.kubernetes.io/rewrite-target: /
ingress.kubernetes.io/force-ssl-redirect: "true"
hope this helps!
Yes @maorfr, adding this annotation to my ingress seems to have fixed it!
nginx.ingress.kubernetes.io/rewrite-target: "/"
Thanks!
you are most welcome!
would you like to contribute to the chart? :)
if so, tell me what you think of this idea:
i bet some other people have struggled with this in the past (i know i am one of them).
maybe it will be helpful if this was documented in the chart. for example, this can be commented out along with the other ingress annotations and with a short description of when should people consider to un-comment this line?
would you like to get involved? ;)
Yes, I would like to get involved more in maintaining a few charts. I'm out this week but I can make a PR next week.
Future versions of Grafana will "just work" without this requirement for a rewrite rule. https://github.com/grafana/grafana/pull/17048
I face the same issue, added the annotations above and still receive the error page
I am facing the same issue and still get the error page. @jaredbischof Could you please share more information about your configuration?
Same issue is with me as well
Hi @tomerleib @naturalbeau @hanzala1234, did you guys add the root_url to the grafana config like this?
grafana.ini:
server:
root_url: "%(protocol)s://%(domain)s:%(http_port)s/grafana"
I realize now that it may not have been clear where that second snippet in my original post was supposed to go.
For anyone using ingress > 0.22, the proper ingress annotations is the following:
path: /grafana(/|$)(.*)
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
As mentionned here:
https://kubernetes.github.io/ingress-nginx/examples/rewrite/#rewrite-target
Starting in Version 0.22.0, ingress definitions using the annotation nginx.ingress.kubernetes.io/rewrite-target are not backwards compatible with previous versions. In Version 0.22.0 and beyond, any substrings within the request URI that need to be passed to the rewritten path must explicitly be defined in a capture group.
With grafana 6.3 this rewrite target should not be needed anymore: https://github.com/grafana/grafana/pull/17048
@IppX Thank you! Of all the documentation out there, your comment is the first I found with the proper Ingress rule for grafana.
In 2020, this solution still works!! Thank you.
Example, how my config is:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: ingress-grafana
namespace: prometheus
spec:
rules:
- host: aks-mycompany.com.br
http:
paths:
- path: /monitoring(/|$)(.*)
backend:
serviceName: grafana
servicePort: 80
@reinaldo-pinto could you please post your grafana.ini configuration? I am not able to deploy grafana even on the main url.
Most helpful comment
For anyone using ingress > 0.22, the proper ingress annotations is the following:
As mentionned here:
https://kubernetes.github.io/ingress-nginx/examples/rewrite/#rewrite-target
With grafana 6.3 this rewrite target should not be needed anymore: https://github.com/grafana/grafana/pull/17048