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_INPUT_BUF_SIZE: IntGauge =
24        register_int_gauge!("greptime_flow_input_buf_size", "flow input buf size").unwrap();
25    pub static ref METRIC_FLOW_INSERT_ELAPSED: HistogramVec = register_histogram_vec!(
26        "greptime_flow_insert_elapsed",
27        "flow insert elapsed",
28        &["table_id"]
29    )
30    .unwrap();
31    pub static ref METRIC_FLOW_BATCHING_ENGINE_QUERY_TIME: HistogramVec = register_histogram_vec!(
32        "greptime_flow_batching_engine_query_time_secs",
33        "flow batching engine query time(seconds)",
34        &["flow_id"],
35        vec![0.0, 5., 10., 20., 40., 80., 160., 320., 640.,]
36    )
37    .unwrap();
38    pub static ref METRIC_FLOW_BATCHING_ENGINE_SLOW_QUERY: HistogramVec = register_histogram_vec!(
39        "greptime_flow_batching_engine_slow_query_secs",
40        "flow batching engine slow query(seconds)",
41        &["flow_id", "peer"],
42        vec![60., 2. * 60., 3. * 60., 5. * 60., 10. * 60.]
43    )
44    .unwrap();
45    pub static ref METRIC_FLOW_BATCHING_ENGINE_QUERY_WINDOW_CNT: HistogramVec =
46        register_histogram_vec!(
47            "greptime_flow_batching_engine_query_window_cnt",
48            "flow batching engine query time window count",
49            &["flow_id"],
50            vec![0.0, 5., 10., 20., 40.]
51        )
52        .unwrap();
53    pub static ref METRIC_FLOW_BATCHING_ENGINE_QUERY_TIME_RANGE: HistogramVec =
54        register_histogram_vec!(
55            "greptime_flow_batching_engine_query_time_range_secs",
56            "flow batching engine query time range(seconds)",
57            &["flow_id"],
58            vec![60., 4. * 60., 16. * 60., 64. * 60., 256. * 60.]
59        )
60        .unwrap();
61    pub static ref METRIC_FLOW_RUN_INTERVAL_MS: IntGauge =
62        register_int_gauge!("greptime_flow_run_interval_ms", "flow run interval in ms").unwrap();
63    pub static ref METRIC_FLOW_ROWS: IntCounterVec = register_int_counter_vec!(
64        "greptime_flow_processed_rows",
65        "Count of rows flowing through the system",
66        &["direction"]
67    )
68    .unwrap();
69    pub static ref METRIC_FLOW_PROCESSING_TIME: HistogramVec = register_histogram_vec!(
70        "greptime_flow_processing_time",
71        "Time spent processing requests",
72        &["type"]
73    )
74    .unwrap();
75    pub static ref METRIC_FLOW_ERRORS: IntCounterVec = register_int_counter_vec!(
76        "greptime_flow_errors",
77        "Count of errors in flow processing",
78        &["code"]
79    )
80    .unwrap();
81}