proq/query_types.rs
1//!
2//! Request types that are sent by the Proq to different endpoints.
3use serde::*;
4
5///
6/// Instant query request struct
7#[derive(Serialize, Deserialize, Debug, Clone)]
8pub struct InstantQuery {
9 /// PromQL Query which will be sent to API
10 pub query: String,
11 /// Evaluation timestamp in unix timestamp format
12 pub time: Option<i64>,
13 /// Timeout duration for evaluating the result
14 pub timeout: Option<String>,
15}
16
17///
18/// Range query request struct
19#[derive(Serialize, Deserialize, Debug, Clone)]
20pub struct RangeQuery {
21 /// PromQL Query which will be sent to API
22 pub query: String,
23 /// Start timestamp for the range query
24 pub start: Option<i64>,
25 /// End timestamp for the range query
26 pub end: Option<i64>,
27 /// Step as duration in the range in seconds as 64-bit floating point format
28 pub step: Option<f64>,
29 /// Timeout duration for evaluating the result
30 pub timeout: Option<String>,
31}
32
33///
34/// Series query request struct
35#[derive(Serialize, Deserialize, Debug, Clone)]
36pub struct SeriesRequest {
37 /// List of series selectors
38 #[serde(rename(serialize = "match[]"))]
39 pub selectors: Vec<String>,
40 /// Start timestamp for the range query
41 pub start: Option<i64>,
42 /// End timestamp for the range query
43 pub end: Option<i64>,
44 /// Timeout duration for evaluating the result
45 pub timeout: Option<String>,
46}
47
48///
49/// Possible Prometheus target states.
50#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)]
51#[serde(rename_all = "lowercase")]
52pub enum ProqTargetStates {
53 /// Target state filtered by Active state
54 ACTIVE,
55 /// Target state filtered by Dropped state
56 DROPPED,
57 /// Target state without any filtering
58 ANY,
59}
60
61///
62/// Target with filtered state request.
63#[derive(Serialize, Deserialize, Debug, Clone)]
64pub struct TargetsWithStatesRequest {
65 /// Requested target state filter
66 pub state: ProqTargetStates,
67}
68
69///
70/// Possible Prometheus rule types.
71#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)]
72#[serde(rename_all = "lowercase")]
73pub enum ProqRulesType {
74 /// Rule type filtered by Alert
75 ALERT,
76 /// Rule type filtered by Record
77 RECORD,
78}
79
80///
81/// Rules with filtered state request.
82#[derive(Serialize, Deserialize, Debug, Clone)]
83pub struct RulesWithTypeRequest {
84 /// Requested target state filter
85 #[serde(rename = "type")]
86 pub rule_type: ProqRulesType,
87}