Skip to content

Instantly share code, notes, and snippets.

Forked from rezgaa/
Last active August 29, 2015 14:01
Show Gist options
  • Save slava-vishnyakov/e0bddd2070b5afff2c3c to your computer and use it in GitHub Desktop.
Save slava-vishnyakov/e0bddd2070b5afff2c3c to your computer and use it in GitHub Desktop.
Graphite/Statsd installation

After install run

# start statsd
# start graphite

statsd is on 8125 port graphite is on

# node.js using PPA (for statsd)
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
# Install git to get statsd
sudo apt-get install git
# System level dependencies for Graphite
sudo apt-get install memcached python-dev python-pip sqlite3 libcairo2 \
libcairo2-dev python-cairo pkg-config
# Get latest pip
sudo pip install --upgrade pip
# Install carbon and graphite deps
cat >> /tmp/graphite_reqs.txt << EOF
sudo pip install -r /tmp/graphite_reqs.txt
# Configure carbon
cd /opt/graphite/conf/
sudo cp carbon.conf.example carbon.conf
# Create storage schema and copy it over
# Using the sample as provided in the statsd README
cat >> /tmp/storage-schemas.conf << EOF
# Schema definitions for Whisper files. Entries are scanned in order,
# and first match wins. This file is scanned for changes every 60 seconds.
# [name]
# pattern = regex
# retentions = timePerPoint:timeToStore, timePerPoint:timeToStore, ...
priority = 110
pattern = ^stats\..*
retentions = 10s:6h,1m:7d,10m:1y
sudo cp /tmp/storage-schemas.conf storage-schemas.conf
# Make sure log dir exists for webapp
sudo mkdir -p /opt/graphite/storage/log/webapp
# Copy over the local settings file and initialize database
cd /opt/graphite/webapp/graphite/
sudo cp
sudo python syncdb # Follow the prompts, creating a superuser is optional
# statsd
cd /opt && sudo git clone git://
# StatsD configuration
cat >> /tmp/localConfig.js << EOF
graphitePort: 2003
, graphiteHost: ""
, port: 8125
sudo cp /tmp/localConfig.js /opt/statsd/localConfig.js
cat >> /etc/init/graphite.conf << EOF
description "Graphite Web Daemon"
start on runlevel [2345]
stop on runlevel [!2345]
start on started carbon-cache
stop on stopped carbon-cache
console output
env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
env PYTHONPATH=/opt/graphite/whisper
exec /opt/graphite/bin/ --libs=/opt/graphite/webapp/ /opt/graphite/
cat >> /etc/init/statsd.conf << EOF
# /etc/init/statsd.conf
description "Statsd node.js server"
author "statsd install gist"
start on startup
stop on shutdown
export HOME="/root"
echo $$ > /var/run/
exec sudo -u www-data /usr/bin/nodejs /opt/statsd/stats.js /opt/statsd/localConfig.js >> /var/log/statsd.log 2> /var/log/statsd.error.log
end script
pre-start script
# Date format same as (new Date()).toISOString() for consistency
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/statsd.log
end script
pre-stop script
rm /var/run/
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/statsd.log
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment