Class PrometheusRemoteWriteExporter

java.lang.Object
org.mockserver.metrics.PrometheusRemoteWriteExporter

public class PrometheusRemoteWriteExporter extends Object
Optional push exporter that, on a fixed interval, snapshots the same Prometheus metrics served at /mockserver/metrics, encodes them as a Prometheus Remote-Write WriteRequest protobuf — v1 or v2 per mockserver.prometheusRemoteWriteProtocolVersion (see selectEncoder(String)) — snappy-compresses it (raw block format), and HTTP POSTs it to a configured remote-write endpoint (Prometheus --web.enable-remote-write-receiver, Grafana Mimir, New Relic, VictoriaMetrics, Thanos Receive).

Off unless mockserver.prometheusRemoteWriteEnabled is set. Mirrors the OtelMetricsExporter lifecycle and is fail-soft throughout: telemetry must never throw into the server or prevent it from running. Remote write is inherently cumulative (the Prometheus model) — there is no delta here.

  • Method Details

    • startIfEnabled

      public static PrometheusRemoteWriteExporter startIfEnabled()
      Start the exporter if enabled in configuration, returning the running instance, or null if disabled, mis-configured, or startup failed (fail-soft — telemetry must never prevent the server from running).
    • startIfEnabled

      public static PrometheusRemoteWriteExporter startIfEnabled(Configuration configuration)
      As startIfEnabled() but preferring the values carried on the supplied Configuration instance, falling back to the static ConfigurationProperties store for each value the instance leaves unset, so remote-write settings applied over PUT /mockserver/configuration take effect here.
      Parameters:
      configuration - the live server configuration, or null to read the static store
    • stop

      public void stop()
      Stop pushing and release the scheduler. Safe to call once.