Permalink
Browse files

Graphite manifest, files, and templates.

  • Loading branch information...
sodabrew committed Sep 11, 2012
1 parent c18cad1 commit e8742978f749c7de4909c06ee085d77f24d6256b
View
@@ -0,0 +1,43 @@
+[cache]
+GRAPHITE_ROOT = /opt/graphite
+USER = graphite
+MAX_CACHE_SIZE = inf
+MAX_UPDATES_PER_SECOND = 1000
+MAX_CREATES_PER_MINUTE = 50
+LINE_RECEIVER_INTERFACE = 0.0.0.0
+LINE_RECEIVER_PORT = 2003
+ENABLE_UDP_LISTENER = True
+UDP_RECEIVER_INTERFACE = 0.0.0.0
+UDP_RECEIVER_PORT = 2003
+PICKLE_RECEIVER_INTERFACE = 0.0.0.0
+PICKLE_RECEIVER_PORT = 2004
+USE_INSECURE_UNPICKLER = False
+CACHE_QUERY_INTERFACE = 0.0.0.0
+CACHE_QUERY_PORT = 7002
+USE_FLOW_CONTROL = True
+LOG_UPDATES = False
+WHISPER_AUTOFLUSH = False
+
+[relay]
+LINE_RECEIVER_INTERFACE = 0.0.0.0
+LINE_RECEIVER_PORT = 2013
+PICKLE_RECEIVER_INTERFACE = 0.0.0.0
+PICKLE_RECEIVER_PORT = 2014
+RELAY_METHOD = rules
+REPLICATION_FACTOR = 1
+DESTINATIONS = 127.0.0.1:2004
+MAX_DATAPOINTS_PER_MESSAGE = 500
+MAX_QUEUE_SIZE = 10000
+USE_FLOW_CONTROL = True
+
+[aggregator]
+LINE_RECEIVER_INTERFACE = 0.0.0.0
+LINE_RECEIVER_PORT = 2023
+PICKLE_RECEIVER_INTERFACE = 0.0.0.0
+PICKLE_RECEIVER_PORT = 2024
+DESTINATIONS = 127.0.0.1:2004
+REPLICATION_FACTOR = 1
+MAX_QUEUE_SIZE = 10000
+USE_FLOW_CONTROL = True
+MAX_DATAPOINTS_PER_MESSAGE = 500
+MAX_AGGREGATION_INTERVALS = 10
@@ -0,0 +1,15 @@
+import os, sys
+sys.path.append('/opt/graphite/webapp')
+os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'
+
+import django.core.handlers.wsgi
+application = django.core.handlers.wsgi.WSGIHandler()
+
+# READ THIS
+# Initializing the search index can be very expensive, please include
+# the WSGIScriptImport directive pointing to this script in your vhost
+# config to ensure the index is preloaded before any requests are handed
+# to the process.
+from graphite.logger import log
+log.info('graphite.wsgi - pid %d - reloading search index' % os.getpid())
+import graphite.metrics.search
@@ -0,0 +1,6 @@
+DATABASES = {
+ 'default': {
+ 'NAME': '/opt/graphite/storage/graphite.db',
+ 'ENGINE': 'django.db.backends.sqlite3',
+ }
+}
@@ -0,0 +1,32 @@
+# Aggregation methods for whisper files. Entries are scanned in order,
+# and first match wins. This file is scanned for changes every 60 seconds
+#
+# [name]
+# pattern = <regex>
+# xFilesFactor = <float between 0 and 1>
+# aggregationMethod = <average|sum|last|max|min>
+#
+# name: Arbitrary unique name for the rule
+# pattern: Regex pattern to match against the metric name
+# xFilesFactor: Ratio of valid data points required for aggregation to the next retention to occur
+# aggregationMethod: function to apply to data points for aggregation
+#
+[min]
+pattern = \.min$
+xFilesFactor = 0.1
+aggregationMethod = min
+
+[max]
+pattern = \.max$
+xFilesFactor = 0.1
+aggregationMethod = max
+
+[sum]
+pattern = \.count$
+xFilesFactor = 0
+aggregationMethod = sum
+
+[default_average]
+pattern = .*
+xFilesFactor = 0.5
+aggregationMethod = average
@@ -0,0 +1,3 @@
+[default_10s_for_1day]
+pattern = .*
+retentions = 10s:1d,1m:7d,10m:180d
View
@@ -0,0 +1,157 @@
+class graphite::base {
+ include memcache::base
+ include apache2::stock_apache
+ include daemontools
+
+ # Packages the host needs:
+ package { [python-django, python-cairo, python-memcache, python-pip,
+ python-sqlite, python-django-tagging, python-dev]:
+ ensure => installed,
+ }
+
+ # Packages containing Apache mods
+ package { [libapache2-mod-wsgi]:
+ ensure => installed,
+ require => Package['apache2'],
+ }
+
+ # Enable the Apache mods
+ apache2::stock_apache_mods::loadmod { 'mod_wsgi':
+ modname => 'wsgi',
+ require => Package['libapache2-mod-wsgi'],
+ }
+
+ # WSGI unix sockets directory
+ file { '/var/run/apache2/wsgi':
+ ensure => directory,
+ require => Package['libapache2-mod-wsgi'],
+ }
+
+ # This forces apache2::stock_apache to turn on its own default config,
+ # which gets rid of the useless "It Works!" default.
+ apache2::stock_apache::site_enable { 'default':
+ }
+
+ # Install the Graphite python packages using pip
+ package { 'carbon':
+ ensure => $::graphite_version,
+ provider => pip,
+ require => Package['python-pip'],
+ } ->
+ package { 'whisper':
+ ensure => $::graphite_version,
+ provider => pip,
+ require => Package['python-pip'],
+ } ->
+ package { 'graphite-web':
+ ensure => $::graphite_version,
+ provider => pip,
+ require => Package['python-pip'],
+ notify => Service['apache2'],
+ }
+
+ file { '/var/log/carbon-aggregator':
+ ensure => directory,
+ } ->
+ helpers::daemontools::svcadd { 'carbon-aggregator':
+ svcstart => template('graphite/carbon-aggregator.run.erb'),
+ require => Package['carbon'],
+ logpath => '/var/log/carbon-aggregator',
+ }
+
+ file { '/var/log/carbon-cache':
+ ensure => directory,
+ } ->
+ helpers::daemontools::svcadd { 'carbon-cache':
+ svcstart => template('graphite/carbon-cache.run.erb'),
+ require => Package['carbon'],
+ logpath => '/var/log/carbon-cache',
+ }
+
+ file { '/opt/graphite/conf/carbon.conf':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ source => 'puppet:///modules/graphite/carbon.conf',
+ require => Package['carbon'],
+ }
+
+ file { '/opt/graphite/conf/storage-schemas.conf':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ source => 'puppet:///modules/graphite/storage-schemas.conf',
+ require => Package['whisper'],
+ }
+
+ file { '/opt/graphite/conf/storage-aggregation.conf':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ source => 'puppet:///modules/graphite/storage-aggregation.conf',
+ require => Package['whisper'],
+ }
+
+ file { '/opt/graphite/conf/graphite.wsgi':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ source => 'puppet:///modules/graphite/graphite.wsgi',
+ require => Package['graphite-web'],
+ }
+
+ file { '/opt/graphite/webapp/graphite/local_settings.py':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ source => 'puppet:///modules/graphite/local_settings.py',
+ require => Package['graphite-web'],
+ }
+
+ file { '/etc/apache2/sites-enabled/graphite.conf':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ content => template('graphite/graphite.conf.erb'),
+ require => Package['apache2'],
+ }
+
+ # Graphite storage dirs
+ group { 'graphite':
+ ensure => present,
+ gid => '2003',
+ } ~>
+ user { 'graphite':
+ ensure => present,
+ comment => 'Graphite user',
+ gid => 'graphite',
+ uid => '2003',
+ shell => '/usr/bin/false',
+ } ~>
+ file { '/opt/graphite/storage':
+ ensure => directory,
+ owner => 'graphite',
+ group => 'www-data',
+ mode => '0664',
+ recurse => true,
+ } ~>
+ exec { 'create_graphite_db':
+ user => 'graphite',
+ cwd => '/opt/graphite/webapp/graphite',
+ path => ['/usr/bin/', '/usr/local/bin'],
+ command => 'python manage.py syncdb --noinput',
+ creates => '/opt/graphite/storage/graphite.db',
+ } ->
+ file { '/opt/graphite/storage/graphite.db':
+ owner => 'graphite',
+ group => 'www-data',
+ mode => '0664',
+ }
+
+}
@@ -0,0 +1,3 @@
+#Just import all .pp files within this directory
+#import "*.pp"
+
@@ -0,0 +1,4 @@
+#!/bin/sh
+echo "Starting carbon-aggregator..."
+cd /opt/graphite
+exec setuidgid graphite ./bin/carbon-aggregator.py --debug start 2>&1
@@ -0,0 +1,4 @@
+#!/bin/sh
+echo "Starting carbon-cache..."
+cd /opt/graphite
+exec setuidgid graphite ./bin/carbon-cache.py --debug start 2>&1
@@ -0,0 +1,34 @@
+WSGISocketPrefix /var/run/apache2/wsgi
+
+<VirtualHost *:80>
+ ServerName <%= fqdn %>
+ DocumentRoot "/opt/graphite/webapp"
+ ErrorLog /opt/graphite/storage/log/webapp/error.log
+ CustomLog /opt/graphite/storage/log/webapp/access.log common
+
+ # Performance is good with equal threads-per-process.
+ 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}
+
+ WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
+
+ Alias /content/ /opt/graphite/webapp/content/
+ <Location "/content/">
+ SetHandler None
+ </Location>
+
+ Alias /media/ "/usr/share/pyshared/django/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>

0 comments on commit e874297

Please sign in to comment.