Need help with datadog-go?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

245 Stars 106 Forks MIT License 219 Commits 16 Opened issues


go dogstatsd client library for datadog

Services available


Need anything else?

Contributors list

Build Status

Datadog Go

Godoc license

is a library that provides a DogStatsD client in Golang.

Go 1.12+ is officially supported. Older versions might work but are not tested.

The following documentation is available:


Get the code with:

$ go get

Then create a new DogStatsD client:

package main

import ( "log" "" )

func main() { statsd, err := statsd.New("") if err != nil { log.Fatal(err) } }

Find a list of all the available options for your DogStatsD Client in the Datadog-go godoc documentation or in Datadog public DogStatsD documentation.

Supported environment variables

  • If the
    parameter is empty, the client uses the
    environment variables to build a target address. Example:
    for UDP,
    for UDS and
    for Windows
  • If the
    environment variable is found, its value is injected as a global
    tag. The Datadog Agent uses this tag to insert container tags into the metrics. To avoid overwriting this global tag, only
    to the

To enable origin detection and set the

environment variable, add the following lines to your application manifest:
  - name: DD_ENTITY_ID
        fieldPath: metadata.uid
  • DD_ENV
    , and
    can be used by the statsd client to set
    {env, service, version}
    as global tags for all data emitted.

Unix Domain Sockets Client

Agent v6+ accepts packets through a Unix Socket datagram connection. Details about the advantages of using UDS over UDP are available in the DogStatsD Unix Socket documentation. You can use this protocol by giving a

address argument to the


In order to use DogStatsD metrics, events, and Service Checks, the Agent must be running and available.


After the client is created, you can start sending custom metrics to Datadog. See the dedicated Metric Submission: DogStatsD documentation to see how to submit all supported metric types to Datadog with working code examples:

Metric names must only contain ASCII alphanumerics, underscores, and periods. The client will not replace nor check for invalid characters.

Some options are suppported when submitting metrics, like applying a sample rate to your metrics or tagging your metrics with your custom tags. Find all the available functions to report metrics in the Datadog Go client GoDoc documentation.


After the client is created, you can start sending events to your Datadog Event Stream. See the dedicated Event Submission: DogStatsD documentation to see how to submit an event to your Datadog Event Stream.

Service Checks

After the client is created, you can start sending Service Checks to Datadog. See the dedicated Service Check Submission: DogStatsD documentation to see how to submit a Service Check to Datadog.

Performance / Metric drops

Monitoring this client

This client automatically injects telemetry about itself in the DogStatsD stream. Those metrics will not be counted as custom and will not be billed. This feature can be disabled using the


See Telemetry documentation to learn more about it.

Tweaking kernel options

In very high throughput environments it is possible to improve performance by changing the values of some kernel options.

Unix Domain Sockets

  • sysctl -w net.unix.max_dgram_qlen=X
    - Set datagram queue size to X (default value is usually 10).
  • sysctl -w net.core.wmem_max=X
    - Set the max size of the send buffer for all the host sockets.

Maximum packets size in high-throughput scenarios

In order to have the most efficient use of this library in high-throughput scenarios, default values for the maximum packets size have already been set to have the best usage of the underlying network. However, if you perfectly know your network and you know that a different value for the maximum packets size should be used, you can set it with the option

. Example:
package main

import ( "log" "" )

func main() { statsd, err := statsd.New("", WithMaxBytesPerPayload(4096)) if err != nil { log.Fatal(err) } }


Run the tests with:

$ go test


datadog-go is released under the MIT license.


Original code by ooyala.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.