Added commmentary to RW 2.0 protocol for easier adoption and explicit semantics. (#13502)

* Added commmentary to RW 2.0 protocol for easier adoption and explicit semantics.

Signed-off-by: bwplotka <bwplotka@gmail.com>

* Apply suggestions from code review

Co-authored-by: Nico Pazos <32206519+npazosmendez@users.noreply.github.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>

---------

Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>
Co-authored-by: Callum Styan <callumstyan@gmail.com>
Co-authored-by: Nico Pazos <32206519+npazosmendez@users.noreply.github.com>
This commit is contained in:
Bartlomiej Plotka 2024-02-22 03:56:02 +01:00 committed by GitHub
parent 6d86554cf3
commit ae414a3e6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 267 additions and 143 deletions

View file

@ -98,8 +98,19 @@ func (Histogram_ResetHint) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_4919b8b88a093366, []int{5, 0}
}
// WriteRequest represents a Remote Write 2.0 request to write given time series
// to remote destination. Note that Remote Write 2.0 requires a content
// negotiation for version and compressions, explained in
// https://docs.google.com/document/d/1jx1fqpRnM0pAndeo3AgY7g6BLxN3Ah8R0Mm8RvNsHoU/edit
// TODO(bwplotka): Change URL to Prometheus docs once ready.
type WriteRequest struct {
Symbols []string `protobuf:"bytes,1,rep,name=symbols,proto3" json:"symbols,omitempty"`
// symbols contains de-duplicated array of string elements used for various
// items in WriteRequest like labels and some metadata items. To decode
// each of those items, referenced, by "ref(s)" suffix, you need to lookup the
// actual string by index from symbols array. The order of strings is up to
// the client, server should not assume any particular encoding.
Symbols []string `protobuf:"bytes,1,rep,name=symbols,proto3" json:"symbols,omitempty"`
// timeseries represents array of distinct series with 0 or more samples.
Timeseries []TimeSeries `protobuf:"bytes,2,rep,name=timeseries,proto3" json:"timeseries"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@ -153,20 +164,48 @@ func (m *WriteRequest) GetTimeseries() []TimeSeries {
return nil
}
// TimeSeries represents a single series.
type TimeSeries struct {
// Sorted list of label name-value pair references,
// encoded as indices to the strings array.
// This list's len is always multiple of 2.
LabelsRefs []uint32 `protobuf:"varint,1,rep,packed,name=labels_refs,json=labelsRefs,proto3" json:"labels_refs,omitempty"`
Samples []Sample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples"`
Exemplars []Exemplar `protobuf:"bytes,3,rep,name=exemplars,proto3" json:"exemplars"`
// Same as current version
Histograms []Histogram `protobuf:"bytes,4,rep,name=histograms,proto3" json:"histograms"`
Metadata Metadata `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata"`
// Optional created timestamp for the metric in ms format,
// if the first sample in samples does not contain 0 value.
// See model/timestamp/timestamp.go for conversion from time.Time
// to Prometheus timestamp.
// labels_refs is a list of label name-value pair references, encoded
// as indices to the WriteRequest.symbols array. This list's len is always
// a multiple of 2, and the underlying labels should be sorted.
//
// Note that there might be multiple TimeSeries objects in the same
// WriteRequests with the same labels e.g. for different exemplars, metadata
// or created timestamp.
LabelsRefs []uint32 `protobuf:"varint,1,rep,packed,name=labels_refs,json=labelsRefs,proto3" json:"labels_refs,omitempty"`
// samples contain zero or more samples for a given timeseries. For a typical
// clients, in healthy cases, there will be only one sample, for ~real
// time metric streaming. Samples can, in theory, co-exist with histogram samples
// (histograms field), although it should be extremely rare in practice (e.g.
// only when classic histogram series and native histogram share exactly the
// same metric name).
//
// Samples are sorted by timestamp (older first).
Samples []Sample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples"`
// histograms contain zero or more histogram samples for a given timeseries.
// For a typical clients, in healthy cases, there will be only one sample, for ~real
// time metric streaming. histograms can co-exist with samples (see samples
// for details).
//
// histograms are sorted by timestamp (older first).
Histograms []Histogram `protobuf:"bytes,3,rep,name=histograms,proto3" json:"histograms"`
// exemplars represents optional set of exemplars attached to this series' samples.
Exemplars []Exemplar `protobuf:"bytes,4,rep,name=exemplars,proto3" json:"exemplars"`
// metadata represents the metadata associated with the given series' samples.
Metadata Metadata `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata"`
// created_timestamp represents an optional created timestamp associated with
// this series' samples in ms format, typically for counter or histogram type
// metrics. Note that some servers might require this and in return fail to
// ingest such series within the WriteRequest.
//
// For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go
// for conversion from/to time.Time to Prometheus timestamp.
//
// NOTE: Optional key word is omitted due to
// https://cloud.google.com/apis/design/design_patterns.md#optional_primitive_fields
// Zero value means value not set. If you need to use exactly zero value for
// timestamp, use 1 millisecond before or after.
CreatedTimestamp int64 `protobuf:"varint,6,opt,name=created_timestamp,json=createdTimestamp,proto3" json:"created_timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@ -220,16 +259,16 @@ func (m *TimeSeries) GetSamples() []Sample {
return nil
}
func (m *TimeSeries) GetExemplars() []Exemplar {
func (m *TimeSeries) GetHistograms() []Histogram {
if m != nil {
return m.Exemplars
return m.Histograms
}
return nil
}
func (m *TimeSeries) GetHistograms() []Histogram {
func (m *TimeSeries) GetExemplars() []Exemplar {
if m != nil {
return m.Histograms
return m.Exemplars
}
return nil
}
@ -248,11 +287,25 @@ func (m *TimeSeries) GetCreatedTimestamp() int64 {
return 0
}
// Exemplar is an additional information attached to some series' samples.
// It is typically used to attach an example trace or request ID associated with
// the metric changes.
type Exemplar struct {
// TODO: same as TimeSeries.labels_refs
// labels_refs is a list of label name-value pair references, encoded
// as indices to the WriteRequest.symbols array. This list's len is always
// a multiple of 2, and the underlying labels should be sorted.
LabelsRefs []uint32 `protobuf:"varint,1,rep,packed,name=labels_refs,json=labelsRefs,proto3" json:"labels_refs,omitempty"`
Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"`
// timestamp is in ms.
// value represents an exact example value. This can be useful when the exemplar
// is attached to a histogram, which only gives an estimated value through buckets.
Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"`
// timestamp represents an optional timestamp of the example in ms.
// For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go
// for conversion from/to time.Time to Prometheus timestamp.
//
// NOTE: Optional key word is omitted due to
// https://cloud.google.com/apis/design/design_patterns.md#optional_primitive_fields
// Zero value means value not set. If you need to use exactly zero value for
// timestamp, use 1 millisecond before or after.
Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@ -313,10 +366,13 @@ func (m *Exemplar) GetTimestamp() int64 {
return 0
}
// Sample represents series sample.
type Sample struct {
// value of the sample.
Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"`
// timestamp is in ms format, see model/timestamp/timestamp.go for
// conversion from time.Time to Prometheus timestamp.
// timestamp represents timestamp of the sample in ms.
// For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go
// for conversion from/to time.Time to Prometheus timestamp.
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@ -370,13 +426,18 @@ func (m *Sample) GetTimestamp() int64 {
return 0
}
// Metadata represents the metadata associated with the given series' samples.
type Metadata struct {
Type Metadata_MetricType `protobuf:"varint,1,opt,name=type,proto3,enum=write.v2.Metadata_MetricType" json:"type,omitempty"`
HelpRef uint32 `protobuf:"varint,3,opt,name=help_ref,json=helpRef,proto3" json:"help_ref,omitempty"`
UnitRef uint32 `protobuf:"varint,4,opt,name=unit_ref,json=unitRef,proto3" json:"unit_ref,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Type Metadata_MetricType `protobuf:"varint,1,opt,name=type,proto3,enum=write.v2.Metadata_MetricType" json:"type,omitempty"`
// help_ref is a reference to the WriteRequest.symbols array representing help
// text for the metric.
HelpRef uint32 `protobuf:"varint,3,opt,name=help_ref,json=helpRef,proto3" json:"help_ref,omitempty"`
// unit_ref is a reference to the WriteRequest.symbols array representing unit
// for the metric.
UnitRef uint32 `protobuf:"varint,4,opt,name=unit_ref,json=unitRef,proto3" json:"unit_ref,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Metadata) Reset() { *m = Metadata{} }
@ -475,8 +536,9 @@ type Histogram struct {
PositiveDeltas []int64 `protobuf:"zigzag64,12,rep,packed,name=positive_deltas,json=positiveDeltas,proto3" json:"positive_deltas,omitempty"`
PositiveCounts []float64 `protobuf:"fixed64,13,rep,packed,name=positive_counts,json=positiveCounts,proto3" json:"positive_counts,omitempty"`
ResetHint Histogram_ResetHint `protobuf:"varint,14,opt,name=reset_hint,json=resetHint,proto3,enum=write.v2.Histogram_ResetHint" json:"reset_hint,omitempty"`
// timestamp is in ms format, see model/timestamp/timestamp.go for
// conversion from time.Time to Prometheus timestamp.
// timestamp represents timestamp of the sample in ms.
// For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go
// for conversion from/to time.Time to Prometheus timestamp.
Timestamp int64 `protobuf:"varint,15,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@ -753,57 +815,57 @@ var fileDescriptor_4919b8b88a093366 = []byte{
0x14, 0xce, 0x78, 0x7d, 0x3d, 0x89, 0xdd, 0xf5, 0xd4, 0x69, 0xb7, 0x81, 0xa6, 0xc6, 0x12, 0x60,
0x81, 0xe4, 0x80, 0x41, 0x48, 0xa0, 0xbc, 0xd8, 0xe9, 0x26, 0xf6, 0x83, 0x9d, 0x6a, 0x76, 0x23,
0x14, 0x5e, 0x56, 0x1b, 0x7b, 0x6c, 0xaf, 0xd8, 0x1b, 0x3b, 0x63, 0x43, 0xf8, 0x5f, 0xfc, 0x87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9c, 0x34, 0xa2, 0xf4,
0xf8, 0xf8, 0x41, 0x3f, 0xd9, 0x7f, 0xd0, 0x4b, 0x68, 0x64, 0x2e, 0x7c, 0x02, 0xcf, 0x88, 0x58,
0x49, 0x6b, 0x32, 0x9d, 0x9b, 0x7b, 0xef, 0x0a, 0x43, 0xab, 0xc0, 0xdd, 0xea, 0x86, 0x8a, 0x70,
0x1b, 0x9a, 0x05, 0x6c, 0x7e, 0xad, 0x96, 0xc4, 0xea, 0x17, 0xa0, 0xf8, 0x91, 0x29, 0xe3, 0x1a,
0x54, 0xe4, 0x17, 0x8e, 0x8f, 0x00, 0xf2, 0x05, 0xe9, 0x9d, 0x03, 0xe4, 0xd3, 0x14, 0x3b, 0x1a,
0xac, 0x56, 0x8c, 0xc6, 0x4b, 0xdf, 0x26, 0x49, 0x25, 0x70, 0x97, 0xfa, 0x6b, 0xbe, 0x91, 0xbb,
0xde, 0x24, 0x49, 0x35, 0x3e, 0x7e, 0xfb, 0x70, 0x8a, 0xfe, 0x7c, 0x38, 0x45, 0xff, 0x3e, 0x9c,
0xa2, 0x9f, 0x6a, 0x72, 0x1e, 0xbb, 0xe1, 0x5d, 0x55, 0xfe, 0xcc, 0x7d, 0xf3, 0x7f, 0x00, 0x00,
0x00, 0xff, 0xff, 0x50, 0xe1, 0xdd, 0xa2, 0x1e, 0x07, 0x00, 0x00,
}
func (m *WriteRequest) Marshal() (dAtA []byte, err error) {
@ -895,10 +957,10 @@ func (m *TimeSeries) MarshalToSizedBuffer(dAtA []byte) (int, error) {
}
i--
dAtA[i] = 0x2a
if len(m.Histograms) > 0 {
for iNdEx := len(m.Histograms) - 1; iNdEx >= 0; iNdEx-- {
if len(m.Exemplars) > 0 {
for iNdEx := len(m.Exemplars) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Histograms[iNdEx].MarshalToSizedBuffer(dAtA[:i])
size, err := m.Exemplars[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
@ -909,10 +971,10 @@ func (m *TimeSeries) MarshalToSizedBuffer(dAtA []byte) (int, error) {
dAtA[i] = 0x22
}
}
if len(m.Exemplars) > 0 {
for iNdEx := len(m.Exemplars) - 1; iNdEx >= 0; iNdEx-- {
if len(m.Histograms) > 0 {
for iNdEx := len(m.Histograms) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Exemplars[iNdEx].MarshalToSizedBuffer(dAtA[:i])
size, err := m.Histograms[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
@ -1393,14 +1455,14 @@ func (m *TimeSeries) Size() (n int) {
n += 1 + l + sovTypes(uint64(l))
}
}
if len(m.Exemplars) > 0 {
for _, e := range m.Exemplars {
if len(m.Histograms) > 0 {
for _, e := range m.Histograms {
l = e.Size()
n += 1 + l + sovTypes(uint64(l))
}
}
if len(m.Histograms) > 0 {
for _, e := range m.Histograms {
if len(m.Exemplars) > 0 {
for _, e := range m.Exemplars {
l = e.Size()
n += 1 + l + sovTypes(uint64(l))
}
@ -1862,40 +1924,6 @@ func (m *TimeSeries) Unmarshal(dAtA []byte) error {
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Exemplars", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Exemplars = append(m.Exemplars, Exemplar{})
if err := m.Exemplars[len(m.Exemplars)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Histograms", wireType)
}
@ -1929,6 +1957,40 @@ func (m *TimeSeries) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Exemplars", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Exemplars = append(m.Exemplars, Exemplar{})
if err := m.Exemplars[len(m.Exemplars)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType)

View file

@ -18,47 +18,104 @@ option go_package = "writev2";
import "gogoproto/gogo.proto";
// WriteRequest represents a Remote Write 2.0 request to write given time series
// to remote destination. Note that Remote Write 2.0 requires a content
// negotiation for version and compressions, explained in
// https://docs.google.com/document/d/1jx1fqpRnM0pAndeo3AgY7g6BLxN3Ah8R0Mm8RvNsHoU/edit
// TODO(bwplotka): Change URL to Prometheus docs once ready.
message WriteRequest {
// symbols contains de-duplicated array of string elements used for various
// items in WriteRequest like labels and some metadata items. To decode
// each of those items, referenced, by "ref(s)" suffix, you need to lookup the
// actual string by index from symbols array. The order of strings is up to
// the client, server should not assume any particular encoding.
repeated string symbols = 1;
// timeseries represents array of distinct series with 0 or more samples.
repeated TimeSeries timeseries = 2 [(gogoproto.nullable) = false];
}
// TimeSeries represents a single series.
message TimeSeries {
// Sorted list of label name-value pair references,
// encoded as indices to the strings array.
// This list's len is always multiple of 2.
repeated uint32 labels_refs = 1 ;
// labels_refs is a list of label name-value pair references, encoded
// as indices to the WriteRequest.symbols array. This list's len is always
// a multiple of 2, and the underlying labels should be sorted.
//
// Note that there might be multiple TimeSeries objects in the same
// WriteRequests with the same labels e.g. for different exemplars, metadata
// or created timestamp.
repeated uint32 labels_refs = 1;
// samples contain zero or more samples for a given timeseries. For typical
// clients, in healthy cases, there will be only one sample, for ~real
// time metric streaming. Samples can, in theory, co-exist with histogram samples
// (histograms field), although it should be extremely rare in practice (e.g.
// only when classic histogram series and native histogram share exactly the
// same metric name).
//
// Samples are sorted by timestamp (older first).
repeated Sample samples = 2 [(gogoproto.nullable) = false];
repeated Exemplar exemplars = 3 [(gogoproto.nullable) = false];
// Same as current version
repeated Histogram histograms = 4 [(gogoproto.nullable) = false];
// histograms contain zero or more histogram samples for a given timeseries.
// For typical clients, in healthy cases, there will be only one sample, for ~real
// time metric streaming. histograms can co-exist with samples (see samples
// for details).
//
// histograms are sorted by timestamp (older first).
repeated Histogram histograms = 3 [(gogoproto.nullable) = false];
// exemplars represents optional set of exemplars attached to this series' samples.
repeated Exemplar exemplars = 4 [(gogoproto.nullable) = false];
// metadata represents the metadata associated with the given series' samples.
Metadata metadata = 5 [(gogoproto.nullable) = false];
// Optional created timestamp for the metric in ms format,
// if the first sample in samples does not contain 0 value.
// See model/timestamp/timestamp.go for conversion from time.Time
// to Prometheus timestamp.
// created_timestamp represents an optional created timestamp associated with
// this series' samples in ms format, typically for counter or histogram type
// metrics. Note that some servers might require this and in return fail to
// ingest such series within the WriteRequest.
//
// For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go
// for conversion from/to time.Time to Prometheus timestamp.
//
// NOTE: Optional key word is omitted due to
// https://cloud.google.com/apis/design/design_patterns.md#optional_primitive_fields
// Zero value means value not set. If you need to use exactly zero value for
// timestamp, use 1 millisecond before or after.
int64 created_timestamp = 6;
}
// Exemplar is an additional information attached to some series' samples.
// It is typically used to attach an example trace or request ID associated with
// the metric changes.
message Exemplar {
// TODO: same as TimeSeries.labels_refs
// labels_refs is a list of label name-value pair references, encoded
// as indices to the WriteRequest.symbols array. This list's len is always
// a multiple of 2, and the underlying labels should be sorted.
repeated uint32 labels_refs = 1;
// value represents an exact example value. This can be useful when the exemplar
// is attached to a histogram, which only gives an estimated value through buckets.
double value = 2;
// timestamp is in ms.
// timestamp represents an optional timestamp of the example in ms.
// For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go
// for conversion from/to time.Time to Prometheus timestamp.
//
// NOTE: Optional key word is omitted due to
// https://cloud.google.com/apis/design/design_patterns.md#optional_primitive_fields
// Zero value means value not set. If you need to use exactly zero value for
// timestamp, use 1 millisecond before or after.
int64 timestamp = 3;
}
// Sample represents series sample.
message Sample {
// value of the sample.
double value = 1;
// timestamp is in ms format, see model/timestamp/timestamp.go for
// conversion from time.Time to Prometheus timestamp.
// timestamp represents timestamp of the sample in ms.
// For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go
// for conversion from/to time.Time to Prometheus timestamp.
int64 timestamp = 2;
}
// Metadata represents the metadata associated with the given series' samples.
message Metadata {
enum MetricType {
METRIC_TYPE_UNSPECIFIED = 0;
@ -71,7 +128,11 @@ message Metadata {
METRIC_TYPE_STATESET = 7;
}
MetricType type = 1;
// help_ref is a reference to the WriteRequest.symbols array representing help
// text for the metric.
uint32 help_ref = 3;
// unit_ref is a reference to the WriteRequest.symbols array representing unit
// for the metric.
uint32 unit_ref = 4;
}
@ -125,8 +186,9 @@ message Histogram {
repeated double positive_counts = 13; // Absolute count of each bucket.
ResetHint reset_hint = 14;
// timestamp is in ms format, see model/timestamp/timestamp.go for
// conversion from time.Time to Prometheus timestamp.
// timestamp represents timestamp of the sample in ms.
// For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go
// for conversion from/to time.Time to Prometheus timestamp.
int64 timestamp = 15;
}