prom_types/
lib.rs

1#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
2pub struct MetricMetadata {
3    /// Represents the metric type, these match the set from Prometheus.
4    /// Refer to pkg/textparse/interface.go for details.
5    #[prost(enumeration = "metric_metadata::MetricType", tag = "1")]
6    pub r#type: i32,
7    #[prost(string, tag = "2")]
8    pub metric_family_name: ::prost::alloc::string::String,
9    #[prost(string, tag = "4")]
10    pub help: ::prost::alloc::string::String,
11    #[prost(string, tag = "5")]
12    pub unit: ::prost::alloc::string::String,
13}
14/// Nested message and enum types in `MetricMetadata`.
15pub mod metric_metadata {
16    #[derive(
17        serde::Serialize,
18        serde::Deserialize,
19        Clone,
20        Copy,
21        Debug,
22        PartialEq,
23        Eq,
24        Hash,
25        PartialOrd,
26        Ord,
27        ::prost::Enumeration,
28    )]
29    #[repr(i32)]
30    pub enum MetricType {
31        Unknown = 0,
32        Counter = 1,
33        Gauge = 2,
34        Histogram = 3,
35        Gaugehistogram = 4,
36        Summary = 5,
37        Info = 6,
38        Stateset = 7,
39    }
40}
41#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
42pub struct Sample {
43    #[serde(skip_serializing_if = "Option::is_none")]
44    #[prost(double, optional, tag = "1")]
45    pub value: Option<f64>,
46    #[prost(int64, tag = "2")]
47    pub timestamp: i64,
48}
49/// TimeSeries represents samples and labels for a single time series.
50#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
51pub struct TimeSeries {
52    #[prost(message, repeated, tag = "1")]
53    pub labels: ::prost::alloc::vec::Vec<Label>,
54    #[prost(message, repeated, tag = "2")]
55    pub samples: ::prost::alloc::vec::Vec<Sample>,
56}
57#[derive(serde::Serialize, serde::Deserialize, Hash, Eq, Clone, PartialEq, ::prost::Message)]
58pub struct Label {
59    #[prost(string, tag = "1")]
60    pub name: ::prost::alloc::string::String,
61    #[prost(string, tag = "2")]
62    pub value: ::prost::alloc::string::String,
63}
64#[derive(serde::Serialize, serde::Deserialize, Hash, Clone, PartialEq, ::prost::Message)]
65pub struct Labels {
66    #[prost(message, repeated, tag = "1")]
67    pub labels: ::prost::alloc::vec::Vec<Label>,
68}
69/// Matcher specifies a rule, which can match or set of labels or not.
70#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
71#[serde(default)]
72pub struct LabelMatcher {
73    #[prost(enumeration = "label_matcher::Type", tag = "1")]
74    pub r#type: i32,
75    #[prost(string, tag = "2")]
76    pub name: ::prost::alloc::string::String,
77    #[prost(string, tag = "3")]
78    pub value: ::prost::alloc::string::String,
79}
80/// Nested message and enum types in `LabelMatcher`.
81pub mod label_matcher {
82    #[derive(
83        serde::Serialize,
84        serde::Deserialize,
85        Clone,
86        Copy,
87        Debug,
88        PartialEq,
89        Eq,
90        Hash,
91        PartialOrd,
92        Ord,
93        ::prost::Enumeration,
94    )]
95    #[repr(i32)]
96    pub enum Type {
97        Eq = 0,
98        Neq = 1,
99        Re = 2,
100        Nre = 3,
101    }
102}
103#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
104#[serde(default)]
105pub struct ReadHints {
106    /// Query step size in milliseconds.
107    #[prost(int64, optional, tag = "1")]
108    pub step_ms: Option<i64>,
109    /// String representation of surrounding function or aggregation.
110    #[prost(string, tag = "2")]
111    pub func: ::prost::alloc::string::String,
112    /// Start time in milliseconds.
113    #[prost(int64, tag = "3")]
114    pub start_ms: i64,
115    /// End time in milliseconds.
116    #[prost(int64, tag = "4")]
117    pub end_ms: i64,
118    /// List of label names used in aggregation.
119    #[prost(string, repeated, tag = "5")]
120    pub grouping: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
121    /// Indicate whether it is without or by.
122    #[prost(bool, tag = "6")]
123    pub by: bool,
124    /// Range vector selector range in milliseconds.
125    #[prost(int64, optional, tag = "7")]
126    pub range_ms: Option<i64>,
127}
128/// Chunk represents a TSDB chunk.
129/// Time range [min, max] is inclusive.
130#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
131pub struct Chunk {
132    #[prost(int64, tag = "1")]
133    pub min_time_ms: i64,
134    #[prost(int64, tag = "2")]
135    pub max_time_ms: i64,
136    #[prost(enumeration = "chunk::Encoding", tag = "3")]
137    pub r#type: i32,
138    #[prost(bytes = "vec", tag = "4")]
139    pub data: ::prost::alloc::vec::Vec<u8>,
140}
141/// Nested message and enum types in `Chunk`.
142pub mod chunk {
143    /// We require this to match chunkenc.Encoding.
144    #[derive(
145        serde::Serialize,
146        serde::Deserialize,
147        Clone,
148        Copy,
149        Debug,
150        PartialEq,
151        Eq,
152        Hash,
153        PartialOrd,
154        Ord,
155        ::prost::Enumeration,
156    )]
157    #[repr(i32)]
158    pub enum Encoding {
159        Unknown = 0,
160        Xor = 1,
161    }
162}
163/// ChunkedSeries represents single, encoded time series.
164#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
165pub struct ChunkedSeries {
166    /// Labels should be sorted.
167    #[prost(message, repeated, tag = "1")]
168    pub labels: ::prost::alloc::vec::Vec<Label>,
169    /// Chunks will be in start time order and may overlap.
170    #[prost(message, repeated, tag = "2")]
171    pub chunks: ::prost::alloc::vec::Vec<Chunk>,
172}
173#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
174pub struct WriteRequest {
175    #[prost(message, repeated, tag = "1")]
176    pub timeseries: ::prost::alloc::vec::Vec<TimeSeries>,
177    #[prost(message, repeated, tag = "3")]
178    pub metadata: ::prost::alloc::vec::Vec<MetricMetadata>,
179}
180/// ReadRequest represents a remote read request.
181#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
182#[serde(default)]
183pub struct ReadRequest {
184    #[prost(message, repeated, tag = "1")]
185    pub queries: ::prost::alloc::vec::Vec<Query>,
186    /// accepted_response_types allows negotiating the content type of the response.
187    ///
188    /// Response types are taken from the list in the FIFO order. If no response type in `accepted_response_types` is
189    /// implemented by server, error is returned.
190    /// For request that do not contain `accepted_response_types` field the SAMPLES response type will be used.
191    #[prost(enumeration = "read_request::ResponseType", repeated, tag = "2")]
192    pub accepted_response_types: ::prost::alloc::vec::Vec<i32>,
193}
194/// Nested message and enum types in `ReadRequest`.
195pub mod read_request {
196    #[derive(
197        serde::Serialize,
198        serde::Deserialize,
199        Clone,
200        Copy,
201        Debug,
202        PartialEq,
203        Eq,
204        Hash,
205        PartialOrd,
206        Ord,
207        ::prost::Enumeration,
208    )]
209    #[repr(i32)]
210    pub enum ResponseType {
211        /// Server will return a single ReadResponse message with matched series that includes list of raw samples.
212        /// It's recommended to use streamed response types instead.
213        ///
214        /// Response headers:
215        /// Content-Type: "application/x-protobuf"
216        /// Content-Encoding: "snappy"
217        Samples = 0,
218        /// Server will stream a delimited ChunkedReadResponse message that contains XOR encoded chunks for a single series.
219        /// Each message is following varint size and fixed size bigendian uint32 for CRC32 Castagnoli checksum.
220        ///
221        /// Response headers:
222        /// Content-Type: "application/x-streamed-protobuf; proto=prometheus.ChunkedReadResponse"
223        /// Content-Encoding: ""
224        StreamedXorChunks = 1,
225    }
226}
227/// ReadResponse is a response when response_type equals SAMPLES.
228#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
229pub struct ReadResponse {
230    /// In same order as the request's queries.
231    #[prost(message, repeated, tag = "1")]
232    pub results: ::prost::alloc::vec::Vec<QueryResult>,
233}
234#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
235pub struct Query {
236    #[prost(int64, tag = "1")]
237    pub start_timestamp_ms: i64,
238    #[prost(int64, tag = "2")]
239    pub end_timestamp_ms: i64,
240    #[prost(message, repeated, tag = "3")]
241    pub matchers: ::prost::alloc::vec::Vec<LabelMatcher>,
242    #[prost(message, optional, tag = "4")]
243    pub hints: ::core::option::Option<ReadHints>,
244}
245#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
246pub struct QueryResult {
247    /// Samples within a time series must be ordered by time.
248    #[prost(message, repeated, tag = "1")]
249    pub timeseries: ::prost::alloc::vec::Vec<TimeSeries>,
250}
251/// ChunkedReadResponse is a response when response_type equals STREAMED_XOR_CHUNKS.
252/// We strictly stream full series after series, optionally split by time. This means that a single frame can contain
253/// partition of the single series, but once a new series is started to be streamed it means that no more chunks will
254/// be sent for previous one. Series are returned sorted in the same way TSDB block are internally.
255#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
256pub struct ChunkedReadResponse {
257    #[prost(message, repeated, tag = "1")]
258    pub chunked_series: ::prost::alloc::vec::Vec<ChunkedSeries>,
259    /// query_index represents an index of the query from ReadRequest.queries these chunks relates to.
260    #[prost(int64, tag = "2")]
261    pub query_index: i64,
262}