Anomaly » Uncategorized https://anomaly.io Just another WordPress site Fri, 21 Dec 2018 19:16:49 +0000 en-US hourly 1 http://wordpress.org/?v=4.2.2 StatsD Installation and Configurationhttps://anomaly.io/statsd-install-and-config/ https://anomaly.io/statsd-install-and-config/#comments Mon, 27 Apr 2015 11:46:19 +0000 http://anomalyts.io/?p=2148 The post StatsD Installation and Configuration appeared first on Anomaly.

]]>

StatsD install
StatsD is a statistic aggregation tool written in node.js. It is a simple, yet powerful, tool for counting and timing when monitoring. StatsD makes it very easy to monitor your own code.

Why StatsD?

In the DevOps world, it is crucial to record and monitor everything. Network, machine, and third party apps can be monitored using CollectD.

But how do you monitor your own code? That is where StatsD comes in. It helps you monitor your code in an easy and flexible way. When you want to track something in your code, just call StatsD: it will produce metrics for you.

Requirements

Node.js must be installed.

On Debian / Ubuntu:

curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
apt-get install -y nodejs

On CentOS / Fedora:

curl -sL https://rpm.nodesource.com/setup | bash -
yum install -y nodejs

On Mac OS X with brew:

brew install nodejs

Download node.js install for Windows and MacOSX.

Install StatsD

First download StatsD from GitHub.
Then create a configuration file

$ git clone https://github.com/etsy/statsd.git
$ cd statsd

#create a configuration file
$ cp exampleConfig.js config.js

Edit config.js to look like:

{
 port: 8125,
 mgmt_port: 8126,
 backends: [ "./backends/console" ]
}

  • StatsD runs on port 8125
  • StatsD Admin runs on port 8126

Send Metrics to StatsD

Start StatsD with its configuration file

$ node stats.js config.js
27 Apr 15:31:51 - reading config file: config.js
27 Apr 15:31:51 - server is up
[ ... ]

Open a terminal and start sending metrics:

$ echo "my.metric:2|c" | nc -u -w 1 127.0.0.1 8125
$ echo "my.metric.time:320|ms" | nc -u -w 1 127.0.0.1 8125
$

Note that these commands will not return any direct result.

The StatsD console should display the received metrics:

Flushing stats at Mon Apr 27 2015 16:28:36 GMT+0000 (UTC)
{ counters:
 { 'statsd.bad_lines_seen': 0,
 'statsd.packets_received': 2,
 'statsd.metrics_received': 2,
 'my.metric': 4 },
 timers: {},
[...]

This shows two metrics received – “statsd.metrics_received”: 2
The value of the counter is “my.metric”: 4

Go Further!

Monitor your own code with StatsD:

  • StatsD in Java
  • StatsD in Python
  • StatsD in PHP
  • StatsD with other programming languages

StatsD is usually used with other software or databases:

The post StatsD Installation and Configuration appeared first on Anomaly.

]]>
https://anomaly.io/statsd-install-and-config/feed/ 1