Skip to main content

flow/
metrics.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Some of the metrics used in the flow module.
16
17use lazy_static::lazy_static;
18use prometheus::*;
19
20lazy_static! {
21    pub static ref METRIC_FLOW_TASK_COUNT: IntGauge =
22        register_int_gauge!("greptime_flow_task_count", "flow task count").unwrap();
23    pub static ref METRIC_FLOW_BATCHING_ENGINE_QUERY_TIME: HistogramVec = register_histogram_vec!(
24        "greptime_flow_batching_engine_query_time_secs",
25        "flow batching engine query time(seconds)",
26        &["flow_id"],
27        vec![0.0, 5., 10., 20., 40., 80., 160., 320., 640.,]
28    )
29    .unwrap();
30    pub static ref METRIC_FLOW_BATCHING_ENGINE_SLOW_QUERY: HistogramVec = register_histogram_vec!(
31        "greptime_flow_batching_engine_slow_query_secs",
32        "flow batching engine slow query(seconds)",
33        &["flow_id", "peer"],
34        vec![60., 2. * 60., 3. * 60., 5. * 60., 10. * 60.]
35    )
36    .unwrap();
37    pub static ref METRIC_FLOW_BATCHING_ENGINE_QUERY_WINDOW_CNT: HistogramVec =
38        register_histogram_vec!(
39            "greptime_flow_batching_engine_query_window_cnt",
40            "flow batching engine query time window count",
41            &["flow_id"],
42            vec![0.0, 5., 10., 20., 40.]
43        )
44        .unwrap();
45    pub static ref METRIC_FLOW_BATCHING_ENGINE_QUERY_WINDOW_SIZE: HistogramVec =
46        register_histogram_vec!(
47            "greptime_flow_batching_engine_query_window_size_secs",
48            "flow batching engine query window size(seconds)",
49            &["flow_id"],
50            vec![60., 4. * 60., 16. * 60., 64. * 60., 256. * 60.]
51        )
52        .unwrap();
53    pub static ref METRIC_FLOW_BATCHING_ENGINE_STALLED_WINDOW_SIZE: HistogramVec =
54        register_histogram_vec!(
55            "greptime_flow_batching_engine_stalled_window_size_secs",
56            "flow batching engine stalled window size(seconds)",
57            &["flow_id"],
58            vec![60., 4. * 60., 16. * 60., 64. * 60., 256. * 60.]
59        )
60        .unwrap();
61    pub static ref METRIC_FLOW_BATCHING_ENGINE_BULK_MARK_TIME_WINDOW: GaugeVec =
62        register_gauge_vec!(
63            "greptime_flow_batching_engine_bulk_mark_time_window",
64            "flow batching engine query time window count marked by bulk inserts",
65            &["flow_id"],
66        )
67        .unwrap();
68    pub static ref METRIC_FLOW_BATCHING_ENGINE_START_QUERY_CNT: IntCounterVec =
69        register_int_counter_vec!(
70            "greptime_flow_batching_start_query_count",
71            "flow batching engine started query count",
72            &["flow_id"],
73        )
74        .unwrap();
75    pub static ref METRIC_FLOW_BATCHING_ENGINE_ERROR_CNT: IntCounterVec =
76        register_int_counter_vec!(
77            "greptime_flow_batching_error_count",
78            "flow batching engine error count per flow id",
79            &["flow_id"],
80        )
81        .unwrap();
82    pub static ref METRIC_FLOW_BATCHING_ENGINE_CHECKPOINT_DECISION_CNT: IntCounterVec =
83        register_int_counter_vec!(
84            "greptime_flow_batching_checkpoint_decision_count",
85            "flow batching checkpoint state-machine decisions",
86            &["flow_id", "mode", "decision", "reason"],
87        )
88        .unwrap();
89    pub static ref METRIC_FLOW_BATCHING_ENGINE_QUERY_MODE_CNT: IntCounterVec =
90        register_int_counter_vec!(
91            "greptime_flow_batching_query_mode_count",
92            "flow batching query attempts by checkpoint mode",
93            &["flow_id", "mode"],
94        )
95        .unwrap();
96    pub static ref METRIC_FLOW_ROWS: IntCounterVec = register_int_counter_vec!(
97        "greptime_flow_processed_rows",
98        "Count of rows flowing through the system.",
99        &["direction"]
100    )
101    .unwrap();
102    pub static ref METRIC_FLOW_PROCESSING_TIME: HistogramVec = register_histogram_vec!(
103        "greptime_flow_processing_time",
104        "Time spent processing requests",
105        &["type"]
106    )
107    .unwrap();
108}