Skip to content

Instantly share code, notes, and snippets.

@sansmischevia
Forked from outmost/Graphite on Amazon Linux
Last active August 10, 2017 12:01
Show Gist options
  • Save sansmischevia/5550696 to your computer and use it in GitHub Desktop.
Save sansmischevia/5550696 to your computer and use it in GitHub Desktop.
Sets up graphite, carbon, whisper, and statsd on ami-3275ee5b
# AMI: ami-3275ee5b
# Login: ec2-user
# Apply updates
sudo yum update
# Enable Epel Repo
sudo vim /etc/yum.repos.d/epel.repo.
# Under the section marked [epel], change enabled=0 to enabled=1.
# Install packages
sudo yum install python-devel.x86_64 python-pip.noarch mod_wsgi.x86_64 mod_python.x86_64 python-sqlite2.x86_64 bitmap.x86_64 pycairo.x86_64 python-zope-interface.x86_64 python-simplejson.x86_64 django-tagging.noarch python-pip.noarch python-twisted-web.x86_64 bitmap bitmap-fonts gcc-c++.x86_64 openssl-devel.x86_64 git.x86_64 make.x86_64
sudo yum install python-dev gcc
# Install Graphite etc
sudo pip-python install carbon
sudo pip-python install graphite-web
sudo pip-python install whisper
# Copy example configs to .conf
pushd /opt/graphite/conf
sudo cp carbon.conf.example carbon.conf
sudo cp storage-schemas.conf.example storage-schemas.conf
sudo cp storage-aggregation.conf.example storage-aggregation.conf
sudo cp graphTemplates.conf.example graphTemplates.conf
# Edit storage-schemas.conf
sudo vim storage-schemas.conf
# Create an environment variable in ~/.bashrc
export GRAPHITE_STORAGE_DIR=/mnt
source ~/.bashrc
# create a symlink to link to the ephemeral drive so you don't get charged for all those itty bitty EBS IOPS that whisper loves to do
sudo ln -s /opt/graphite/storage/whisper/ /mnt
# Add the following to top of config settings
### [stats]
### priority = 110
### pattern = ^stats\..*
### retentions = 10s:7d,1m:21d,15m:91d,1h:5y
# Edit storage-aggregation.conf
sudo vim storage-aggregation.conf
# Add the following to config settings
### [counters]
### pattern = stats.counts.*
### xFilesFactor = 0.0
### aggregationMethod = sum
# Copy important file
sudo cp graphite.wsgi.example graphite.wsgi
# Make WSGI Directory
sudo mkdir /etc/httpd/wsgi
# Configure apache2
sudo vim /etc/httpd/conf/httpd.conf
# Add the following at line 223
### Include "/etc/httpd/vhosts/*.conf"
# Create the new directory
sudo mkdir /etc/httpd/vhosts
# Setup Graphite
sudo vim /etc/httpd/vhosts/graphite-vhost.conf
# Add the following to file
# On Red Hat WSGISocketPrefix /etc/httpd/wsgi/
<VirtualHost *:80>
ServerName graphite
DocumentRoot "/opt/graphite/webapp"
ErrorLog /opt/graphite/storage/log/webapp/error.log
CustomLog /opt/graphite/storage/log/webapp/access.log common
# I've found that an equal number of processes & threads tends
# to show the best performance for Graphite (ymmv).
WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
WSGIProcessGroup graphite
WSGIApplicationGroup %{GLOBAL}
WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
# XXX You will need to create this file! There is a graphite.wsgi.example
# file in this directory that you can safely use, just copy it to graphite.wgsi
WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
Alias /content/ /opt/graphite/webapp/content/
<Location "/content/">
SetHandler None
</Location>
# XXX In order for the django admin site media to work you
# must change @CHANGE_ME_TO_DJANGO_ROOT@ to be the path to your django
# installation, which is probably something like:
# /usr/lib/python2.6/site-packages/django
Alias /media/ "@CHANGE_ME_TO_DJANGO_ROOT@/contrib/admin/media/"
<Location "/media/">
SetHandler None
</Location>
# The graphite.wsgi file has to be accessible by apache. It won't
# be visible to clients because of the DocumentRoot though.
<Directory /opt/graphite/conf/>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
# Let the Apache user be the owner of /opt/graphite/
sudo chown -R apache:apache /opt/graphite/
# Restart Apache
sudo /sbin/service httpd restart
# Configure Graphite Web
cd /opt/graphite/webapp/graphite
sudo python manage.py syncdb
# You will be prompted to create an admin user; most people will want to do this.
# Start Carbon, Graphite's data aggregator
cd /opt/graphite/
sudo ./bin/carbon-cache.py start
# Node.js
# Install required packages
sudo yum groupinstall "Development Tools"
# Install Node.js... from yum, silly.
sudo yum install nodejs
sudo yum install npm
# Install StatsD
cd ~
git clone http://github.com/etsy/statsd.git
sudo cp -R statsd /opt/graphite
# Start Node.js/StatsD
cd /opt/graphite/statsd
sudo cp exampleConfig.js config.js
# Edit config.js
sudo vim config.js
# Configure the following
### graphitePort: 2003
### graphiteHost: "127.0.0.1"
### port: 8125
# Start things up with forever:
sudo npm install -g forever
forever start stats.js local.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment