1use lazy_static::lazy_static;
16use prometheus::*;
17
18pub const LOGSTORE_LABEL: &str = "logstore";
20pub const OPTYPE_LABEL: &str = "optype";
22pub const TOPIC_LABEL: &str = "topic";
24pub const PARTITION_LABEL: &str = "partition";
26
27lazy_static! {
28 pub static ref METRIC_LOGSTORE_OP_BYTES_TOTAL: IntCounterVec = register_int_counter_vec!(
30 "greptime_logstore_op_bytes_total",
31 "logstore operation bytes total",
32 &[LOGSTORE_LABEL, OPTYPE_LABEL],
33 )
34 .unwrap();
35 pub static ref METRIC_KAFKA_APPEND_BATCH_BYTES_TOTAL: IntCounter = METRIC_LOGSTORE_OP_BYTES_TOTAL.with_label_values(
37 &["kafka", "append_batch"],
38 );
39 pub static ref METRIC_KAFKA_READ_BYTES_TOTAL: IntCounter = METRIC_LOGSTORE_OP_BYTES_TOTAL.with_label_values(
41 &["kafka", "read"],
42 );
43 pub static ref METRIC_RAFT_ENGINE_APPEND_BATCH_BYTES_TOTAL: IntCounter = METRIC_LOGSTORE_OP_BYTES_TOTAL.with_label_values(
45 &["raft-engine", "append_batch"],
46 );
47 pub static ref METRIC_RAFT_ENGINE_READ_BYTES_TOTAL: IntCounter = METRIC_LOGSTORE_OP_BYTES_TOTAL.with_label_values(
49 &["raft-engine", "read"],
50 );
51
52 pub static ref METRIC_LOGSTORE_OP_ELAPSED: HistogramVec = register_histogram_vec!(
54 "greptime_logstore_op_elapsed",
55 "logstore operation elapsed",
56 &[LOGSTORE_LABEL, OPTYPE_LABEL],
57 vec![
58 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0, 15.0, 20.0, 30.0,
59 45.0, 60.0,
60 ],
61 )
62 .unwrap();
63 pub static ref METRIC_KAFKA_APPEND_BATCH_ELAPSED: Histogram = METRIC_LOGSTORE_OP_ELAPSED.with_label_values(&["kafka", "append_batch"]);
65 pub static ref METRIC_KAFKA_READ_ELAPSED: Histogram = METRIC_LOGSTORE_OP_ELAPSED.with_label_values(&["kafka", "read"]);
68 pub static ref METRIC_RAFT_ENGINE_APPEND_BATCH_ELAPSED: Histogram = METRIC_LOGSTORE_OP_ELAPSED.with_label_values(&["raft-engine", "append_batch"]);
70 pub static ref METRIC_RAFT_ENGINE_READ_ELAPSED: Histogram = METRIC_LOGSTORE_OP_ELAPSED.with_label_values(&["raft-engine", "read"]);
73
74 pub static ref METRIC_KAFKA_CLIENT_BYTES_TOTAL: IntCounterVec = register_int_counter_vec!(
75 "greptime_logstore_kafka_client_bytes_total",
76 "kafka logstore's bytes traffic total",
77 &[LOGSTORE_LABEL, PARTITION_LABEL],
78 )
79 .unwrap();
80 pub static ref METRIC_KAFKA_CLIENT_TRAFFIC_TOTAL: IntCounterVec = register_int_counter_vec!(
81 "greptime_logstore_kafka_client_traffic_total",
82 "kafka logstore's request count traffic total",
83 &[LOGSTORE_LABEL, PARTITION_LABEL],
84 )
85 .unwrap();
86 pub static ref METRIC_KAFKA_CLIENT_PRODUCE_ELAPSED: HistogramVec = register_histogram_vec!(
87 "greptime_logstore_kafka_client_produce_elapsed",
88 "kafka logstore produce operation elapsed",
89 &[LOGSTORE_LABEL, PARTITION_LABEL],
90 )
91 .unwrap();
92}