be/src/common/metrics/doris_metrics.cpp
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #include "common/metrics/doris_metrics.h" |
19 | | |
20 | | // IWYU pragma: no_include <bthread/errno.h> |
21 | | #include <errno.h> // IWYU pragma: keep |
22 | | #include <glog/logging.h> |
23 | | #include <inttypes.h> |
24 | | #include <stdio.h> |
25 | | #include <stdlib.h> |
26 | | #include <string.h> |
27 | | #include <unistd.h> |
28 | | |
29 | | #include <algorithm> |
30 | | #include <functional> |
31 | | #include <ostream> |
32 | | |
33 | | #include "common/metrics/metrics.h" |
34 | | #include "common/metrics/system_metrics.h" |
35 | | #include "common/status.h" |
36 | | #include "io/fs/local_file_system.h" |
37 | | |
38 | | namespace doris { |
39 | | namespace io { |
40 | | struct FileInfo; |
41 | | } // namespace io |
42 | | |
43 | | DEFINE_COUNTER_METRIC_PROTOTYPE_3ARG(fragment_requests_total, MetricUnit::REQUESTS, |
44 | | "Total fragment requests received."); |
45 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(fragment_request_duration_us, MetricUnit::MICROSECONDS); |
46 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(query_scan_bytes, MetricUnit::BYTES); |
47 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(query_scan_bytes_from_local, MetricUnit::BYTES); |
48 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(query_scan_bytes_from_remote, MetricUnit::BYTES); |
49 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(query_scan_rows, MetricUnit::ROWS); |
50 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(query_scan_count, MetricUnit::NOUNIT); |
51 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(push_requests_success_total, MetricUnit::REQUESTS, "", |
52 | | push_requests_total, Labels({{"status", "SUCCESS"}})); |
53 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(push_requests_fail_total, MetricUnit::REQUESTS, "", |
54 | | push_requests_total, Labels({{"status", "FAIL"}})); |
55 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(push_request_duration_us, MetricUnit::MICROSECONDS); |
56 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(push_request_write_bytes, MetricUnit::BYTES); |
57 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(push_request_write_rows, MetricUnit::ROWS); |
58 | | |
59 | | #define DEFINE_ENGINE_COUNTER_METRIC(name, type, status) \ |
60 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(name, MetricUnit::REQUESTS, "", engine_requests_total, \ |
61 | | Labels({{"type", #type}, {"status", #status}})); |
62 | | |
63 | | DEFINE_ENGINE_COUNTER_METRIC(create_tablet_requests_total, create_tablet, total); |
64 | | DEFINE_ENGINE_COUNTER_METRIC(create_tablet_requests_failed, create_tablet, failed); |
65 | | DEFINE_ENGINE_COUNTER_METRIC(drop_tablet_requests_total, drop_tablet, total); |
66 | | DEFINE_ENGINE_COUNTER_METRIC(report_all_tablets_requests_skip, report_all_tablets, skip) |
67 | | DEFINE_ENGINE_COUNTER_METRIC(schema_change_requests_total, schema_change, total); |
68 | | DEFINE_ENGINE_COUNTER_METRIC(schema_change_requests_failed, schema_change, failed); |
69 | | DEFINE_ENGINE_COUNTER_METRIC(create_rollup_requests_total, create_rollup, total); |
70 | | DEFINE_ENGINE_COUNTER_METRIC(create_rollup_requests_failed, create_rollup, failed); |
71 | | DEFINE_ENGINE_COUNTER_METRIC(storage_migrate_requests_total, storage_migrate, total); |
72 | | DEFINE_ENGINE_COUNTER_METRIC(storage_migrate_v2_requests_total, storage_migrate_v2, total); |
73 | | DEFINE_ENGINE_COUNTER_METRIC(storage_migrate_v2_requests_failed, storage_migrate_v2, failed); |
74 | | DEFINE_ENGINE_COUNTER_METRIC(delete_requests_total, delete, total); |
75 | | DEFINE_ENGINE_COUNTER_METRIC(delete_requests_failed, delete, failed); |
76 | | DEFINE_ENGINE_COUNTER_METRIC(clone_requests_total, clone, total); |
77 | | DEFINE_ENGINE_COUNTER_METRIC(clone_requests_failed, clone, failed); |
78 | | DEFINE_ENGINE_COUNTER_METRIC(finish_task_requests_total, finish_task, total); |
79 | | DEFINE_ENGINE_COUNTER_METRIC(finish_task_requests_failed, finish_task, failed); |
80 | | DEFINE_ENGINE_COUNTER_METRIC(base_compaction_request_total, base_compaction, total); |
81 | | DEFINE_ENGINE_COUNTER_METRIC(base_compaction_request_failed, base_compaction, failed); |
82 | | DEFINE_ENGINE_COUNTER_METRIC(single_compaction_request_total, single_compaction, total); |
83 | | DEFINE_ENGINE_COUNTER_METRIC(single_compaction_request_failed, single_compaction, failed); |
84 | | DEFINE_ENGINE_COUNTER_METRIC(single_compaction_request_cancelled, single_compaction, cancelled); |
85 | | DEFINE_ENGINE_COUNTER_METRIC(cumulative_compaction_request_total, cumulative_compaction, total); |
86 | | DEFINE_ENGINE_COUNTER_METRIC(cumulative_compaction_request_failed, cumulative_compaction, failed); |
87 | | DEFINE_ENGINE_COUNTER_METRIC(publish_task_request_total, publish, total); |
88 | | DEFINE_ENGINE_COUNTER_METRIC(publish_task_failed_total, publish, failed); |
89 | | DEFINE_ENGINE_COUNTER_METRIC(alter_inverted_index_requests_total, alter_inverted_index, total); |
90 | | DEFINE_ENGINE_COUNTER_METRIC(alter_inverted_index_requests_failed, alter_inverted_index, failed); |
91 | | |
92 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(base_compaction_deltas_total, MetricUnit::ROWSETS, "", |
93 | | compaction_deltas_total, Labels({{"type", "base"}})); |
94 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(cumulative_compaction_deltas_total, MetricUnit::ROWSETS, "", |
95 | | compaction_deltas_total, Labels({{"type", "cumulative"}})); |
96 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(full_compaction_deltas_total, MetricUnit::ROWSETS, "", |
97 | | compaction_deltas_total, Labels({{"type", "full"}})); |
98 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(base_compaction_bytes_total, MetricUnit::BYTES, "", |
99 | | compaction_bytes_total, Labels({{"type", "base"}})); |
100 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(cumulative_compaction_bytes_total, MetricUnit::BYTES, "", |
101 | | compaction_bytes_total, Labels({{"type", "cumulative"}})); |
102 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(full_compaction_bytes_total, MetricUnit::BYTES, "", |
103 | | compaction_bytes_total, Labels({{"type", "full"}})); |
104 | | |
105 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(base_compaction_task_running_total, MetricUnit::ROWSETS, "", |
106 | | compaction_task_state_total, Labels({{"type", "base"}})); |
107 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(base_compaction_task_pending_total, MetricUnit::ROWSETS, "", |
108 | | compaction_task_state_total, Labels({{"type", "base"}})); |
109 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(cumulative_compaction_task_running_total, MetricUnit::ROWSETS, |
110 | | "", compaction_task_state_total, |
111 | | Labels({{"type", "cumulative"}})); |
112 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(cumulative_compaction_task_pending_total, MetricUnit::ROWSETS, |
113 | | "", compaction_task_state_total, |
114 | | Labels({{"type", "cumulative"}})); |
115 | | |
116 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(segment_read_total, MetricUnit::OPERATIONS, |
117 | | "(segment_v2) total number of segments read", segment_read, |
118 | | Labels({{"type", "segment_read_total"}})); |
119 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG( |
120 | | segment_row_total, MetricUnit::ROWS, |
121 | | "(segment_v2) total number of rows in queried segments (before index pruning)", |
122 | | segment_read, Labels({{"type", "segment_row_total"}})); |
123 | | |
124 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(condition_cache_search_count, MetricUnit::OPERATIONS, |
125 | | "number of condition cache lookups when digest != 0", |
126 | | condition_cache, Labels({{"type", "condition_cache_search"}})); |
127 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(condition_cache_hit_count, MetricUnit::OPERATIONS, |
128 | | "number of condition cache hits", condition_cache, |
129 | | Labels({{"type", "condition_cache_hit"}})); |
130 | | |
131 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_load_txn_begin_request_total, MetricUnit::OPERATIONS, |
132 | | "", stream_load_txn_request, Labels({{"type", "begin"}})); |
133 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_load_txn_commit_request_total, MetricUnit::OPERATIONS, |
134 | | "", stream_load_txn_request, Labels({{"type", "commit"}})); |
135 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_load_txn_rollback_request_total, MetricUnit::OPERATIONS, |
136 | | "", stream_load_txn_request, Labels({{"type", "rollback"}})); |
137 | | |
138 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_receive_bytes_total, MetricUnit::BYTES, "", stream_load, |
139 | | Labels({{"type", "receive_bytes"}})); |
140 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_load_rows_total, MetricUnit::ROWS, "", stream_load, |
141 | | Labels({{"type", "load_rows"}})); |
142 | | |
143 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(compaction_producer_callback_a_round_time, |
144 | | MetricUnit::ROWSETS); |
145 | | |
146 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(local_compaction_read_rows_total, MetricUnit::ROWS, "", |
147 | | compaction_rows_total, Labels({{"type", "read"}})); |
148 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(local_compaction_read_bytes_total, MetricUnit::BYTES, "", |
149 | | compaction_bytes_total, Labels({{"type", "read"}})); |
150 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(local_compaction_write_rows_total, MetricUnit::ROWS, "", |
151 | | compaction_rows_total, Labels({{"type", "write"}})); |
152 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(local_compaction_write_bytes_total, MetricUnit::BYTES, "", |
153 | | compaction_bytes_total, Labels({{"type", "write"}})); |
154 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(remote_compaction_read_rows_total, MetricUnit::ROWS, "", |
155 | | compaction_rows_total, Labels({{"type", "read"}})); |
156 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(remote_compaction_read_bytes_total, MetricUnit::BYTES, "", |
157 | | compaction_bytes_total, Labels({{"type", "read"}})); |
158 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(remote_compaction_write_rows_total, MetricUnit::ROWS, "", |
159 | | compaction_rows_total, Labels({{"type", "write"}})); |
160 | | DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(remote_compaction_write_bytes_total, MetricUnit::BYTES, "", |
161 | | compaction_bytes_total, Labels({{"type", "write"}})); |
162 | | |
163 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(load_rows, MetricUnit::ROWS); |
164 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(load_bytes, MetricUnit::BYTES); |
165 | | |
166 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_get_msg_latency, MetricUnit::MILLISECONDS); |
167 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_get_msg_count, MetricUnit::NOUNIT); |
168 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_consume_rows, MetricUnit::ROWS); |
169 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_consume_bytes, MetricUnit::BYTES); |
170 | | |
171 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(memtable_flush_total, MetricUnit::OPERATIONS); |
172 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(memtable_flush_duration_us, MetricUnit::MICROSECONDS); |
173 | | |
174 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(memory_pool_bytes_total, MetricUnit::BYTES); |
175 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(process_thread_num, MetricUnit::NOUNIT); |
176 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(process_fd_num_used, MetricUnit::NOUNIT); |
177 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(process_fd_num_limit_soft, MetricUnit::NOUNIT); |
178 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(process_fd_num_limit_hard, MetricUnit::NOUNIT); |
179 | | |
180 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(tablet_cumulative_max_compaction_score, MetricUnit::NOUNIT); |
181 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(tablet_base_max_compaction_score, MetricUnit::NOUNIT); |
182 | | |
183 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(all_rowsets_num, MetricUnit::NOUNIT); |
184 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(all_segments_num, MetricUnit::NOUNIT); |
185 | | |
186 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(compaction_used_permits, MetricUnit::NOUNIT); |
187 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(compaction_waitting_permits, MetricUnit::NOUNIT); |
188 | | |
189 | | DEFINE_HISTOGRAM_METRIC_PROTOTYPE_2ARG(tablet_version_num_distribution, MetricUnit::NOUNIT); |
190 | | |
191 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(query_scan_bytes_per_second, MetricUnit::BYTES); |
192 | | |
193 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(readable_blocks_total, MetricUnit::BLOCKS); |
194 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(writable_blocks_total, MetricUnit::BLOCKS); |
195 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(blocks_created_total, MetricUnit::OPERATIONS); |
196 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(blocks_deleted_total, MetricUnit::OPERATIONS); |
197 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(bytes_read_total, MetricUnit::BYTES); |
198 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(bytes_written_total, MetricUnit::BYTES); |
199 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(disk_sync_total, MetricUnit::OPERATIONS); |
200 | | |
201 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(blocks_open_reading, MetricUnit::BLOCKS); |
202 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(blocks_open_writing, MetricUnit::BLOCKS); |
203 | | |
204 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(query_cache_memory_total_byte, MetricUnit::BYTES); |
205 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(query_cache_sql_total_count, MetricUnit::NOUNIT); |
206 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(query_cache_partition_total_count, MetricUnit::NOUNIT); |
207 | | |
208 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(upload_total_byte, MetricUnit::BYTES); |
209 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(upload_rowset_count, MetricUnit::ROWSETS); |
210 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(upload_fail_count, MetricUnit::ROWSETS); |
211 | | |
212 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(local_file_reader_total, MetricUnit::FILESYSTEM); |
213 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_file_reader_total, MetricUnit::FILESYSTEM); |
214 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(hdfs_file_reader_total, MetricUnit::FILESYSTEM); |
215 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(broker_file_reader_total, MetricUnit::FILESYSTEM); |
216 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(local_file_writer_total, MetricUnit::FILESYSTEM); |
217 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_file_writer_total, MetricUnit::FILESYSTEM); |
218 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(file_created_total, MetricUnit::FILESYSTEM); |
219 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_file_created_total, MetricUnit::FILESYSTEM); |
220 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(local_bytes_read_total, MetricUnit::FILESYSTEM); |
221 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_bytes_read_total, MetricUnit::FILESYSTEM); |
222 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(local_bytes_written_total, MetricUnit::FILESYSTEM); |
223 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_bytes_written_total, MetricUnit::FILESYSTEM); |
224 | | |
225 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(local_file_open_reading, MetricUnit::FILESYSTEM); |
226 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(s3_file_open_reading, MetricUnit::FILESYSTEM); |
227 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(hdfs_file_open_reading, MetricUnit::FILESYSTEM); |
228 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(broker_file_open_reading, MetricUnit::FILESYSTEM); |
229 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(local_file_open_writing, MetricUnit::FILESYSTEM); |
230 | | DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(s3_file_open_writing, MetricUnit::FILESYSTEM); |
231 | | |
232 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(num_io_bytes_read_total, MetricUnit::OPERATIONS); |
233 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(num_io_bytes_read_from_cache, MetricUnit::OPERATIONS); |
234 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(num_io_bytes_read_from_remote, MetricUnit::OPERATIONS); |
235 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(num_io_bytes_read_from_peer, MetricUnit::OPERATIONS); |
236 | | |
237 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(udf_close_bthread_count, MetricUnit::OPERATIONS); |
238 | | |
239 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(query_ctx_cnt, MetricUnit::NOUNIT); |
240 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(scanner_ctx_cnt, MetricUnit::NOUNIT); |
241 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(scanner_cnt, MetricUnit::NOUNIT); |
242 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(scanner_task_cnt, MetricUnit::NOUNIT); |
243 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(pipeline_task_queue_size, MetricUnit::NOUNIT); |
244 | | |
245 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(runtime_filter_consumer_num, MetricUnit::NOUNIT); |
246 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(runtime_filter_consumer_ready_num, MetricUnit::NOUNIT); |
247 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(runtime_filter_consumer_wait_ready_ms, |
248 | | MetricUnit::MILLISECONDS); |
249 | | DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(runtime_filter_consumer_timeout_num, MetricUnit::NOUNIT); |
250 | | |
251 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(get_remote_tablet_slow_time_ms, MetricUnit::MILLISECONDS); |
252 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(get_remote_tablet_slow_cnt, MetricUnit::NOUNIT); |
253 | | |
254 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_load_costs_ms, MetricUnit::MILLISECONDS); |
255 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_load_cnt, MetricUnit::NOUNIT); |
256 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_search_costs_ms, MetricUnit::MILLISECONDS); |
257 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_search_cnt, MetricUnit::NOUNIT); |
258 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_in_memory_cnt, MetricUnit::NOUNIT); |
259 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_in_memory_rows_cnt, MetricUnit::ROWS); |
260 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_construction, MetricUnit::NOUNIT); |
261 | | DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_build_index_threads, MetricUnit::NOUNIT); |
262 | | |
263 | | const std::string DorisMetrics::_s_registry_name = "doris_be"; |
264 | | const std::string DorisMetrics::_s_hook_name = "doris_metrics"; |
265 | | |
266 | 8 | DorisMetrics::DorisMetrics() : _metric_registry(_s_registry_name) { |
267 | 8 | _server_metric_entity = _metric_registry.register_entity("server"); |
268 | | |
269 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, fragment_requests_total); |
270 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, fragment_request_duration_us); |
271 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_scan_bytes); |
272 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_scan_bytes_from_local); |
273 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_scan_bytes_from_remote); |
274 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_scan_rows); |
275 | | |
276 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_requests_success_total); |
277 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_requests_fail_total); |
278 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_request_duration_us); |
279 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_request_write_bytes); |
280 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_request_write_rows); |
281 | | |
282 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, compaction_producer_callback_a_round_time); |
283 | | |
284 | | // engine_requests_total |
285 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, create_tablet_requests_total); |
286 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, create_tablet_requests_failed); |
287 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, drop_tablet_requests_total); |
288 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, report_all_tablets_requests_skip); |
289 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, schema_change_requests_total); |
290 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, schema_change_requests_failed); |
291 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, create_rollup_requests_total); |
292 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, create_rollup_requests_failed); |
293 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, storage_migrate_requests_total); |
294 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, storage_migrate_v2_requests_total); |
295 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, storage_migrate_v2_requests_failed); |
296 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, delete_requests_total); |
297 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, delete_requests_failed); |
298 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, clone_requests_total); |
299 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, clone_requests_failed); |
300 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, finish_task_requests_total); |
301 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, finish_task_requests_failed); |
302 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_request_total); |
303 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_request_failed); |
304 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_request_total); |
305 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_request_failed); |
306 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, single_compaction_request_total); |
307 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, single_compaction_request_failed); |
308 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, single_compaction_request_cancelled); |
309 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, publish_task_request_total); |
310 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, publish_task_failed_total); |
311 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, alter_inverted_index_requests_total); |
312 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, alter_inverted_index_requests_failed); |
313 | | |
314 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_compaction_read_rows_total); |
315 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_compaction_read_bytes_total); |
316 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_compaction_write_rows_total); |
317 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_compaction_write_bytes_total); |
318 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, remote_compaction_read_rows_total); |
319 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, remote_compaction_read_bytes_total); |
320 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, remote_compaction_write_rows_total); |
321 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, remote_compaction_write_bytes_total); |
322 | | |
323 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_deltas_total); |
324 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_bytes_total); |
325 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_deltas_total); |
326 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_bytes_total); |
327 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, full_compaction_deltas_total); |
328 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, full_compaction_bytes_total); |
329 | | |
330 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_task_running_total); |
331 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_task_pending_total); |
332 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_task_running_total); |
333 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_task_pending_total); |
334 | | |
335 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, segment_read_total); |
336 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, condition_cache_search_count); |
337 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, condition_cache_hit_count); |
338 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, segment_row_total); |
339 | | |
340 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_load_txn_begin_request_total); |
341 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_load_txn_commit_request_total); |
342 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_load_txn_rollback_request_total); |
343 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_receive_bytes_total); |
344 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_load_rows_total); |
345 | | |
346 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_get_msg_latency); |
347 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_get_msg_count); |
348 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_consume_bytes); |
349 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_consume_rows); |
350 | | |
351 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, memtable_flush_total); |
352 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, memtable_flush_duration_us); |
353 | | |
354 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, memory_pool_bytes_total); |
355 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, process_thread_num); |
356 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, process_fd_num_used); |
357 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, process_fd_num_limit_soft); |
358 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, process_fd_num_limit_hard); |
359 | | |
360 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, tablet_cumulative_max_compaction_score); |
361 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, tablet_base_max_compaction_score); |
362 | | |
363 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, all_rowsets_num); |
364 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, all_segments_num); |
365 | | |
366 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, compaction_used_permits); |
367 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, compaction_waitting_permits); |
368 | | |
369 | 8 | HISTOGRAM_METRIC_REGISTER(_server_metric_entity, tablet_version_num_distribution); |
370 | | |
371 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, query_scan_bytes_per_second); |
372 | | |
373 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, load_rows); |
374 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, load_bytes); |
375 | | |
376 | 8 | INT_UGAUGE_METRIC_REGISTER(_server_metric_entity, upload_total_byte); |
377 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, upload_rowset_count); |
378 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, upload_fail_count); |
379 | | |
380 | 8 | _server_metric_entity->register_hook(_s_hook_name, std::bind(&DorisMetrics::_update, this)); |
381 | | |
382 | 8 | INT_UGAUGE_METRIC_REGISTER(_server_metric_entity, query_cache_memory_total_byte); |
383 | 8 | INT_UGAUGE_METRIC_REGISTER(_server_metric_entity, query_cache_sql_total_count); |
384 | 8 | INT_UGAUGE_METRIC_REGISTER(_server_metric_entity, query_cache_partition_total_count); |
385 | | |
386 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_file_reader_total); |
387 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_file_reader_total); |
388 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, hdfs_file_reader_total); |
389 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, broker_file_reader_total); |
390 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_file_writer_total); |
391 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_file_writer_total); |
392 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, file_created_total); |
393 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_file_created_total); |
394 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_bytes_read_total); |
395 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_bytes_read_total); |
396 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_bytes_written_total); |
397 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_bytes_written_total); |
398 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, local_file_open_reading); |
399 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, s3_file_open_reading); |
400 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, hdfs_file_open_reading); |
401 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, broker_file_open_reading); |
402 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, local_file_open_writing); |
403 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, s3_file_open_writing); |
404 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, num_io_bytes_read_total); |
405 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, num_io_bytes_read_from_cache); |
406 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, num_io_bytes_read_from_remote); |
407 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, num_io_bytes_read_from_peer); |
408 | | |
409 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, udf_close_bthread_count); |
410 | | |
411 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_ctx_cnt); |
412 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, scanner_ctx_cnt); |
413 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, scanner_cnt); |
414 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, scanner_task_cnt); |
415 | | |
416 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, runtime_filter_consumer_num); |
417 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, runtime_filter_consumer_ready_num); |
418 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, runtime_filter_consumer_wait_ready_ms); |
419 | 8 | INT_GAUGE_METRIC_REGISTER(_server_metric_entity, runtime_filter_consumer_timeout_num); |
420 | | |
421 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, get_remote_tablet_slow_time_ms); |
422 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, get_remote_tablet_slow_cnt); |
423 | | |
424 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, pipeline_task_queue_size); |
425 | | |
426 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_load_costs_ms); |
427 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_load_cnt); |
428 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_search_costs_ms); |
429 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_search_cnt); |
430 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_in_memory_cnt); |
431 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_in_memory_rows_cnt); |
432 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_construction); |
433 | 8 | INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_build_index_threads); |
434 | 8 | } |
435 | | |
436 | | void DorisMetrics::initialize(bool init_system_metrics, const std::set<std::string>& disk_devices, |
437 | 7 | const std::vector<std::string>& network_interfaces) { |
438 | 7 | if (init_system_metrics) { |
439 | 3 | _system_metrics.reset( |
440 | 3 | new SystemMetrics(&_metric_registry, disk_devices, network_interfaces)); |
441 | 3 | } |
442 | 7 | } |
443 | | |
444 | 7 | void DorisMetrics::init_jvm_metrics() { |
445 | 7 | _jvm_metrics.reset(new JvmMetrics(&_metric_registry)); |
446 | 7 | } |
447 | | |
448 | 400 | void DorisMetrics::_update() { |
449 | 400 | _update_process_thread_num(); |
450 | 400 | _update_process_fd_num(); |
451 | 400 | } |
452 | | |
453 | | // get num of thread of doris_be process |
454 | | // from /proc/self/task |
455 | 400 | void DorisMetrics::_update_process_thread_num() { |
456 | 400 | std::error_code ec; |
457 | 400 | std::filesystem::directory_iterator dict_iter("/proc/self/task/", ec); |
458 | 400 | if (ec) { |
459 | 0 | LOG(WARNING) << "failed to count thread num: " << ec.message(); |
460 | 0 | process_thread_num->set_value(0); |
461 | 0 | return; |
462 | 0 | } |
463 | 400 | int64_t count = |
464 | 1.03M | std::count_if(dict_iter, std::filesystem::end(dict_iter), [](const auto& entry) { |
465 | 1.03M | std::error_code error_code; |
466 | 1.03M | return entry.is_directory(error_code) && !error_code; |
467 | 1.03M | }); |
468 | | |
469 | 400 | process_thread_num->set_value(count); |
470 | 400 | } |
471 | | |
472 | | // get num of file descriptor of doris_be process |
473 | 400 | void DorisMetrics::_update_process_fd_num() { |
474 | | // fd used |
475 | 400 | std::error_code ec; |
476 | 400 | std::filesystem::directory_iterator dict_iter("/proc/self/fd/", ec); |
477 | 400 | if (ec) { |
478 | 0 | LOG(WARNING) << "failed to count fd: " << ec.message(); |
479 | 0 | process_fd_num_used->set_value(0); |
480 | 0 | return; |
481 | 0 | } |
482 | 400 | int64_t count = |
483 | 1.02M | std::count_if(dict_iter, std::filesystem::end(dict_iter), [](const auto& entry) { |
484 | 1.02M | std::error_code error_code; |
485 | 1.02M | return entry.is_regular_file(error_code) && !error_code; |
486 | 1.02M | }); |
487 | | |
488 | 400 | process_fd_num_used->set_value(count); |
489 | | |
490 | | // fd limits |
491 | 400 | FILE* fp = fopen("/proc/self/limits", "r"); |
492 | 400 | if (fp == nullptr) { |
493 | 0 | char buf[64]; |
494 | 0 | LOG(WARNING) << "open /proc/self/limits failed, errno=" << errno |
495 | 0 | << ", message=" << strerror_r(errno, buf, 64); |
496 | 0 | return; |
497 | 0 | } |
498 | | |
499 | | // /proc/self/limits |
500 | | // Max open files 65536 65536 files |
501 | 400 | int64_t values[2]; |
502 | 400 | size_t line_buf_size = 0; |
503 | 400 | char* line_ptr = nullptr; |
504 | 3.60k | while (getline(&line_ptr, &line_buf_size, fp) > 0) { |
505 | 3.60k | memset(values, 0, sizeof(values)); |
506 | 3.60k | int num = sscanf(line_ptr, "Max open files %" PRId64 " %" PRId64, &values[0], &values[1]); |
507 | 3.60k | if (num == 2) { |
508 | 400 | process_fd_num_limit_soft->set_value(values[0]); |
509 | 400 | process_fd_num_limit_hard->set_value(values[1]); |
510 | 400 | break; |
511 | 400 | } |
512 | 3.60k | } |
513 | | |
514 | 400 | if (line_ptr != nullptr) { |
515 | 400 | free(line_ptr); |
516 | 400 | } |
517 | | |
518 | 400 | if (ferror(fp) != 0) { |
519 | 0 | char buf[64]; |
520 | 0 | LOG(WARNING) << "getline failed, errno=" << errno |
521 | | << ", message=" << strerror_r(errno, buf, 64); |
522 | 0 | } |
523 | 400 | fclose(fp); |
524 | 400 | } |
525 | | |
526 | | } // namespace doris |