StatsD in Standalone AppSignal Agent

The standalone AppSignal Agent runs a StatsD server over UDP on localhost port 8125 by default. You can use this to ingest metrics from other components of your infrastructure. Any metrics added can be used as custom metrics within AppSignal.

If you are running several AppSignal-instrumented applications at a time in the same server, the enable_statsd configuration option should be disabled for all but one of them, or the statsd_port configuration option should be used to expose each StatsD server on a different port.

Supported metrics

The following StatsD metrics are currently supported:

  • gauge
  • counter
  • timers

Other, unsupported metric types, will be ignored.

Tagging

The StatsD server supports the DogStatsD extension, which means tags for metrics are supported.

Example

The following example in Ruby demonstrates how this works using the statsd-instrument gem.

Ruby
require 'statsd-instrument' StatsD.backend = StatsD::Instrument::Backends::UDPBackend.new("localhost:8125", :datadog) # Gauge StatsD.gauge 'gauge', 2.0 StatsD.gauge 'gauge_with_tags', 3.0, tags: ['hostname:frontend1'], sample_rate: 0.9 # Counter 10.times do StatsD.increment 'counter' StatsD.increment 'counter_with_key_value_tags', tags: ['hostname:frontend1'] StatsD.increment 'counter_with_only_key_tags', tags: ['important'] end # Timing 10.times do StatsD.measure 'timing', 2.55 StatsD.measure 'timing_with_tags', 3.55, tags: ['hostname:frontend1'] end

This is just to demonstrate, it is far more useful to use this from other languages that are not directly supported by AppSignal. You could use this to collect metrics from a PHP or .NET app for example.

There are numerous tools available that can extract StatsD metrics from the JVM or various databases and web servers. We're curious to see what use cases you find, do let us know!