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

      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