Permalink
Browse files

Moved to librato/statsd

  • Loading branch information...
1 parent 5d2f5b0 commit c0b0cf5787a4411b607f4f891a1c7135e6e3c423 Andy Delcambre committed May 3, 2012
Showing with 1 addition and 740 deletions.
  1. +0 −22 LICENSE
  2. +1 −112 README.md
  3. +0 −155 StatsdClient.java
  4. +0 −39 config.js
  5. +0 −5 debian/changelog
  6. +0 −1 debian/compat
  7. +0 −12 debian/control
  8. +0 −22 debian/copyright
  9. +0 −5 debian/rdioConfig.js
  10. +0 −4 debian/rules
  11. +0 −3 debian/scripts/start
  12. +0 −4 debian/statsd.install
  13. +0 −12 debian/statsd.upstart
  14. +0 −6 exampleConfig.js
  15. +0 −96 php-example.php
  16. +0 −91 python_example.py
  17. +0 −151 stats.js
View
22 LICENSE
@@ -1,22 +0,0 @@
- Copyright (c) 2010 Etsy
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation
- files (the "Software"), to deal in the Software without
- restriction, including without limitation the rights to use,
- copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following
- conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
View
113 README.md
@@ -1,113 +1,2 @@
-StatsD
-======
+# Statsd with Librato support has moved to [librato/statsd](http://github.com/librato/statsd)
-A network daemon for aggregating statistics (counters and timers), rolling them up, then sending them to [graphite][graphite].
-
-We ([Etsy][etsy]) [blogged][blog post] about how it works and why we created it.
-
-
-Concepts
---------
-
-* *buckets*
- Each stat is in it's own "bucket". They are not predefined anywhere. Buckets can be named anything that will translate to Graphite (periods make folders, etc)
-
-* *values*
- Each stat will have a value. How it is interpreted depends on modifiers
-
-* *flush*
- After the flush interval timeout (default 10 seconds), stats are munged and sent over to Graphite.
-
-Counting
---------
-
- gorets:1|c
-
-This is a simple counter. Add 1 to the "gorets" bucket. It stays in memory until the flush interval.
-
-
-Timing
-------
-
- glork:320|ms
-
-The glork took 320ms to complete this time. StatsD figures out 90th percentile, average (mean), lower and upper bounds for the flush interval.
-
-Sampling
---------
-
- gorets:1|c|@0.1
-
-Tells StatsD that this counter is being sent sampled every 1/10th of the time.
-
-
-Guts
-----
-
-* [UDP][udp]
- Client libraries use UDP to send information to the StatsD daemon.
-
-* [NodeJS][node]
-* [Graphite][graphite]
-
-Graphite uses "schemas" to define the different round robin datasets it houses (analogous to RRAs in rrdtool). Here's what Etsy is using for the stats databases:
-
- [stats]
- priority = 110
- pattern = ^stats\..*
- retentions = 10:2160,60:10080,600:262974
-
-That translates to:
-
-* 6 hours of 10 second data (what we consider "near-realtime")
-* 1 week of 1 minute data
-* 5 years of 10 minute data
-
-This has been a good tradeoff so far between size-of-file (round robin databases are fixed size) and data we care about. Each "stats" database is about 3.2 megs with these retentions.
-
-Installation and Configuration
-------------------------------
-
- * Install node.js
- * Clone the project
- * Create a config file from exampleConfig.js and put it somewhere
- * Start the Daemon:
-
- node stats.js /path/to/config
-
-
-Inspiration
------------
-
-StatsD was inspired (heavily) by the project (of the same name) at Flickr. Here's a post where Cal Henderson described it in depth:
-[Counting and timing](http://code.flickr.com/blog/2008/10/27/counting-timing/). Cal re-released the code recently: [Perl StatsD](https://github.com/iamcal/Flickr-StatsD)
-
-
-Contribute
----------------------
-
-You're interested in contributing to StatsD? *AWESOME*. Here are the basic steps:
-
-fork StatsD from here: http://github.com/etsy/statsd
-
-1. Clone your fork
-2. Hack away
-3. If you are adding new functionality, document it in the README
-4. If necessary, rebase your commits into logical chunks, without errors
-5. Push the branch up to GitHub
-6. Send a pull request to the etsy/statsd project.
-
-We'll do our best to get your changes in!
-
-[graphite]: http://graphite.wikidot.com
-[etsy]: http://www.etsy.com
-[blog post]: http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/
-[node]: http://nodejs.org
-[udp]: http://enwp.org/udp
-
-
-Contributors
------------------
-
-In lieu of a list of contributors, check out the commit history for the project:
-http://github.com/etsy/statsd/commits/master
View
@@ -1,155 +0,0 @@
-/**
- * StatsdClient.java
- *
- * (C) 2011 Meetup, Inc.
- * Author: Andrew Gwozdziewycz <andrew@meetup.com>, @apgwoz
- *
- *
- *
- * Example usage:
- *
- * StatsdClient client = new StatsdClient("statsd.example.com", 8125);
- * // increment by 1
- * client.increment("foo.bar.baz");
- * // increment by 10
- * client.increment("foo.bar.baz", 10);
- * // sample rate
- * client.increment("foo.bar.baz", 10, .1);
- * // increment multiple keys by 1
- * client.increment("foo.bar.baz", "foo.bar.boo", "foo.baz.bar");
- * // increment multiple keys by 10 -- yeah, it's "backwards"
- * client.increment(10, "foo.bar.baz", "foo.bar.boo", "foo.baz.bar");
- * // multiple keys with a sample rate
- * client.increment(10, .1, "foo.bar.baz", "foo.bar.boo", "foo.baz.bar");
- *
- * Note: For best results, and greater availability, you'll probably want to
- * create a wrapper class which creates a static client and proxies to it.
- *
- * You know... the "Java way."
- */
-
-import java.util.Random;
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-
-import org.apache.log4j.Logger;
-
-public class StatsdClient {
- private static Random RNG = new Random();
- private static Logger log = Logger.getLogger(StatsdClient.class.getName());
-
- private InetAddress _host;
- private int _port;
-
- private DatagramSocket _sock;
-
- public StatsdClient(String host, int port) throws UnknownHostException, SocketException {
- this(InetAddress.getByName(host), port);
- }
-
- public StatsdClient(InetAddress host, int port) throws SocketException {
- _host = host;
- _port = port;
- _sock = new DatagramSocket();
- }
-
- public boolean timing(String key, int value) {
- return timing(key, value, 1.0);
- }
-
- public boolean timing(String key, int value, double sampleRate) {
- return send(sampleRate, String.format("%s:%d|ms", key, value));
- }
-
- public boolean decrement(String key) {
- return increment(key, -1, 1.0);
- }
-
- public boolean decrement(String key, int magnitude) {
- return decrement(key, magnitude, 1.0);
- }
-
- public boolean decrement(String key, int magnitude, double sampleRate) {
- magnitude = magnitude < 0 ? magnitude: -magnitude;
- return increment(key, magnitude, sampleRate);
- }
-
- public boolean decrement(String... keys) {
- return increment(-1, 1.0, keys);
- }
-
- public boolean decrement(int magnitude, String... keys) {
- magnitude = magnitude < 0 ? magnitude: -magnitude;
- return increment(magnitude, 1.0, keys);
- }
-
- public boolean decrement(int magnitude, double sampleRate, String... keys) {
- magnitude = magnitude < 0 ? magnitude: -magnitude;
- return increment(magnitude, sampleRate, keys);
- }
-
- public boolean increment(String key) {
- return increment(key, 1, 1.0);
- }
-
- public boolean increment(String key, int magnitude) {
- return increment(key, magnitude, 1.0);
- }
-
- public boolean increment(String key, int magnitude, double sampleRate) {
- String stat = String.format("%s:%s|c", key, magnitude);
- return send(stat, sampleRate);
- }
-
- public boolean increment(int magnitude, double sampleRate, String... keys) {
- String[] stats = new String[keys.length];
- for (int i = 0; i < keys.length; i++) {
- stats[i] = String.format("%s:%s|c", keys[i], magnitude);
- }
- return send(sampleRate, stats);
- }
-
- private boolean send(String stat, double sampleRate) {
- return send(sampleRate, stat);
- }
-
- private boolean send(double sampleRate, String... stats) {
-
- boolean retval = false; // didn't send anything
- if (sampleRate < 1.0) {
- for (String stat : stats) {
- if (RNG.nextDouble() <= sampleRate) {
- stat = String.format("%s|@%f", stat, sampleRate);
- if (doSend(stat)) {
- retval = true;
- }
- }
- }
- }
- else {
- for (String stat : stats) {
- if (doSend(stat)) {
- retval = true;
- }
- }
- }
-
- return retval;
- }
-
- private boolean doSend(String stat) {
- try {
- byte[] data = stat.getBytes();
- _sock.send(new DatagramPacket(data, data.length, _host, _port));
- return true;
- }
- catch (IOException e) {
- log.error(String.format("Could not send stat %s to host %s:%d", stat, _host, _port), e);
- }
- return false;
- }
-}
View
@@ -1,39 +0,0 @@
-var fs = require('fs')
- , sys = require('sys')
-
-var Configurator = function (file) {
-
- var self = this;
- var config = {};
- var oldConfig = {};
-
- this.updateConfig = function () {
- sys.log('reading config file: ' + file);
-
- fs.readFile(file, function (err, data) {
- if (err) { throw err; }
- old_config = self.config;
-
- self.config = process.compile('config = ' + data, file);
- self.emit('configChanged', self.config);
- });
- };
-
- this.updateConfig();
-
- fs.watchFile(file, function (curr, prev) {
- if (curr.ino != prev.ino) { self.updateConfig(); }
- });
-};
-
-sys.inherits(Configurator, process.EventEmitter);
-
-exports.Configurator = Configurator;
-
-exports.configFile = function(file, callbackFunc) {
- var config = new Configurator(file);
- config.on('configChanged', function() {
- callbackFunc(config.config, config.oldConfig);
- });
-};
-
View
@@ -1,5 +0,0 @@
-statsd (0.0.1) unstable; urgency=low
-
- * Initial rdio packaging.
-
- -- Manish Singh <manish@rd.io> Mon, 21 Mar 2011 23:04:52 -0700
View
@@ -1 +0,0 @@
-7
View
@@ -1,12 +0,0 @@
-Source: statsd
-Section: devel
-Priority: optional
-Maintainer: Manish Singh <manish@rd.io>
-Standards-Version: 3.9.1
-
-Package: statsd
-Architecture: all
-Depends: nodejs
-Description: Stats aggregation daemon
- A network daemon for aggregating statistics (counters and timers),
- rolling them up, then sending them to graphite.
View
@@ -1,22 +0,0 @@
- Copyright (c) 2010 Etsy
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation
- files (the "Software"), to deal in the Software without
- restriction, including without limitation the rights to use,
- copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following
- conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,5 +0,0 @@
-{
- graphitePort: 2003
-, graphiteHost: "localhost"
-, port: 8125
-}
View
@@ -1,4 +0,0 @@
-#!/usr/bin/make -f
-
-%:
- dh $@
View
@@ -1,3 +0,0 @@
-#!/bin/sh
-# Called by Upstart, /etc/init/statsd.conf
-/usr/bin/nodejs /usr/share/statsd/stats.js /etc/statsd/rdioConfig.js 2>&1 >> /tmp/statsd.log
View
@@ -1,4 +0,0 @@
-stats.js /usr/share/statsd
-config.js /usr/share/statsd
-debian/rdioConfig.js /etc/statsd
-debian/scripts/start /usr/share/statsd/scripts
Oops, something went wrong.

0 comments on commit c0b0cf5

Please sign in to comment.