Skip to content

Instantly share code, notes, and snippets.

@foertel
Last active June 28, 2017 17:44
Show Gist options
  • Save foertel/a04c61e98609642457b0 to your computer and use it in GitHub Desktop.
Save foertel/a04c61e98609642457b0 to your computer and use it in GitHub Desktop.
How to setup graphite with grafana in Ubuntu 14.04
#!/bin/bash
echo '
###
# Welcome to graphite creator
###
!!!
! THIS WILL REMOVE /var/www - MAKE SURE YOU WANT TO DO THIS!
!!!
You will need two domains mapped to this server. The first one runs graphite, the second one the grafana web-frontend.
Please enter just the domain, without http:// or trailing slash. (grafana.example.org)
domain of graphite: '
read graphite_url
echo 'domain of grafana: '
read grafana_url
apt-get update && sudo apt-get dist-upgrade -y
apt-get install graphite-carbon graphite-web apache2 libapache2-mod-wsgi curl
echo 'CARBON_CACHE_ENABLED=true' >> /etc/default/graphite-carbon
service carbon-cache start
graphite-manage syncdb
chown _graphite:_graphite /var/lib/graphite/graphite.db
tee /etc/apache2/sites-available/graphite-web.conf <<DELIM
<VirtualHost *:80>
Header set Access-Control-Allow-Origin "http://$grafana_url"
Header set Access-Control-Allow-Methods "GET, OPTIONS"
Header set Access-Control-Allow-Headers "origin, authorization, accept"
ServerName $graphite_url
DELIM
grep -E "^\s" /usr/share/graphite-web/apache2-graphite.conf >> /etc/apache2/sites-available/graphite-web.conf
echo '</VirtualHost>' >> /etc/apache2/sites-available/graphite-web.conf
a2ensite graphite-web
a2enmod headers
service apache2 restart
rm -rf /var/www
curl http://grafanarel.s3.amazonaws.com/grafana-1.8.1.tar.gz | tar xvzf - --strip-components=1 -C /var/www
cp /var/www/config.sample.js /var/www/config.js
sed -i s/my.graphite.server.com/$graphite_url/g config.js
echo '
All done! Happy graphing ... '
@jasonrogena
Copy link

Enable the Apache2 Headers module before a2ensite graphite-web:

a2enmod headers
a2ensite graphite-web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment