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";
20
21pub const REGION_ROLE: &str = "region_role";
22pub const REGION_ID: &str = "region_id";
23pub const RESULT_TYPE: &str = "result";
24
25lazy_static! {
26    /// The elapsed time of handling a request in the region_server.
27    pub static ref HANDLE_REGION_REQUEST_ELAPSED: HistogramVec = register_histogram_vec!(
28        "greptime_datanode_handle_region_request_elapsed",
29        "datanode handle region request elapsed",
30        &[REGION_ID, REGION_REQUEST_TYPE]
31    )
32    .unwrap();
33    /// The number of rows in region request received by region server, labeled with request type.
34    pub static ref REGION_CHANGED_ROW_COUNT: IntCounterVec = register_int_counter_vec!(
35        "greptime_datanode_region_changed_row_count",
36        "datanode region changed row count",
37        &[REGION_ID, REGION_REQUEST_TYPE]
38    )
39    .unwrap();
40    /// The elapsed time since the last received heartbeat.
41    pub static ref LAST_RECEIVED_HEARTBEAT_ELAPSED: IntGauge = register_int_gauge!(
42        "greptime_last_received_heartbeat_lease_elapsed",
43        "last received heartbeat lease elapsed",
44    )
45    .unwrap();
46    /// The elapsed time since the last sent heartbeat.
47    pub static ref LAST_SENT_HEARTBEAT_ELAPSED: IntGauge = register_int_gauge!(
48        "greptime_last_sent_heartbeat_lease_elapsed",
49        "last sent heartbeat lease elapsed",
50    )
51    .unwrap();
52    pub static ref LEASE_EXPIRED_REGION: IntGaugeVec = register_int_gauge_vec!(
53        "greptime_lease_expired_region",
54        "lease expired region",
55        &[REGION_ID]
56    )
57    .unwrap();
58    /// The received region leases via heartbeat.
59    pub static ref HEARTBEAT_REGION_LEASES: IntGaugeVec = register_int_gauge_vec!(
60        "greptime_heartbeat_region_leases",
61        "received region leases via heartbeat",
62        &[REGION_ROLE]
63    )
64    .unwrap();
65    /// The number of heartbeats send by datanode.
66    pub static ref HEARTBEAT_SENT_COUNT: IntCounter = register_int_counter!(
67        "greptime_datanode_heartbeat_send_count",
68        "datanode heartbeat sent",
69    )
70    .unwrap();
71    /// The number of heartbeats received by datanode, labeled with result type.
72    pub static ref HEARTBEAT_RECV_COUNT: IntCounterVec = register_int_counter_vec!(
73        "greptime_datanode_heartbeat_recv_count",
74        "datanode heartbeat received",
75        &[RESULT_TYPE]
76    )
77    .unwrap();
78}