sui_proxy/
remote_write.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3#[allow(clippy::derive_partial_eq_without_eq)]
4#[derive(Clone, PartialEq, ::prost::Message)]
5pub struct MetricMetadata {
6    /// Represents the metric type, these match the set from Prometheus.
7    /// Refer to model/textparse/interface.go for details.
8    #[prost(enumeration = "metric_metadata::MetricType", tag = "1")]
9    pub r#type: i32,
10    #[prost(string, tag = "2")]
11    pub metric_family_name: ::prost::alloc::string::String,
12    #[prost(string, tag = "4")]
13    pub help: ::prost::alloc::string::String,
14    #[prost(string, tag = "5")]
15    pub unit: ::prost::alloc::string::String,
16}
17/// Nested message and enum types in `MetricMetadata`.
18pub mod metric_metadata {
19    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
20    #[repr(i32)]
21    pub enum MetricType {
22        Unknown = 0,
23        Counter = 1,
24        Gauge = 2,
25        Histogram = 3,
26        Gaugehistogram = 4,
27        Summary = 5,
28        Info = 6,
29        Stateset = 7,
30    }
31    impl MetricType {
32        /// String value of the enum field names used in the ProtoBuf definition.
33        ///
34        /// The values are not transformed in any way and thus are considered stable
35        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
36        pub fn as_str_name(&self) -> &'static str {
37            match self {
38                MetricType::Unknown => "UNKNOWN",
39                MetricType::Counter => "COUNTER",
40                MetricType::Gauge => "GAUGE",
41                MetricType::Histogram => "HISTOGRAM",
42                MetricType::Gaugehistogram => "GAUGEHISTOGRAM",
43                MetricType::Summary => "SUMMARY",
44                MetricType::Info => "INFO",
45                MetricType::Stateset => "STATESET",
46            }
47        }
48        /// Creates an enum from field names used in the ProtoBuf definition.
49        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
50            match value {
51                "UNKNOWN" => Some(Self::Unknown),
52                "COUNTER" => Some(Self::Counter),
53                "GAUGE" => Some(Self::Gauge),
54                "HISTOGRAM" => Some(Self::Histogram),
55                "GAUGEHISTOGRAM" => Some(Self::Gaugehistogram),
56                "SUMMARY" => Some(Self::Summary),
57                "INFO" => Some(Self::Info),
58                "STATESET" => Some(Self::Stateset),
59                _ => None,
60            }
61        }
62    }
63}
64#[allow(clippy::derive_partial_eq_without_eq)]
65#[derive(Clone, PartialEq, ::prost::Message)]
66pub struct Sample {
67    #[prost(double, tag = "1")]
68    pub value: f64,
69    /// timestamp is in ms format, see model/timestamp/timestamp.go for
70    /// conversion from time.Time to Prometheus timestamp.
71    #[prost(int64, tag = "2")]
72    pub timestamp: i64,
73}
74#[allow(clippy::derive_partial_eq_without_eq)]
75#[derive(Clone, PartialEq, ::prost::Message)]
76pub struct Exemplar {
77    /// Optional, can be empty.
78    #[prost(message, repeated, tag = "1")]
79    pub labels: ::prost::alloc::vec::Vec<Label>,
80    #[prost(double, tag = "2")]
81    pub value: f64,
82    /// timestamp is in ms format, see model/timestamp/timestamp.go for
83    /// conversion from time.Time to Prometheus timestamp.
84    #[prost(int64, tag = "3")]
85    pub timestamp: i64,
86}
87/// A native histogram, also known as a sparse histogram.
88/// Original design doc:
89/// <https://docs.google.com/document/d/1cLNv3aufPZb3fNfaJgdaRBZsInZKKIHo9E6HinJVbpM/edit>
90/// The appendix of this design doc also explains the concept of float
91/// histograms. This Histogram message can represent both, the usual
92/// integer histogram as well as a float histogram.
93#[allow(clippy::derive_partial_eq_without_eq)]
94#[derive(Clone, PartialEq, ::prost::Message)]
95pub struct Histogram {
96    /// Sum of observations in the histogram.
97    #[prost(double, tag = "3")]
98    pub sum: f64,
99    /// The schema defines the bucket schema. Currently, valid numbers
100    /// are -4 <= n <= 8. They are all for base-2 bucket schemas, where 1
101    /// is a bucket boundary in each case, and then each power of two is
102    /// divided into 2^n logarithmic buckets. Or in other words, each
103    /// bucket boundary is the previous boundary times 2^(2^-n). In the
104    /// future, more bucket schemas may be added using numbers < -4 or >
105    /// 8.
106    #[prost(sint32, tag = "4")]
107    pub schema: i32,
108    /// Breadth of the zero bucket.
109    #[prost(double, tag = "5")]
110    pub zero_threshold: f64,
111    /// Negative Buckets.
112    #[prost(message, repeated, tag = "8")]
113    pub negative_spans: ::prost::alloc::vec::Vec<BucketSpan>,
114    /// Use either "negative_deltas" or "negative_counts", the former for
115    /// regular histograms with integer counts, the latter for float
116    /// histograms.
117    ///
118    /// Count delta of each bucket compared to previous one (or to zero for 1st bucket).
119    #[prost(sint64, repeated, tag = "9")]
120    pub negative_deltas: ::prost::alloc::vec::Vec<i64>,
121    /// Absolute count of each bucket.
122    #[prost(double, repeated, tag = "10")]
123    pub negative_counts: ::prost::alloc::vec::Vec<f64>,
124    /// Positive Buckets.
125    #[prost(message, repeated, tag = "11")]
126    pub positive_spans: ::prost::alloc::vec::Vec<BucketSpan>,
127    /// Use either "positive_deltas" or "positive_counts", the former for
128    /// regular histograms with integer counts, the latter for float
129    /// histograms.
130    ///
131    /// Count delta of each bucket compared to previous one (or to zero for 1st bucket).
132    #[prost(sint64, repeated, tag = "12")]
133    pub positive_deltas: ::prost::alloc::vec::Vec<i64>,
134    /// Absolute count of each bucket.
135    #[prost(double, repeated, tag = "13")]
136    pub positive_counts: ::prost::alloc::vec::Vec<f64>,
137    #[prost(enumeration = "histogram::ResetHint", tag = "14")]
138    pub reset_hint: i32,
139    /// timestamp is in ms format, see model/timestamp/timestamp.go for
140    /// conversion from time.Time to Prometheus timestamp.
141    #[prost(int64, tag = "15")]
142    pub timestamp: i64,
143    /// Count of observations in the histogram.
144    #[prost(oneof = "histogram::Count", tags = "1, 2")]
145    pub count: ::core::option::Option<histogram::Count>,
146    /// Count in zero bucket.
147    #[prost(oneof = "histogram::ZeroCount", tags = "6, 7")]
148    pub zero_count: ::core::option::Option<histogram::ZeroCount>,
149}
150/// Nested message and enum types in `Histogram`.
151pub mod histogram {
152    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
153    #[repr(i32)]
154    pub enum ResetHint {
155        /// Need to test for a counter reset explicitly.
156        Unknown = 0,
157        /// This is the 1st histogram after a counter reset.
158        Yes = 1,
159        /// There was no counter reset between this and the previous Histogram.
160        No = 2,
161        /// This is a gauge histogram where counter resets don't happen.
162        Gauge = 3,
163    }
164    impl ResetHint {
165        /// String value of the enum field names used in the ProtoBuf definition.
166        ///
167        /// The values are not transformed in any way and thus are considered stable
168        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
169        pub fn as_str_name(&self) -> &'static str {
170            match self {
171                ResetHint::Unknown => "UNKNOWN",
172                ResetHint::Yes => "YES",
173                ResetHint::No => "NO",
174                ResetHint::Gauge => "GAUGE",
175            }
176        }
177        /// Creates an enum from field names used in the ProtoBuf definition.
178        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
179            match value {
180                "UNKNOWN" => Some(Self::Unknown),
181                "YES" => Some(Self::Yes),
182                "NO" => Some(Self::No),
183                "GAUGE" => Some(Self::Gauge),
184                _ => None,
185            }
186        }
187    }
188    /// Count of observations in the histogram.
189    #[allow(clippy::derive_partial_eq_without_eq)]
190    #[derive(Clone, PartialEq, ::prost::Oneof)]
191    pub enum Count {
192        #[prost(uint64, tag = "1")]
193        CountInt(u64),
194        #[prost(double, tag = "2")]
195        CountFloat(f64),
196    }
197    /// Count in zero bucket.
198    #[allow(clippy::derive_partial_eq_without_eq)]
199    #[derive(Clone, PartialEq, ::prost::Oneof)]
200    pub enum ZeroCount {
201        #[prost(uint64, tag = "6")]
202        ZeroCountInt(u64),
203        #[prost(double, tag = "7")]
204        ZeroCountFloat(f64),
205    }
206}
207/// A BucketSpan defines a number of consecutive buckets with their
208/// offset. Logically, it would be more straightforward to include the
209/// bucket counts in the Span. However, the protobuf representation is
210/// more compact in the way the data is structured here (with all the
211/// buckets in a single array separate from the Spans).
212#[allow(clippy::derive_partial_eq_without_eq)]
213#[derive(Clone, PartialEq, ::prost::Message)]
214pub struct BucketSpan {
215    /// Gap to previous span, or starting point for 1st span (which can be negative).
216    #[prost(sint32, tag = "1")]
217    pub offset: i32,
218    /// Length of consecutive buckets.
219    #[prost(uint32, tag = "2")]
220    pub length: u32,
221}
222/// TimeSeries represents samples and labels for a single time series.
223#[allow(clippy::derive_partial_eq_without_eq)]
224#[derive(Clone, PartialEq, ::prost::Message)]
225pub struct TimeSeries {
226    /// For a timeseries to be valid, and for the samples and exemplars
227    /// to be ingested by the remote system properly, the labels field is required.
228    #[prost(message, repeated, tag = "1")]
229    pub labels: ::prost::alloc::vec::Vec<Label>,
230    #[prost(message, repeated, tag = "2")]
231    pub samples: ::prost::alloc::vec::Vec<Sample>,
232    #[prost(message, repeated, tag = "3")]
233    pub exemplars: ::prost::alloc::vec::Vec<Exemplar>,
234    #[prost(message, repeated, tag = "4")]
235    pub histograms: ::prost::alloc::vec::Vec<Histogram>,
236}
237#[allow(clippy::derive_partial_eq_without_eq)]
238#[derive(Clone, PartialEq, ::prost::Message)]
239pub struct Label {
240    #[prost(string, tag = "1")]
241    pub name: ::prost::alloc::string::String,
242    #[prost(string, tag = "2")]
243    pub value: ::prost::alloc::string::String,
244}
245#[allow(clippy::derive_partial_eq_without_eq)]
246#[derive(Clone, PartialEq, ::prost::Message)]
247pub struct Labels {
248    #[prost(message, repeated, tag = "1")]
249    pub labels: ::prost::alloc::vec::Vec<Label>,
250}
251/// Matcher specifies a rule, which can match or set of labels or not.
252#[allow(clippy::derive_partial_eq_without_eq)]
253#[derive(Clone, PartialEq, ::prost::Message)]
254pub struct LabelMatcher {
255    #[prost(enumeration = "label_matcher::Type", tag = "1")]
256    pub r#type: i32,
257    #[prost(string, tag = "2")]
258    pub name: ::prost::alloc::string::String,
259    #[prost(string, tag = "3")]
260    pub value: ::prost::alloc::string::String,
261}
262/// Nested message and enum types in `LabelMatcher`.
263pub mod label_matcher {
264    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
265    #[repr(i32)]
266    pub enum Type {
267        Eq = 0,
268        Neq = 1,
269        Re = 2,
270        Nre = 3,
271    }
272    impl Type {
273        /// String value of the enum field names used in the ProtoBuf definition.
274        ///
275        /// The values are not transformed in any way and thus are considered stable
276        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
277        pub fn as_str_name(&self) -> &'static str {
278            match self {
279                Type::Eq => "EQ",
280                Type::Neq => "NEQ",
281                Type::Re => "RE",
282                Type::Nre => "NRE",
283            }
284        }
285        /// Creates an enum from field names used in the ProtoBuf definition.
286        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
287            match value {
288                "EQ" => Some(Self::Eq),
289                "NEQ" => Some(Self::Neq),
290                "RE" => Some(Self::Re),
291                "NRE" => Some(Self::Nre),
292                _ => None,
293            }
294        }
295    }
296}
297#[allow(clippy::derive_partial_eq_without_eq)]
298#[derive(Clone, PartialEq, ::prost::Message)]
299pub struct ReadHints {
300    /// Query step size in milliseconds.
301    #[prost(int64, tag = "1")]
302    pub step_ms: i64,
303    /// String representation of surrounding function or aggregation.
304    #[prost(string, tag = "2")]
305    pub func: ::prost::alloc::string::String,
306    /// Start time in milliseconds.
307    #[prost(int64, tag = "3")]
308    pub start_ms: i64,
309    /// End time in milliseconds.
310    #[prost(int64, tag = "4")]
311    pub end_ms: i64,
312    /// List of label names used in aggregation.
313    #[prost(string, repeated, tag = "5")]
314    pub grouping: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
315    /// Indicate whether it is without or by.
316    #[prost(bool, tag = "6")]
317    pub by: bool,
318    /// Range vector selector range in milliseconds.
319    #[prost(int64, tag = "7")]
320    pub range_ms: i64,
321}
322/// Chunk represents a TSDB chunk.
323/// Time range [min, max] is inclusive.
324#[allow(clippy::derive_partial_eq_without_eq)]
325#[derive(Clone, PartialEq, ::prost::Message)]
326pub struct Chunk {
327    #[prost(int64, tag = "1")]
328    pub min_time_ms: i64,
329    #[prost(int64, tag = "2")]
330    pub max_time_ms: i64,
331    #[prost(enumeration = "chunk::Encoding", tag = "3")]
332    pub r#type: i32,
333    #[prost(bytes = "vec", tag = "4")]
334    pub data: ::prost::alloc::vec::Vec<u8>,
335}
336/// Nested message and enum types in `Chunk`.
337pub mod chunk {
338    /// We require this to match chunkenc.Encoding.
339    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
340    #[repr(i32)]
341    pub enum Encoding {
342        Unknown = 0,
343        Xor = 1,
344        Histogram = 2,
345    }
346    impl Encoding {
347        /// String value of the enum field names used in the ProtoBuf definition.
348        ///
349        /// The values are not transformed in any way and thus are considered stable
350        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
351        pub fn as_str_name(&self) -> &'static str {
352            match self {
353                Encoding::Unknown => "UNKNOWN",
354                Encoding::Xor => "XOR",
355                Encoding::Histogram => "HISTOGRAM",
356            }
357        }
358        /// Creates an enum from field names used in the ProtoBuf definition.
359        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
360            match value {
361                "UNKNOWN" => Some(Self::Unknown),
362                "XOR" => Some(Self::Xor),
363                "HISTOGRAM" => Some(Self::Histogram),
364                _ => None,
365            }
366        }
367    }
368}
369/// ChunkedSeries represents single, encoded time series.
370#[allow(clippy::derive_partial_eq_without_eq)]
371#[derive(Clone, PartialEq, ::prost::Message)]
372pub struct ChunkedSeries {
373    /// Labels should be sorted.
374    #[prost(message, repeated, tag = "1")]
375    pub labels: ::prost::alloc::vec::Vec<Label>,
376    /// Chunks will be in start time order and may overlap.
377    #[prost(message, repeated, tag = "2")]
378    pub chunks: ::prost::alloc::vec::Vec<Chunk>,
379}
380#[allow(clippy::derive_partial_eq_without_eq)]
381#[derive(Clone, PartialEq, ::prost::Message)]
382pub struct WriteRequest {
383    #[prost(message, repeated, tag = "1")]
384    pub timeseries: ::prost::alloc::vec::Vec<TimeSeries>,
385    #[prost(message, repeated, tag = "3")]
386    pub metadata: ::prost::alloc::vec::Vec<MetricMetadata>,
387}
388/// ReadRequest represents a remote read request.
389#[allow(clippy::derive_partial_eq_without_eq)]
390#[derive(Clone, PartialEq, ::prost::Message)]
391pub struct ReadRequest {
392    #[prost(message, repeated, tag = "1")]
393    pub queries: ::prost::alloc::vec::Vec<Query>,
394    /// accepted_response_types allows negotiating the content type of the response.
395    ///
396    /// Response types are taken from the list in the FIFO order. If no response type in `accepted_response_types` is
397    /// implemented by server, error is returned.
398    /// For request that do not contain `accepted_response_types` field the SAMPLES response type will be used.
399    #[prost(enumeration = "read_request::ResponseType", repeated, tag = "2")]
400    pub accepted_response_types: ::prost::alloc::vec::Vec<i32>,
401}
402/// Nested message and enum types in `ReadRequest`.
403pub mod read_request {
404    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
405    #[repr(i32)]
406    pub enum ResponseType {
407        /// Server will return a single ReadResponse message with matched series that includes list of raw samples.
408        /// It's recommended to use streamed response types instead.
409        ///
410        /// Response headers:
411        /// Content-Type: "application/x-protobuf"
412        /// Content-Encoding: "snappy"
413        Samples = 0,
414        /// Server will stream a delimited ChunkedReadResponse message that
415        /// contains XOR or HISTOGRAM(!) encoded chunks for a single series.
416        /// Each message is following varint size and fixed size bigendian
417        /// uint32 for CRC32 Castagnoli checksum.
418        ///
419        /// Response headers:
420        /// Content-Type: "application/x-streamed-protobuf; proto=prometheus.ChunkedReadResponse"
421        /// Content-Encoding: ""
422        StreamedXorChunks = 1,
423    }
424    impl ResponseType {
425        /// String value of the enum field names used in the ProtoBuf definition.
426        ///
427        /// The values are not transformed in any way and thus are considered stable
428        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
429        pub fn as_str_name(&self) -> &'static str {
430            match self {
431                ResponseType::Samples => "SAMPLES",
432                ResponseType::StreamedXorChunks => "STREAMED_XOR_CHUNKS",
433            }
434        }
435        /// Creates an enum from field names used in the ProtoBuf definition.
436        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
437            match value {
438                "SAMPLES" => Some(Self::Samples),
439                "STREAMED_XOR_CHUNKS" => Some(Self::StreamedXorChunks),
440                _ => None,
441            }
442        }
443    }
444}
445/// ReadResponse is a response when response_type equals SAMPLES.
446#[allow(clippy::derive_partial_eq_without_eq)]
447#[derive(Clone, PartialEq, ::prost::Message)]
448pub struct ReadResponse {
449    /// In same order as the request's queries.
450    #[prost(message, repeated, tag = "1")]
451    pub results: ::prost::alloc::vec::Vec<QueryResult>,
452}
453#[allow(clippy::derive_partial_eq_without_eq)]
454#[derive(Clone, PartialEq, ::prost::Message)]
455pub struct Query {
456    #[prost(int64, tag = "1")]
457    pub start_timestamp_ms: i64,
458    #[prost(int64, tag = "2")]
459    pub end_timestamp_ms: i64,
460    #[prost(message, repeated, tag = "3")]
461    pub matchers: ::prost::alloc::vec::Vec<LabelMatcher>,
462    #[prost(message, optional, tag = "4")]
463    pub hints: ::core::option::Option<ReadHints>,
464}
465#[allow(clippy::derive_partial_eq_without_eq)]
466#[derive(Clone, PartialEq, ::prost::Message)]
467pub struct QueryResult {
468    /// Samples within a time series must be ordered by time.
469    #[prost(message, repeated, tag = "1")]
470    pub timeseries: ::prost::alloc::vec::Vec<TimeSeries>,
471}
472/// ChunkedReadResponse is a response when response_type equals STREAMED_XOR_CHUNKS.
473/// We strictly stream full series after series, optionally split by time. This means that a single frame can contain
474/// partition of the single series, but once a new series is started to be streamed it means that no more chunks will
475/// be sent for previous one. Series are returned sorted in the same way TSDB block are internally.
476#[allow(clippy::derive_partial_eq_without_eq)]
477#[derive(Clone, PartialEq, ::prost::Message)]
478pub struct ChunkedReadResponse {
479    #[prost(message, repeated, tag = "1")]
480    pub chunked_series: ::prost::alloc::vec::Vec<ChunkedSeries>,
481    /// query_index represents an index of the query from ReadRequest.queries these chunks relates to.
482    #[prost(int64, tag = "2")]
483    pub query_index: i64,
484}