Statsd is a popular tool for collecting and monitoring metrics in real-time. It’s an open-source project developed by Etsy that works well with Graphite and other monitoring tools. In this tutorial, you’ll learn how to install Statsd on the Debian Latest operating system.
Before we start installing Statsd, make sure that the following requirements are met:
Once you’ve confirmed that your system meets the requirements, you can proceed with the installation.
Statsd is written in Node.js, so you’ll need to install it first. You can install Node.js by adding the NodeSource repository to your system and then installing the latest version of Node.
First, update the package list on your system:
sudo apt-get update
Install the software-properties-common package:
sudo apt-get install software-properties-common
Add the NodeSource repository to your system:
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
This will add the NodeSource repository and update your system’s package list.
Finally, install Node.js:
sudo apt-get install nodejs
This will install the latest version of Node.js on your system.
Now that you’ve installed Node.js, it’s time to install Statsd.
First, clone the Statsd repository from GitHub:
git clone https://github.com/etsy/statsd.git
Change to the cloned directory:
cd statsd
Install Statsd using NPM:
sudo npm install -g
This will install statsd globally on your system.
Create a configuration file:
sudo cp exampleConfig.js config.js
This will copy the example configuration file to the Statsd directory.
Edit the configuration file to fit your needs. You can use any text editor of your choice:
sudo nano config.js
This will open the configuration file in nano.
You’ll need to modify the “graphiteHost” and “graphitePort” properties to match the hostname and port of your Graphite server.
Save and exit the configuration file.
Now that Statsd is installed and configured, it’s time to test it.
Start Statsd:
statsd config.js
This will start Statsd using the configuration file you created earlier.
Send some metrics to Statsd for testing:
echo "test.metric:1|c" | nc -w 1 -u localhost 8125
This command sends a counter metric to Statsd.
Verify that Statsd is working correctly by accessing the Graphite web interface:
http://[IP Address of Graphite Server]/render?target=test.metric&from=-2min
Replace “[IP Address of Graphite Server]” with the IP address of your Graphite server. This should show a graph of the metric you just sent to Statsd.
If the graph is displayed correctly, then Statsd is working properly.
You’ve successfully installed Statsd on Debian Latest and sent a test metric to verify that it’s working. You can now use Statsd to collect and monitor metrics in real-time.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!