PrometheusMetricsSink (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.metrics2.sink, class: PrometheusMetricsSink

Package org.apache.hadoop.metrics2.sink

# Class PrometheusMetricsSink

java.lang.Object
org.apache.hadoop.metrics2.sink.PrometheusMetricsSink

All Implemented Interfaces:
  `MetricsPlugin`, `MetricsSink`

public class PrometheusMetricsSink extends Object implements MetricsSink
Metrics sink for prometheus exporter.

Stores the metric data in-memory and return with it on request.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PrometheusMetricsSink()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `flush()`
  Flush any buffered metrics
  `void`
  `init(org.apache.commons.configuration2.SubsetConfiguration conf)`
  Initialize the plugin
  `String`
  `prometheusName(String recordName, String metricName)`
  Convert CamelCase based names to lower-case names where the separator is the underscore, to follow prometheus naming conventions.
  `void`
  `putMetrics(MetricsRecord metricsRecord)`
  Put a metrics record in the sink
  `void`
  `writeMetrics(Writer writer)`

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

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

- ## Constructor Details

  - ### PrometheusMetricsSink

    public PrometheusMetricsSink()

- ## Method Details

  - ### putMetrics

    public void putMetrics(MetricsRecord metricsRecord)
    Description copied from interface: `MetricsSink`
    Put a metrics record in the sink
    Specified by:
      `putMetrics` in interface `MetricsSink`
    Parameters:
      `metricsRecord` - the record to put

  - ### prometheusName

    public String prometheusName(String recordName, String metricName)
    Convert CamelCase based names to lower-case names where the separator is the underscore, to follow prometheus naming conventions. This method utilizes a cache to improve performance.

    Reference:

    - Metrics and Label Naming
    - Exposition formats
    Parameters:
      `metricName` - metricName.
      `recordName` - recordName.
    Returns:
      prometheusName.

  - ### flush

    public void flush()
    Description copied from interface: `MetricsSink`
    Flush any buffered metrics
    Specified by:
      `flush` in interface `MetricsSink`

  - ### 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

  - ### writeMetrics

    public void writeMetrics(Writer writer) throws IOException
    Throws:
      `IOException`