org.apache.hadoop.metrics2.sink

## Class StatsDSink

- java.lang.Object
- - org.apache.hadoop.metrics2.sink.StatsDSink

- All Implemented Interfaces:
    Closeable, AutoCloseable, MetricsPlugin, MetricsSink

      @InterfaceAudience.Public
       @InterfaceStability.Evolving
      public class StatsDSink
      extends Object
      implements MetricsSink, Closeable

  A metrics sink that writes metrics to a StatsD daemon. This sink will produce metrics of the form '[hostname].servicename.context.name.metricname:value|type' where hostname is optional. This is useful when sending to a daemon that is running on the localhost and will add the hostname to the metric (such as the CollectD StatsD plugin).
  To configure this plugin, you will need to add the following entries to your hadoop-metrics2.properties file:

       *.sink.statsd.class=org.apache.hadoop.metrics2.sink.StatsDSink
       [prefix].sink.statsd.server.host=
       [prefix].sink.statsd.server.port=
       [prefix].sink.statsd.skip.hostname=true|false (optional)
       [prefix].sink.statsd.service.name=NameNode (name you want for service)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `StatsDSink.StatsD` Class that sends UDP packets to StatsD daemon.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StatsDSink()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `void` | `flush()` Flush any buffered metrics
    `void` | `init(org.apache.commons.configuration2.SubsetConfiguration conf)` Initialize the plugin
    `void` | `putMetrics(MetricsRecord record)` Put a metrics record in the sink
    `void` | `writeMetric(String line)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StatsDSink

          public StatsDSink()

  - ### Method Detail

    - #### init

          public void init(org.apache.commons.configuration2.SubsetConfiguration conf)

      Description copied from interface: `MetricsPlugin`
      Initialize the plugin
      Specified by:
        `init` in interface `MetricsPlugin`
      Parameters:
        `conf` - the configuration object for the plugin

    - #### putMetrics

          public void putMetrics(MetricsRecord record)

      Description copied from interface: `MetricsSink`
      Put a metrics record in the sink
      Specified by:
        `putMetrics` in interface `MetricsSink`
      Parameters:
        `record` - the record to put

    - #### writeMetric

          public void writeMetric(String line)

    - #### flush

          public void flush()

      Description copied from interface: `MetricsSink`
      Flush any buffered metrics
      Specified by:
        `flush` in interface `MetricsSink`

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Throws:
        `IOException`

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.