Grafana is a fantastic dashboard/graph tool for Graphite, InfluxDB & OpenTSDB.

Everyone knows that the standard configuration of graphite is terrible and well...really ugly. I used Grafana 2.0.2 in this tutorial. If you want to run Grafana in a subdirectory you have to change the Grafana configuration and add a apache configuration.

Open the file vi /etc/grafana/grafana.ini and go to the following line:

;root_url = %(protocol)s://%(domain)s:%(http_port)s/

Remove the comma in the beginning of the line and add after the backslash the name of the subdirectory. e.g.:

root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/

Restart the grafana server:

/etc/init.d/grafana-server restart

The direct access via port number 3000 is now no longer possible. You get a page, but because of our change of the root_url the base_path is wrong.

For the apache configuration go to: /etc/apache2/sites-available Create a new file (like grafana.conf) with the following content:

    ProxyPreserveHost On
    ProxyPass /grafana
    ProxyPassReverse /grafana

Replace "grafana" with the name of your subdirectory.

For those who want to run grafana with a subdomain can ignore the changes I made in the grafana.ini and just create a grafana.conf file in /etc/apache2/sites-available with the following content

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

Don't forget to change the Servername!

The apache modules proxy and proxy_http have to be enabled so that this configuration can work.

a2enmod proxy_http
a2enmod proxy

Enable the grafana.conf

a2ensite Apache grafana.conf

and restart/reload apache

/etc/init.d/apache2 reload

Questions are welcome!

Add a comment

Next Post Previous Post