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", "sql", "peer"],
42        vec![60., 2. * 60., 3. * 60., 5. * 60., 10. * 60.]
43    )
44    .unwrap();
45    pub static ref METRIC_FLOW_RUN_INTERVAL_MS: IntGauge =
46        register_int_gauge!("greptime_flow_run_interval_ms", "flow run interval in ms").unwrap();
47    pub static ref METRIC_FLOW_ROWS: IntCounterVec = register_int_counter_vec!(
48        "greptime_flow_processed_rows",
49        "Count of rows flowing through the system",
50        &["direction"]
51    )
52    .unwrap();
53    pub static ref METRIC_FLOW_PROCESSING_TIME: HistogramVec = register_histogram_vec!(
54        "greptime_flow_processing_time",
55        "Time spent processing requests",
56        &["type"]
57    )
58    .unwrap();
59    pub static ref METRIC_FLOW_ERRORS: IntCounterVec = register_int_counter_vec!(
60        "greptime_flow_errors",
61        "Count of errors in flow processing",
62        &["code"]
63    )
64    .unwrap();
65}