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
93 pub static ref METRIC_OBJECT_STORE_WAL_SKIPPED_SEGMENTS_TOTAL: IntCounter = register_int_counter!(
96 "greptime_logstore_object_store_wal_skipped_segments_total",
97 "object store logstore skipped corrupted segments total",
98 )
99 .unwrap();
100 pub static ref METRIC_OBJECT_STORE_WAL_DELETED_OBJECTS_TOTAL: IntCounter = register_int_counter!(
103 "greptime_logstore_object_store_wal_deleted_objects_total",
104 "object store logstore deleted objects total",
105 )
106 .unwrap();
107 pub static ref METRIC_OBJECT_STORE_WAL_FAILED_DELETES_TOTAL: IntCounter = register_int_counter!(
110 "greptime_logstore_object_store_wal_failed_deletes_total",
111 "object store logstore failed object deletes total",
112 )
113 .unwrap();
114 pub static ref METRIC_OBJECT_STORE_WAL_RELEASE_RECORDS_TOTAL: IntCounter = register_int_counter!(
117 "greptime_logstore_object_store_wal_release_records_total",
118 "object store logstore release records made durable total",
119 )
120 .unwrap();
121
122 pub static ref METRIC_OBJECT_STORE_WAL_SEAL_TO_DURABLE_SECONDS: Histogram = register_histogram!(
131 "greptime_logstore_object_store_wal_seal_to_durable_seconds",
132 "object store logstore seconds from sealing a batch to the success of its conditional create, slot waits and retries included",
133 exponential_buckets(0.001, 2.0, 14).unwrap(),
134 )
135 .unwrap();
136
137 pub static ref METRIC_OBJECT_STORE_WAL_APPEND_ACK_SECONDS: Histogram = register_histogram!(
145 "greptime_logstore_object_store_wal_append_ack_seconds",
146 "object store logstore seconds an append waits for its acknowledgement in the durable mode",
147 exponential_buckets(0.002, 2.0, 14).unwrap(),
148 )
149 .unwrap();
150
151 pub static ref METRIC_OBJECT_STORE_WAL_OBJECT_BYTES: Histogram = register_histogram!(
158 "greptime_logstore_object_store_wal_object_bytes",
159 "object store logstore bytes of each object sealed",
160 exponential_buckets(1024.0, 2.0, 15).unwrap(),
161 )
162 .unwrap();
163
164 pub static ref METRIC_OBJECT_STORE_WAL_OBJECT_ENTRIES: Histogram = register_histogram!(
171 "greptime_logstore_object_store_wal_object_entries",
172 "object store logstore entries of each object sealed",
173 exponential_buckets(1.0, 4.0, 11).unwrap(),
174 )
175 .unwrap();
176
177 pub static ref METRIC_OBJECT_STORE_WAL_CREATED_OBJECTS_TOTAL: IntCounter = register_int_counter!(
182 "greptime_logstore_object_store_wal_created_objects_total",
183 "object store logstore conditional creates that succeeded, identical retries included",
184 )
185 .unwrap();
186
187 pub static ref METRIC_OBJECT_STORE_WAL_INDEXED_OBJECTS: IntGauge = register_int_gauge!(
190 "greptime_logstore_object_store_wal_indexed_objects",
191 "object store logstore objects currently indexed",
192 )
193 .unwrap();
194
195 pub static ref METRIC_OBJECT_STORE_WAL_INDEXED_BYTES: IntGauge = register_int_gauge!(
198 "greptime_logstore_object_store_wal_indexed_bytes",
199 "object store logstore bytes currently indexed",
200 )
201 .unwrap();
202
203 pub static ref METRIC_OBJECT_STORE_WAL_RECOVERY_SECONDS: Histogram = register_histogram!(
210 "greptime_logstore_object_store_wal_recovery_seconds",
211 "object store logstore seconds spent by a recovery that succeeded",
212 exponential_buckets(0.01, 3.0, 10).unwrap(),
213 )
214 .unwrap();
215
216 pub static ref METRIC_OBJECT_STORE_WAL_RECOVERED_OBJECTS_TOTAL: IntCounter = register_int_counter!(
221 "greptime_logstore_object_store_wal_recovered_objects_total",
222 "object store logstore objects read by a recovery that succeeded total",
223 )
224 .unwrap();
225
226 pub static ref METRIC_OBJECT_STORE_WAL_READ_SECONDS: Histogram = register_histogram!(
233 "greptime_logstore_object_store_wal_read_seconds",
234 "object store logstore seconds spent serving a region read that ran to its end",
235 exponential_buckets(0.005, 3.0, 10).unwrap(),
236 )
237 .unwrap();
238
239 pub static ref METRIC_OBJECT_STORE_WAL_CREATE_CONFLICTS_TOTAL: IntCounter = register_int_counter!(
244 "greptime_logstore_object_store_wal_create_conflicts_total",
245 "object store logstore conflicting conditional creates total",
246 )
247 .unwrap();
248
249 pub static ref METRIC_OBJECT_STORE_WAL_CREATE_FAILURES_TOTAL: IntCounter = register_int_counter!(
253 "greptime_logstore_object_store_wal_create_failures_total",
254 "object store logstore conditional creates the object store did not confirm total",
255 )
256 .unwrap();
257
258 pub static ref METRIC_OBJECT_STORE_WAL_POISONED_TOTAL: IntCounter = register_int_counter!(
261 "greptime_logstore_object_store_wal_poisoned_total",
262 "object store logstores poisoned total",
263 )
264 .unwrap();
265
266 pub static ref METRIC_OBJECT_STORE_WAL_STALLED_APPENDS_TOTAL: IntCounter = register_int_counter!(
272 "greptime_logstore_object_store_wal_stalled_appends_total",
273 "object store logstore appends stalled by full sealed batches or the backlog thresholds total",
274 )
275 .unwrap();
276
277 pub static ref METRIC_OBJECT_STORE_WAL_STALLED_APPEND_SECONDS: Histogram = register_histogram!(
285 "greptime_logstore_object_store_wal_stalled_append_seconds",
286 "object store logstore seconds a stalled append is held back before it is admitted or refused",
287 exponential_buckets(0.005, 3.0, 9).unwrap(),
288 )
289 .unwrap();
290
291 pub static ref METRIC_OBJECT_STORE_WAL_FAILING: IntGauge = register_int_gauge!(
297 "greptime_logstore_object_store_wal_failing",
298 "object store logstores rejecting appends because the object store refuses their backlog with an error that requires intervention",
299 )
300 .unwrap();
301
302 pub static ref METRIC_OBJECT_STORE_WAL_REJECTED_APPENDS_TOTAL: IntCounter = register_int_counter!(
307 "greptime_logstore_object_store_wal_rejected_appends_total",
308 "object store logstore appends rejected while the object store refuses the backlog total",
309 )
310 .unwrap();
311}