New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Graphite backend configuration flag to connect only when there are metrics to send #345
base: master
Are you sure you want to change the base?
Conversation
…nnecting to Graphite when there are not metrics to report.
Interesting patch, do you see any downsides of this just being the normal behaviour? I don't think connecting without any metrics is useful in any situation. So if you can't think of any problems that might arise, I'd say let's make this the default (and only) way of connecting. |
It might be useful to have Statsd connect to Graphite at the configured flush interval to indicate that it's alive & well. This would help distinguish between an absence of application metrics because there are no metrics to report versus no metrics because the Statsd service is down. In my case, the application metrics are not considered mission critical. It's preferable to have Statsd stay quiet when no application metrics need to be pushed to Graphite. I like the idea of making 'quiet=true' the default, and think that it's worth allowing that behavior to be controlled through the quiet configuration option. |
Great idea/patch, thanks! Lunch break braindumpIs it accurate that this functionality requires that deleteIdleStats is Also Object.keys() is O(n) so we should make sure that we aren't making all Taking a step back, would it make sense to just skip the flush function all together if packets received is 0 instead of all of the object.keys checks?Will try to look at more of this on the train ride home this evening. On Tue, Oct 1, 2013 at 2:55 PM, Scott Kidder notifications@github.comwrote:
|
…y when the deleteIdleStats option is enabled. The check for empty stats associative arrays has been made more efficient.
Thanks for the excellent feedback! I've updated the pull-request to perform the 'quiet' operation only when the 'deleteIdleStats' option is enabled. The documentation in the example configuration file has bee updated accordingly. I also modified the check for empty stats associative arrays to be more efficient. |
Thanks for the PR and for updating the PR! Just a heads up. I'm looking into how we can have this PR and #364 coexist. Thinking we move to a graphite connection_type config option so we can set quiet , standard(?) or persistent, and then handle the cases accordingly. Debating about including the current case as the "standard" option to support backwards compatibility. Other option would be to try and do some combination of both automagically. Persisting the connection while regularly flushing metrics, but timeout and don't reconnect if we have a flushInterval that doesn't have metrics to send. Need to think this option through a little more, but like the idea of less config options for everyone :) |
Just added a PR for Persistent connections for high traffic statsd servers. |
That sounds great, I'm looking forward to seeing both features be a part of the Statsd project! |
On second thought, I'm not sure that we should close the connection when the 'quiet' flag is true. In my case I'd like to keep the connection open, if possible, in the interest of efficiency. Does the persistent-connection pull-request handle the case where the connection is left open & idle for an extended period of time (i.e. > 5 minutes)? |
It doesn't timeout an idle connection currently. If the connection has We could modify your PR to close the connection to graphite if it doesn't On Fri, Dec 13, 2013 at 4:21 PM, Scott Kidder notifications@github.comwrote:
|
Awesome, that'd do it. On Fri, Dec 13, 2013 at 1:34 PM, Dan Rowe notifications@github.com wrote:
|
Hey is this synced with the changes in #364 ? Or do we need to sync both up to merge this? |
This feature looks useful to me. I've incorporated urlgrey's work into an up to date fork (I hope that's okay) so that I can get the latest version of statsd along with this feature. I'm willing to help where I can if there's outstanding work required to get this merged into mainline. |
etsy/statsd has not merged this yet. So, I've forked to cPanelScott/statsd and will maintain this fork Merge branch 'master' of https://github.com/urlgrey/statsd Conflicts: backends/graphite.js
The Statsd Graphite backend in the master branch will connect to a Graphite carbon-relay or carbon-cache server even when there are no metrics to report. This can be useful for indicating that the Statsd process is alive and well, and capable of sending metrics if/when they occur; however, the frequency & volume of connections to Graphite could become a problem in some circumstances.
In my case, I have a large number of Amazon EC2 instances that can perform various tasks. Statsd metrics are generated for just one type of task. Using the master branch of Statsd, all EC2 instances connect to the Graphite server at 1 second intervals, usually reporting no metrics. I would prefer to have just the instances handling the task that produces metrics connect to Graphite and report stats. My applications produces several Statsd gauge values while the task is running.
I have added a 'quiet' boolean flag to the Statsd Graphite configuration. It has a default value of 'false', which will cause the Graphite backend to perform identically to the current master branch (always connect to Graphite). If the 'quiet' flag is set to 'true', then a connection will be made to Graphite only when there are metrics to report.
Here's an example Statsd config.js file showing its usage: