Skip to main content

frontend/
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
18lazy_static! {
19    /// Timer of handling query in RPC handler.
20    pub static ref GRPC_HANDLE_QUERY_ELAPSED: HistogramVec = register_histogram_vec!(
21        "greptime_frontend_grpc_handle_query_elapsed",
22        "Elapsed time of handling queries in RPC handler",
23        &["type"],
24        vec![0.005, 0.01, 0.05, 0.1, 0.5, 1.0, 5.0, 10.0, 60.0, 300.0]
25    )
26    .unwrap();
27    pub static ref GRPC_HANDLE_SQL_ELAPSED: Histogram = GRPC_HANDLE_QUERY_ELAPSED
28        .with_label_values(&["sql"]);
29    pub static ref GRPC_HANDLE_PLAN_ELAPSED: Histogram = GRPC_HANDLE_QUERY_ELAPSED
30        .with_label_values(&["plan"]);
31    pub static ref GRPC_HANDLE_PROMQL_ELAPSED: Histogram = GRPC_HANDLE_QUERY_ELAPSED
32        .with_label_values(&["promql"]);
33
34    pub static ref PROMQL_QUERY_METRICS_ELAPSED: HistogramVec = register_histogram_vec!(
35        "greptime_frontend_promql_query_metrics_elapsed",
36        "frontend promql query metric names elapsed",
37        &["db"]
38    )
39    .unwrap();
40
41    /// The number of OpenTelemetry metrics send by frontend node.
42    pub static ref OTLP_METRICS_ROWS: IntCounter = register_int_counter!(
43        "greptime_frontend_otlp_metrics_rows",
44        "frontend otlp metrics rows"
45    )
46    .unwrap();
47
48    /// Failed writes of the synthesized OTLP resource descriptor table; these
49    /// surface as OTLP partial-success warnings, not request failures.
50    pub static ref OTLP_RESOURCE_INFO_WRITE_ERRORS: IntCounter = register_int_counter!(
51        "greptime_frontend_otlp_resource_info_write_errors",
52        "frontend otlp resource descriptor write errors"
53    )
54    .unwrap();
55
56    /// The number of OpenTelemetry traces send by frontend node.
57    pub static ref OTLP_TRACES_ROWS: IntCounter = register_int_counter!(
58        "greptime_frontend_otlp_traces_rows",
59        "frontend otlp traces rows"
60    )
61    .unwrap();
62
63    /// The number of OpenTelemetry trace ingest failures on the frontend node.
64    pub static ref OTLP_TRACES_FAILURE_COUNT: IntCounterVec = register_int_counter_vec!(
65        "greptime_frontend_otlp_traces_failure_count",
66        "frontend otlp trace ingest failure count",
67        &["label"]
68    )
69    .unwrap();
70
71    /// The number of OpenTelemetry logs send by frontend node.
72    pub static ref OTLP_LOGS_ROWS: IntCounter = register_int_counter!(
73        "greptime_frontend_otlp_logs_rows",
74        "frontend otlp logs rows"
75    )
76    .unwrap();
77
78    /// The number of heartbeats send by frontend node.
79    pub static ref HEARTBEAT_SENT_COUNT: IntCounter = register_int_counter!(
80        "greptime_frontend_heartbeat_send_count",
81        "frontend heartbeat sent",
82    )
83    .unwrap();
84    /// The number of heartbeats received by frontend node, labeled with result type.
85    pub static ref HEARTBEAT_RECV_COUNT: IntCounterVec = register_int_counter_vec!(
86        "greptime_frontend_heartbeat_recv_count",
87        "frontend heartbeat received",
88        &["result"]
89    )
90    .unwrap();
91}