A client for DogStatsD, an extension of the StatsD metric server for Datadog. Full API documentation is available in DogStatsD-ruby rubydoc.
First install the library:
gem install dogstatsd-ruby
To instantiate a DogStatsd client:
# Import the library require 'datadog/statsd' # Create a DogStatsD client instance. statsd = ::.('localhost', 8125)
Or if you want to connect over Unix Domain Socket:
# Connection over Unix Domain Socket statsd = ::.(socket_path: '/path/to/socket/file')
Origin detection over UDP
Origin detection is a method to detect which pod DogStatsD packets are coming from in order to add the pod's tags to the tag list.
To enable origin detection over UDP, add the following lines to your application manifest
env: - name: DD_ENTITY_ID valueFrom: fieldRef: fieldPath: metadata.uid
The DogStatsD client attaches an internal tag,
entity_id. The value of this tag is the content of the
DD_ENTITY_ID environment variable, which is the pod’s UID.
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:
- Submit a COUNT metric.
- Submit a GAUGE metric.
- Submit a SET metric
- Submit a HISTOGRAM metric
- Submit a DISTRIBUTION metric
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 DogStatsD-ruby rubydoc.
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 Datadog your Event Stream.
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.
dogstatsd-ruby is forked from Rien Henrichs original Statsd client.
Copyright (c) 2011 Rein Henrichs. See LICENSE.txt for further details.