Class PrometheusResponseWriter

java.lang.Object
org.apache.solr.response.RawResponseWriter
org.apache.solr.response.PrometheusResponseWriter
All Implemented Interfaces:
BinaryQueryResponseWriter, QueryResponseWriter, NamedListInitializedPlugin

public class PrometheusResponseWriter extends RawResponseWriter
Response writer for Prometheus metrics. This is used only by the MetricsHandler
  • Constructor Details

    • PrometheusResponseWriter

      public PrometheusResponseWriter()
  • Method Details

    • write

      public void write(OutputStream out, SolrQueryRequest request, SolrQueryResponse response) throws IOException
      Description copied from interface: BinaryQueryResponseWriter
      Use it to write the response in a binary format
      Specified by:
      write in interface BinaryQueryResponseWriter
      Overrides:
      write in class RawResponseWriter
      Throws:
      IOException
    • getContentType

      public String getContentType(SolrQueryRequest request, SolrQueryResponse response)
      Description copied from interface: QueryResponseWriter
      Return the applicable Content Type for a request, this method must be thread safe.

      QueryResponseWriter's must implement this method to return a valid HTTP Content-Type header for the request, that will logically correspond with the output produced by the write method.

      Specified by:
      getContentType in interface QueryResponseWriter
      Overrides:
      getContentType in class RawResponseWriter
      Returns:
      a Content-Type string, which may not be null.
    • toPrometheus

      public static void toPrometheus(com.codahale.metrics.MetricRegistry registry, String registryName, List<com.codahale.metrics.MetricFilter> shouldMatchFilters, com.codahale.metrics.MetricFilter mustMatchFilter, Predicate<CharSequence> propertyFilter, boolean skipHistograms, boolean skipAggregateValues, boolean compact, Consumer<SolrPrometheusFormatter> consumer)
      Provides a representation of the given Dropwizard metric registry as SolrPrometheusCoreFormatter-s. Only those metrics are converted which match at least one of the given MetricFilter instances.
      Parameters:
      registry - the MetricRegistry to be converted
      shouldMatchFilters - a list of MetricFilter instances. A metric must match any one of the filters from this list to be included in the output
      mustMatchFilter - a MetricFilter. A metric must match this filter to be included in the output.
      propertyFilter - limit what properties of a metric are returned
      skipHistograms - discard any Histogram-s and histogram parts of Timer-s.
      skipAggregateValues - discard internal values of AggregateMetric-s.
      compact - use compact representation for counters and gauges.
      consumer - consumer that accepts produced SolrPrometheusCoreFormatter-s
    • getFormatterType

      public static SolrPrometheusFormatter getFormatterType(String registryName)