StatsD is an open-source standard and, by extension, a set of tools that can be used to send, collect, and aggregate custom metrics from any application.
This tutorial demonstrates how to install and run StatsD to send your metrics to Coralogix.
module.exports = { deleteIdleStats: true, deleteGauges: true, deleteTimers: true, deleteCounters: true, port: 8125, backends: ["@coralogix/statsd-backend"], coralogix: { privateKey: "<PRIVATE_KEY>", apiHost: "<remote_write URL>", prefix: "host1", applicationName: "statsd", subsystemName: "statsd", mappings: { timer_test: { histogram_options: { buckets: [50, 100, 250, 500, 1000] }, labels: { job: 'test_job' } }, timer_test_2: { histogram_options: { buckets: [50, 100, 250, 500, 1000] } } } } }
In this configuration, you need to:
To run StatsD, execute it:
node stats.js coralogixConfig.js
The basic line protocol expects metrics to be sent in the format:
<metricname>:<value>|<type>
So the simplest way to send in metrics from your command line if you have StatsD running with the default UDP server on localhost would be:
echo "foo:1|c" | nc -u -w0 127.0.0.1 8125
echo "timer_test:65|ms|#tag_1:value,tag_2:value_2" | /usr/bin/nc -u -w0 127.0.0.1 8125
To run inside a Docker container, just replace the provided Dockerfile in the repository with this one.
Then follow the Manual Install steps.
FROM node:14 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app # Install python # RUN apk add --no-cache --update g++ gcc libgcc libstdc++ linux-headers make python # Setup node envs ARG NODE_ENV ENV NODE_ENV $NODE_ENV # Install dependencies COPY package.json /usr/src/app/ RUN npm install npm cache clean --force # Copy required src (see .dockerignore) COPY . /usr/src/app COPY coralogixConfig.js config.js # Expose required ports RUN npm install @coralogix/statsd-backend EXPOSE 8125/udp EXPOSE 8126 # Start statsd ENTRYPOINT [ "node", "stats.js", "config.js" ]
You can go to Grafana in your account and browse metrics to see if they are arriving:
Need help?
Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.
Feel free to reach out to us via our in-app chat or by sending us an email at [email protected].