Skip to content

Instantly share code, notes, and snippets.

@jokull
Created August 9, 2012 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jokull/3303572 to your computer and use it in GitHub Desktop.
Save jokull/3303572 to your computer and use it in GitHub Desktop.
PVG Graphite Server Configuration

Users

graphite is the user that runs all graphite related services.

Graphite

Web Interface

NGiNX listens on TCP port 80

  • NGiNX conf: /etc/nginx/sites-enabled/graphite
  • init script: /etc/init/graphite-uwsgi.conf

Backend

The graphite stats backend consists of many components to shard, aggregate and relay. For now we only need carbon-cache to receive, and selectively store.

Config files of interest:

  • /opt/graphite/conf/storage-schemas.conf for retention of datapoints
  • /opt/graphite/conf/storage-aggregation.conf for aggregating mins, maxes and averages

Structuring and Collecting

Graphite assumes a keyspace seperated by .. Graphite makes it easy to collect different datasets with regex patterns

# storage-aggregation.conf

[signups]
pattern = \.signup$
aggregationMethod = sum

Where is data stored?

Graphite has its own storage engine that uses a filesystem hierarchy to store data. Simply remove files or folders to reset or remove useless data.

Location: /opt/graphite/storage/whisper

statsite

To get data to the server from other servers we use a program called statsite. It is interface between other servers and clients to Graphite.

statsite listens on UDP port 8126. There are many server implimentations of statsite, all of them made to work with Graphite. The first one was from Etsy written in node.js. I went for a <www.github.com/kiip/statsite>, a well written Python server. It is not super fast, but will do for now. It has been superceded by a C implimentation of it which I had trouble compiling on Ubuntu but that’ll be the go to solution if we hit scaling troubles with statsite.

See init script /etc/init/statsite.conf

Datatypes

statsite and Graphite support three different datatypes: counters, gauges and timers. Example client code:

# install with pip install statsd
import statsd
c = statsd.StatsClient('graphite')  # graphite is the host
c.incr('bar')  # Increment counter 'bar'

To use timers and gauges with python-statsd: http://python-statsd.readthedocs.org/en/latest/usage.html

TODO

Setup Graphine dashboard interface.

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