Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Regex filter on graphite timer stats #271

Open
wants to merge 4 commits into from

2 participants

@nickj21

Simple (perhaps too simple) hack to cut down number of stats that we weren’t using.

@mrtazz
Owner

Why are you sending the stats to StatsD in the first place? Or is this for built-in stats? In that case a configuration flag to just turn them off might be better?

@nickj21

We only need the upper metric from the timer stats. If there is a way to set this currently that I am completely missing then my bad.

I could change it to three flags for mean, upper and sum and will continue to just filter them on the graphite backend.

@mrtazz
Owner

There is no way to do this right now. However the question if it is possible to restrict the number of default metrics sent has come up quite a bit. So I think we should try to come up with a good solution for this, especially since timers are potentially calculating a lot more metrics now. @draco2003 thoughts about how to make this configurable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 26, 2013
  1. @nickj21

    add timerRegEx param

    nickj21 authored
Commits on Mar 13, 2013
  1. @nickj21

    Merge branch 'master' of github.com:etsy/statsd

    nickj21 authored
    Conflicts:
    	backends/graphite.js
Commits on Mar 14, 2013
  1. @nickj21

    update example

    nickj21 authored
  2. @nickj21

    cleaned up code

    nickj21 authored
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 0 deletions.
  1. +9 −0 backends/graphite.js
  2. +1 −0  exampleConfig.js
View
9 backends/graphite.js
@@ -39,6 +39,8 @@ var timerNamespace = [];
var gaugesNamespace = [];
var setsNamespace = [];
+var timerRegEx;
+
var graphiteStats = {};
var post_stats = function graphite_post_stats(statString) {
@@ -113,6 +115,9 @@ var flush_stats = function graphite_flush(ts, metrics) {
var namespace = timerNamespace.concat(key);
var the_key = namespace.join(".");
for (timer_data_key in timer_data[key]) {
+ if (!timerRegEx.test(timer_data_key)) {
+ continue;
+ }
if (typeof(timer_data[key][timer_data_key]) === 'number') {
statString += the_key + '.' + timer_data_key + ' ' + timer_data[key][timer_data_key] + ts_suffix;
} else {
@@ -179,6 +184,7 @@ exports.init = function graphite_init(startup_time, config, events) {
prefixGauge = config.graphite.prefixGauge;
prefixSet = config.graphite.prefixSet;
legacyNamespace = config.graphite.legacyNamespace;
+ timerRegEx = config.graphite.timerRegEx;
// set defaults for prefixes
globalPrefix = globalPrefix !== undefined ? globalPrefix : "stats";
@@ -188,6 +194,9 @@ exports.init = function graphite_init(startup_time, config, events) {
prefixSet = prefixSet !== undefined ? prefixSet : "sets";
legacyNamespace = legacyNamespace !== undefined ? legacyNamespace : true;
+ // initialize regex
+ timerRegEx = timerRegEx !== undefined ? timerRegEx : ".*";
+ timerRegEx = new RegExp(timerRegEx);
if (legacyNamespace === false) {
if (globalPrefix !== "") {
View
1  exampleConfig.js
@@ -54,6 +54,7 @@ Optional Variables:
prefixTimer: graphite prefix for timer metrics [default: "timers"]
prefixGauge: graphite prefix for gauge metrics [default: "gauges"]
prefixSet: graphite prefix for set metrics [default: "sets"]
+ timerRegEx: will only send metrics that match key [default: ".*"]
repeater: an array of hashes of the for host: and port:
that details other statsd servers to which the received
Something went wrong with that request. Please try again.