Documentation
¶
Overview ¶
Package prompb implements the small subset of Prometheus's remote-read wire protocol needed for a Prometheus remote read endpoint (ReadRequest/ReadResponse and their.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalReadRequest ¶
func MarshalReadRequest(req ReadRequest) []byte
MarshalReadRequest encodes req as plain (uncompressed) protobuf bytes. The remote-read HTTP transport wraps this in snappy block compression; that's the HTTP handler's concern, not this package's, which only speaks the message format.
func MarshalReadResponse ¶
func MarshalReadResponse(resp ReadResponse) []byte
MarshalReadResponse encodes resp as plain (uncompressed) protobuf bytes.
Types ¶
type Label ¶
Label is one name/value pair identifying a time series, e.g. {__name__="levelrail_cpu_percent"} or {service="web"}.
type LabelMatcher ¶
type LabelMatcher struct {
Type MatcherType
Name string
Value string
}
LabelMatcher is one selector term in a Query, e.g. Type=MatchEqual, Name="service", Value="web".
type MatcherType ¶
type MatcherType int32
MatcherType mirrors prometheus/prometheus/prompb's LabelMatcher_Type enum values exactly; these are wire-format constants, not this package's own invention.
const ( MatchEqual MatcherType = 0 MatchNotEqual MatcherType = 1 MatchRegexp MatcherType = 2 MatchNotRegexp MatcherType = 3 )
The four matcher types Prometheus's remote-read protocol defines. This pass's HTTP handler (internal/api/prometheus.go) only actually resolves MatchEqual; the others are still decoded correctly (an unsupported matcher type is a valid, representable value, not a decode error) so the codec itself stays a complete, honest implementation of the wire format even where the handler built on top of it is narrower.
type Query ¶
type Query struct {
StartTimestampMs int64
EndTimestampMs int64
Matchers []LabelMatcher
}
Query is one time-series selection: a time range plus the matchers that narrow which series it covers.
type QueryResult ¶
type QueryResult struct {
TimeSeries []TimeSeries
}
QueryResult answers one Query with every matching TimeSeries.
type ReadRequest ¶
type ReadRequest struct {
Queries []Query
}
ReadRequest is the top-level message a remote-read client (Prometheus or Grafana pointed directly at this control plane) sends.
func UnmarshalReadRequest ¶
func UnmarshalReadRequest(b []byte) (ReadRequest, error)
UnmarshalReadRequest decodes plain (uncompressed) protobuf bytes.
type ReadResponse ¶
type ReadResponse struct {
Results []QueryResult
}
ReadResponse is the top-level message this control plane sends back, one QueryResult per Query in the originating ReadRequest, same order.
func UnmarshalReadResponse ¶
func UnmarshalReadResponse(b []byte) (ReadResponse, error)
UnmarshalReadResponse decodes plain (uncompressed) protobuf bytes. Exported for tests (round-tripping this package's own output) and for any future client-side use; the HTTP handler itself only ever calls MarshalReadResponse.
type Sample ¶
Sample is one metric value at one point in time. Timestamp is milliseconds since the Unix epoch, matching Prometheus's own convention (not seconds, and not this repo's more common time.Time).
type TimeSeries ¶
TimeSeries is one selected series: the labels that identify it plus every sample found for it within the query's time range.