Interface RemoteWriteEncoder

All Known Implementing Classes:
RemoteWriteV1Encoder, RemoteWriteV2Encoder

public interface RemoteWriteEncoder
Encodes a snapshot of Prometheus metrics into the body of a Prometheus remote-write request. Implementations are pure and stateless (no network, no global state) so they can be unit-tested in isolation.

The exporter calls encode(io.prometheus.metrics.model.snapshots.MetricSnapshots, long) to produce the (uncompressed) protobuf body, then snappy-compresses it and POSTs it. contentType() and protocolVersionHeader() let the exporter set the version-specific request headers without knowing which protocol version it holds.

  • Method Summary

    Modifier and Type
    Method
    Description
    The HTTP Content-Type for this protocol version (v1: application/x-protobuf).
    byte[]
    encode(io.prometheus.metrics.model.snapshots.MetricSnapshots snapshots, long timestampMillis)
    Encode the given metric snapshots into an uncompressed remote-write protobuf body.
    The value for the X-Prometheus-Remote-Write-Version header (v1: 0.1.0).
  • Method Details

    • encode

      byte[] encode(io.prometheus.metrics.model.snapshots.MetricSnapshots snapshots, long timestampMillis)
      Encode the given metric snapshots into an uncompressed remote-write protobuf body. Every emitted sample carries timestampMillis (unix epoch milliseconds) as its timestamp.
    • contentType

      String contentType()
      The HTTP Content-Type for this protocol version (v1: application/x-protobuf).
    • protocolVersionHeader

      String protocolVersionHeader()
      The value for the X-Prometheus-Remote-Write-Version header (v1: 0.1.0).