From 3be3807eea912cdba897b88bc8ba3ad42b4db1b5 Mon Sep 17 00:00:00 2001
From: "James E. Blair" <jeblair@openstack.org>
Date: Fri, 28 Dec 2012 15:52:08 -0800
Subject: [PATCH] Add statsd compatible schema to graphite.

Most of this is from the statsd README.

Change-Id: I22e4619375c10de2cb010b06071ed3b473197e92
Reviewed-on: https://review.openstack.org/18737
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
---
 modules/graphite/manifests/init.pp            |  6 +++++
 .../templates/storage-aggregation.conf.erb    | 23 +++++++++++++++++++
 .../templates/storage-schemas.conf.erb        |  8 +++++--
 3 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 modules/graphite/templates/storage-aggregation.conf.erb

diff --git a/modules/graphite/manifests/init.pp b/modules/graphite/manifests/init.pp
index 29687f154d..5ac0e5a60c 100644
--- a/modules/graphite/manifests/init.pp
+++ b/modules/graphite/manifests/init.pp
@@ -160,6 +160,12 @@ class graphite(
     require => File['/etc/graphite'],
   }
 
+  file { '/etc/graphite/storage-aggregation.conf':
+    mode    => '0444',
+    content => template('graphite/storage-aggregation.conf.erb'),
+    require => File['/etc/graphite'],
+  }
+
   file { '/usr/local/lib/python2.7/dist-packages/graphite/local_settings.py':
     mode    => '0444',
     content => template('graphite/local_settings.py.erb'),
diff --git a/modules/graphite/templates/storage-aggregation.conf.erb b/modules/graphite/templates/storage-aggregation.conf.erb
new file mode 100644
index 0000000000..ab75e85e1b
--- /dev/null
+++ b/modules/graphite/templates/storage-aggregation.conf.erb
@@ -0,0 +1,23 @@
+[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.3
+aggregationMethod = average
+
+[stats_counts]
+pattern = ^stats_counts\..*
+aggregationMethod = sum
diff --git a/modules/graphite/templates/storage-schemas.conf.erb b/modules/graphite/templates/storage-schemas.conf.erb
index d184c620d0..f0f1f6ad8b 100644
--- a/modules/graphite/templates/storage-schemas.conf.erb
+++ b/modules/graphite/templates/storage-schemas.conf.erb
@@ -11,6 +11,10 @@
 pattern = ^carbon\.
 retentions = 60:90d
 
-[default_1min_for_3years]
+[default]
 pattern = .*
-retentions = 60s:3y
+retentions = 60:90d
+
+[stats]
+pattern = ^stats.*
+retentions = 10:2160,60:10080,600:262974