1use common_frontend::metrics::{CACHE_HIT, CACHE_MISS};
16use lazy_static::lazy_static;
17use prometheus::*;
18
19lazy_static! {
20 pub static ref GRPC_HANDLE_QUERY_ELAPSED: HistogramVec = register_histogram_vec!(
22 "greptime_frontend_grpc_handle_query_elapsed",
23 "Elapsed time of handling queries in RPC handler",
24 &["type"],
25 vec![0.005, 0.01, 0.05, 0.1, 0.5, 1.0, 5.0, 10.0, 60.0, 300.0]
26 )
27 .unwrap();
28 pub static ref GRPC_HANDLE_SQL_ELAPSED: Histogram = GRPC_HANDLE_QUERY_ELAPSED
29 .with_label_values(&["sql"]);
30 pub static ref GRPC_HANDLE_PLAN_ELAPSED: Histogram = GRPC_HANDLE_QUERY_ELAPSED
31 .with_label_values(&["plan"]);
32 pub static ref GRPC_HANDLE_PROMQL_ELAPSED: Histogram = GRPC_HANDLE_QUERY_ELAPSED
33 .with_label_values(&["promql"]);
34
35 pub static ref PROMQL_QUERY_METRICS_ELAPSED: HistogramVec = register_histogram_vec!(
36 "greptime_frontend_promql_query_metrics_elapsed",
37 "frontend promql query metric names elapsed",
38 &["db"]
39 )
40 .unwrap();
41
42 pub static ref OTLP_METRICS_ROWS: IntCounter = register_int_counter!(
44 "greptime_frontend_otlp_metrics_rows",
45 "frontend otlp metrics rows"
46 )
47 .unwrap();
48
49 pub static ref OTLP_RESOURCE_INFO_WRITE_ERRORS: IntCounter = register_int_counter!(
52 "greptime_frontend_otlp_resource_info_write_errors",
53 "frontend otlp resource descriptor write errors"
54 )
55 .unwrap();
56
57 pub static ref OTLP_TRACES_ROWS: IntCounter = register_int_counter!(
59 "greptime_frontend_otlp_traces_rows",
60 "frontend otlp traces rows"
61 )
62 .unwrap();
63
64 pub static ref OTLP_TRACES_FAILURE_COUNT: IntCounterVec = register_int_counter_vec!(
66 "greptime_frontend_otlp_traces_failure_count",
67 "frontend otlp trace ingest failure count",
68 &["label"]
69 )
70 .unwrap();
71
72 pub static ref OTLP_TRACE_AUX_CACHE_HIT: IntCounter =
74 CACHE_HIT.with_label_values(&["otlp_trace_aux"]);
75 pub static ref OTLP_TRACE_AUX_CACHE_MISS: IntCounter =
76 CACHE_MISS.with_label_values(&["otlp_trace_aux"]);
77
78 pub static ref OTLP_LOGS_ROWS: IntCounter = register_int_counter!(
80 "greptime_frontend_otlp_logs_rows",
81 "frontend otlp logs rows"
82 )
83 .unwrap();
84
85 pub static ref HEARTBEAT_SENT_COUNT: IntCounter = register_int_counter!(
87 "greptime_frontend_heartbeat_send_count",
88 "frontend heartbeat sent",
89 )
90 .unwrap();
91 pub static ref HEARTBEAT_RECV_COUNT: IntCounterVec = register_int_counter_vec!(
93 "greptime_frontend_heartbeat_recv_count",
94 "frontend heartbeat received",
95 &["result"]
96 )
97 .unwrap();
98}