Skip to main content

datanode/
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
15use lazy_static::lazy_static;
16use prometheus::*;
17
18/// Region request type label.
19pub const REGION_REQUEST_TYPE: &str = "datanode_region_request_type";
20const REGION_REQUEST_CODE: &str = "code";
21
22pub const REGION_ROLE: &str = "region_role";
23pub const REGION_ID: &str = "region_id";
24pub const RESULT_TYPE: &str = "result";
25
26lazy_static! {
27    /// The elapsed time of handling a request in the region_server.
28    pub static ref HANDLE_REGION_REQUEST_ELAPSED: HistogramVec = register_histogram_vec!(
29        "greptime_datanode_handle_region_request_elapsed",
30        "datanode handle region request elapsed",
31        &[REGION_REQUEST_TYPE]
32    )
33    .unwrap();
34    /// The number of rows in region request received by region server, labeled with request type.
35    pub static ref REGION_CHANGED_ROW_COUNT: IntCounterVec = register_int_counter_vec!(
36        "greptime_datanode_region_changed_row_count",
37        "datanode region changed row count",
38        &[REGION_REQUEST_TYPE]
39    )
40    .unwrap();
41    /// The elapsed time since the last received heartbeat.
42    pub static ref LAST_RECEIVED_HEARTBEAT_ELAPSED: IntGauge = register_int_gauge!(
43        "greptime_last_received_heartbeat_lease_elapsed",
44        "last received heartbeat lease elapsed",
45    )
46    .unwrap();
47    /// The elapsed time since the last sent heartbeat.
48    pub static ref LAST_SENT_HEARTBEAT_ELAPSED: IntGauge = register_int_gauge!(
49        "greptime_last_sent_heartbeat_lease_elapsed",
50        "last sent heartbeat lease elapsed",
51    )
52    .unwrap();
53    pub static ref LEASE_EXPIRED_REGION: IntGaugeVec = register_int_gauge_vec!(
54        "greptime_lease_expired_region",
55        "lease expired region",
56        &[REGION_ID]
57    )
58    .unwrap();
59    /// The received region leases via heartbeat.
60    pub static ref HEARTBEAT_REGION_LEASES: IntGaugeVec = register_int_gauge_vec!(
61        "greptime_heartbeat_region_leases",
62        "received region leases via heartbeat",
63        &[REGION_ROLE]
64    )
65    .unwrap();
66    /// The number of heartbeats send by datanode.
67    pub static ref HEARTBEAT_SENT_COUNT: IntCounter = register_int_counter!(
68        "greptime_datanode_heartbeat_send_count",
69        "datanode heartbeat sent",
70    )
71    .unwrap();
72    /// The number of heartbeats received by datanode, labeled with result type.
73    pub static ref HEARTBEAT_RECV_COUNT: IntCounterVec = register_int_counter_vec!(
74        "greptime_datanode_heartbeat_recv_count",
75        "datanode heartbeat received",
76        &[RESULT_TYPE]
77    )
78    .unwrap();
79
80    /// Total count of failed region server requests.
81    pub static ref REGION_SERVER_REQUEST_FAILURE_COUNT: IntCounterVec = register_int_counter_vec!(
82        "greptime_datanode_region_request_fail_count",
83        "failed region server requests count",
84        &[REGION_REQUEST_TYPE]
85    )
86    .unwrap();
87
88    /// Failed region open attempts, including individual and batch requests.
89    /// Counts every request in an engine group when no individual results are available.
90    /// Failed retries count separately; explicitly ignored missing regions do not count.
91    pub static ref REGION_OPEN_FAILURES_TOTAL: IntCounterVec = register_int_counter_vec!(
92        "greptime_datanode_region_open_failures_total",
93        "Failed region open attempts, including retries and all requests in failed engine groups, excluding ignored missing regions",
94        &["engine", "status_code"]
95    )
96    .unwrap();
97
98    /// Total count of failed insert requests to region server, labeled with request
99    /// type and status code.
100    pub static ref REGION_SERVER_INSERT_FAIL_COUNT: IntCounterVec = register_int_counter_vec!(
101        "greptime_datanode_region_failed_insert_count",
102        "failed region server insert requests count",
103        &[REGION_REQUEST_TYPE, REGION_REQUEST_CODE]
104    )
105    .unwrap();
106
107    /// Remote dynamic filter update processing outcomes, labeled with the outcome.
108    pub static ref REMOTE_DYN_FILTER_UPDATE_OUTCOME_TOTAL: IntCounterVec = register_int_counter_vec!(
109        "greptime_datanode_remote_dyn_filter_update_outcome_total",
110        "remote dynamic filter update processing outcomes",
111        &["result"]
112    )
113    .unwrap();
114
115    /// Remote dynamic filter update drops, labeled with drop reason.
116    pub static ref REMOTE_DYN_FILTER_UPDATE_DROP_TOTAL: IntCounterVec = register_int_counter_vec!(
117        "greptime_datanode_remote_dyn_filter_update_drop_total",
118        "remote dynamic filter update drops by reason",
119        &["reason"]
120    )
121    .unwrap();
122
123    /// Remote dynamic filter unregister outcomes, labeled with the outcome.
124    pub static ref REMOTE_DYN_FILTER_UNREGISTER_TOTAL: IntCounterVec = register_int_counter_vec!(
125        "greptime_datanode_remote_dyn_filter_unregister_total",
126        "remote dynamic filter unregister outcomes",
127        &["result"]
128    )
129    .unwrap();
130
131    /// Current count of remote dynamic filter registry entries.
132    pub static ref REMOTE_DYN_FILTER_REGISTRY_ENTRIES: IntGauge = register_int_gauge!(
133        "greptime_datanode_remote_dyn_filter_registry_entries",
134        "current remote dynamic filter registry entry count",
135    )
136    .unwrap();
137
138    /// Remote dynamic filter accepted update payload bytes received.
139    pub static ref REMOTE_DYN_FILTER_PAYLOAD_BYTES: Histogram = register_histogram!(
140        "greptime_datanode_remote_dyn_filter_payload_bytes",
141        "remote dynamic filter accepted update payload bytes received",
142        vec![
143            128.0, 256.0, 512.0, 1024.0, 2048.0, 4096.0, 8192.0, 16384.0, 32768.0,
144            65536.0, 131072.0, 262144.0, 524288.0,
145        ]
146    )
147    .unwrap();
148}