Last active
June 28, 2017 17:44
-
-
Save foertel/a04c61e98609642457b0 to your computer and use it in GitHub Desktop.
How to setup graphite with grafana in Ubuntu 14.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 ... ' |
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
line 20 need to check sudo permission : http://superuser.com/questions/195781/sudo-is-there-a-command-to-check-if-i-have-sudo-and-or-how-much-time-is-left
line 40 need a 'mkdir -p /var/www' as it would fail otherwise (ubuntu 14.04)
line 42 need a cd /var/www before being executed, as it wont found file otherwise.