anujdas / dogstatsd-local

A local dogstatsd backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dogstatsd Local

A local implementation of the dogstatsd protocol (<=v1.2) from Datadog

Why?

Datadog is great for production application metric aggregation. This project was inspired by the need to inspect and debug metrics before sending them to datadog.

dogstatsd-local is a small program which understands the dogstatsd and statsd protocols. It listens on a local UDP server and writes metrics, events and service checks per the dogstatsd protocol to stdout in user configurable formats.

This can be helpful for debugging metrics themselves, and to prevent polluting datadog with noisy metrics from a development environment. dogstatsd-local can also be used to pipe metrics as json to other processes for further processing.

Usage

Build Manually

This is a go application with no external dependencies. Building should be as simple as running go build in the source directory.

Once compiled, the dogstatsd-local binary can be run directly:

$ ./dogstatsd-local -port 8126

Docker

$ docker run -p 8125:8125/udp anujdas/dogstatsd-local

Sample Formats

Raw (no formatting)

When writing a metric such as:

$ printf "namespace.metric:1:2|c|@1|#tag1,tag2:value" | nc -cu localhost 8125

Running dogstatsd-local with the -format raw flag will output the plain udp packet:

$ docker run -p 8125:8125/udp anujdas/dogstatsd-local -format raw
namespace.metric:1:2|c|@1|#tag1,tag2:value

Human

When writing a metric such as:

$ printf "namespace.metric:1:2|c|@1|#tag1,tag2:value" | nc -cu localhost 8125

Running dogstatsd-local with the -format human flag will output a human readable metric:

$ docker run -p 8125:8125/udp anujdas/dogstatsd-local -format human
metric:counter|namespace.metric|1.00,2.00  tag1 tag2:value

JSON

When writing a metric such as:

$ printf "namespace.metric:1:2|c|@1|#tag1,tag2:value|c:c1" | nc -cu localhost 8125

Running dogstatsd-local with the -format json flag will output json:

$ docker run -p 8125:8125/udp anujdas/dogstatsd-local -format json
{"name":"namespace.metric","type":"counter","values":[1,2],"sample_rate":1,"tags":["tag1","tag2:value","container_id":"c1"]}

dogstatsd-local can be piped to any process that understands json via stdin. For example, to pretty print the name and first value with jq:

$ docker run -p 8125:8125/udp anujdas/dogstatsd-local -format json | jq ".name,.values[0]"
"namespace.metric"
1

About

A local dogstatsd backend

License:MIT License


Languages

Language:Go 98.9%Language:Dockerfile 1.1%