1use lazy_static::lazy_static;
16use prometheus::*;
17
18lazy_static! {
19 pub static ref METRIC_META_KV_REQUEST_ELAPSED: HistogramVec = register_histogram_vec!(
21 "greptime_meta_kv_request_elapsed",
22 "meta kv request",
23 &["target", "op"]
24 )
25 .unwrap();
26 pub static ref METRIC_META_HEARTBEAT_CONNECTION_NUM: IntGauge = register_int_gauge!(
28 "greptime_meta_heartbeat_connection_num",
29 "meta heartbeat connection num"
30 )
31 .unwrap();
32 pub static ref METRIC_META_HANDLER_EXECUTE: HistogramVec =
34 register_histogram_vec!("greptime_meta_handler_execute", "meta handler execute", &["name"]).unwrap();
35 pub static ref METRIC_META_INACTIVE_REGIONS: IntGauge =
37 register_int_gauge!("greptime_meta_inactive_regions", "meta inactive regions").unwrap();
38 pub static ref METRIC_META_LEADER_CACHED_KV_LOAD_ELAPSED: HistogramVec =
40 register_histogram_vec!("greptime_meta_leader_cache_kv_load", "meta load cache", &["prefix"])
41 .unwrap();
42 pub static ref METRIC_META_KV_CACHE_HIT: IntCounterVec =
44 register_int_counter_vec!("greptime_meta_kv_cache_hit", "meta kv cache hit", &["op"]).unwrap();
45 pub static ref METRIC_META_KV_CACHE_MISS: IntCounterVec =
47 register_int_counter_vec!("greptime_meta_kv_cache_miss", "meta kv cache miss", &["op"]).unwrap();
48 pub static ref METRIC_META_HEARTBEAT_RECV: IntCounterVec =
50 register_int_counter_vec!("greptime_meta_heartbeat_recv", "heartbeats received by metasrv", &["pusher_key"]).unwrap();
51 pub static ref METRIC_META_HEARTBEAT_DROPPED: IntCounterVec =
53 register_int_counter_vec!("greptime_meta_heartbeat_dropped", "heartbeats dropped by metasrv", &["reason"]).unwrap();
54 pub static ref METRIC_META_REGION_MIGRATION_EXECUTE: HistogramVec =
56 register_histogram_vec!("greptime_meta_region_migration_execute", "meta region migration execute", &["state"]).unwrap();
57 pub static ref METRIC_META_REGION_MIGRATION_ERROR: IntCounterVec =
59 register_int_counter_vec!("greptime_meta_region_migration_error", "meta region migration abort", &["state", "error_type"]).unwrap();
60 pub static ref METRIC_META_REGION_MIGRATION_DATANODES: IntCounterVec =
62 register_int_counter_vec!("greptime_meta_region_migration_stat", "meta region migration stat", &["datanode_type", "datanode_id"]).unwrap();
63 pub static ref METRIC_META_REGION_MIGRATION_FAIL: IntCounter =
65 register_int_counter!("greptime_meta_region_migration_fail", "meta region migration fail").unwrap();
66 pub static ref METRIC_META_HEARTBEAT_STAT_MEMORY_SIZE: Histogram =
68 register_histogram!("greptime_meta_heartbeat_stat_memory_size", "meta heartbeat stat memory size", vec![
69 100.0, 500.0, 1000.0, 1500.0, 2000.0, 3000.0, 5000.0, 10000.0, 20000.0
70 ]).unwrap();
71 pub static ref METRIC_META_HEARTBEAT_RATE: IntCounter =
73 register_int_counter!("greptime_meta_heartbeat_rate", "meta heartbeat arrival rate").unwrap();
74 pub static ref METRIC_META_REMOTE_WAL_PRUNE_EXECUTE: IntCounterVec =
76 register_int_counter_vec!("greptime_meta_remote_wal_prune_execute", "meta remote wal prune execute", &["topic_name"]).unwrap();
77 pub static ref METRIC_META_REGION_MIGRATION_STAGE_ELAPSED: HistogramVec = register_histogram_vec!(
79 "greptime_meta_region_migration_stage_elapsed",
80 "meta region migration stage elapsed",
81 &["stage"],
82 exponential_buckets(0.01, 10.0, 7).unwrap(),
84 )
85 .unwrap();
86 pub static ref METRIC_META_TRIGGERED_REGION_FLUSH_TOTAL: IntCounterVec =
88 register_int_counter_vec!("meta_triggered_region_flush_total", "meta triggered region flush total", &["topic_name"]).unwrap();
89
90 pub static ref METRIC_META_TRIGGERED_REGION_CHECKPOINT_TOTAL: IntCounterVec =
92 register_int_counter_vec!("meta_triggered_region_checkpoint_total", "meta triggered region checkpoint total", &["topic_name"]).unwrap();
93 pub static ref METRIC_META_TOPIC_ESTIMATED_REPLAY_SIZE: IntGaugeVec =
95 register_int_gauge_vec!("meta_topic_estimated_replay_size", "meta topic estimated replay size", &["topic_name"]).unwrap();
96
97 pub static ref METRIC_META_GC_SCHEDULER_CYCLES_TOTAL: IntCounter = register_int_counter!(
99 "greptime_metasrv_gc_scheduler_cycles_total",
100 "Total GC scheduler cycles",
101 )
102 .unwrap();
103
104 pub static ref METRIC_META_GC_SCHEDULER_DURATION_SECONDS: Histogram = register_histogram!(
106 "greptime_metasrv_gc_scheduler_duration_seconds",
107 "Time for a full GC scheduler cycle",
108 vec![0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 30.0, 60.0, 120.0, 300.0],
109 )
110 .unwrap();
111
112 pub static ref METRIC_META_GC_CANDIDATE_REGIONS: IntGauge = register_int_gauge!(
114 "greptime_metasrv_gc_candidate_regions",
115 "Number of GC candidate regions",
116 )
117 .unwrap();
118
119 pub static ref METRIC_META_GC_DATANODE_CALLS_TOTAL: IntCounterVec = register_int_counter_vec!(
121 "greptime_metasrv_gc_datanode_calls_total",
122 "Calls to datanodes for GC",
123 &["operation", "status"],
124 )
125 .unwrap();
126
127 pub static ref METRIC_META_GC_FAILED_REGIONS_TOTAL: IntCounter = register_int_counter!(
129 "greptime_metasrv_gc_failed_regions_total",
130 "Total regions that failed GC",
131 )
132 .unwrap();
133
134}
135
136#[cfg(feature = "enterprise")]
137lazy_static! {
138 pub static ref METRIC_META_GC_SOFT_DROP_PURGES_TOTAL: IntCounterVec = register_int_counter_vec!(
140 "greptime_metasrv_gc_soft_drop_purges_total",
141 "Soft-drop purge submissions by status",
142 &["status"],
143 )
144 .unwrap();
145}