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 TypeMethodDescriptionThe HTTPContent-Typefor 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 theX-Prometheus-Remote-Write-Versionheader (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 carriestimestampMillis(unix epoch milliseconds) as its timestamp. -
contentType
String contentType()The HTTPContent-Typefor this protocol version (v1:application/x-protobuf). -
protocolVersionHeader
String protocolVersionHeader()The value for theX-Prometheus-Remote-Write-Versionheader (v1:0.1.0).
-