Coverage Report

Created: 2026-07-19 19:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
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_3ARG(query_cache_stale_hit_total, MetricUnit::REQUESTS,
52
                                     "Query cache decisions that reused a stale entry by "
53
                                     "incremental merge.");
54
DEFINE_COUNTER_METRIC_PROTOTYPE_3ARG(query_cache_incremental_fallback_total, MetricUnit::REQUESTS,
55
                                     "Query cache decisions that could have merged incrementally "
56
                                     "but fell back to a full recompute.");
57
DEFINE_COUNTER_METRIC_PROTOTYPE_3ARG(query_cache_write_back_total, MetricUnit::REQUESTS,
58
                                     "Query cache entries handed to the cache to be written back "
59
                                     "(full or merged); admission may still turn one down.");
60
DEFINE_COUNTER_METRIC_PROTOTYPE_3ARG(query_cache_decision_sync_time_ms, MetricUnit::MILLISECONDS,
61
                                     "Cumulative wall time the cloud incremental-merge decision "
62
                                     "spent blocking on its pre-sync rowset fan-out.");
63
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(push_requests_success_total, MetricUnit::REQUESTS, "",
64
                                     push_requests_total, Labels({{"status", "SUCCESS"}}));
65
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(push_requests_fail_total, MetricUnit::REQUESTS, "",
66
                                     push_requests_total, Labels({{"status", "FAIL"}}));
67
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(push_request_duration_us, MetricUnit::MICROSECONDS);
68
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(push_request_write_bytes, MetricUnit::BYTES);
69
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(push_request_write_rows, MetricUnit::ROWS);
70
71
#define DEFINE_ENGINE_COUNTER_METRIC(name, type, status)                                        \
72
    DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(name, MetricUnit::REQUESTS, "", engine_requests_total, \
73
                                         Labels({{"type", #type}, {"status", #status}}));
74
75
DEFINE_ENGINE_COUNTER_METRIC(create_tablet_requests_total, create_tablet, total);
76
DEFINE_ENGINE_COUNTER_METRIC(create_tablet_requests_failed, create_tablet, failed);
77
DEFINE_ENGINE_COUNTER_METRIC(drop_tablet_requests_total, drop_tablet, total);
78
DEFINE_ENGINE_COUNTER_METRIC(report_all_tablets_requests_skip, report_all_tablets, skip)
79
DEFINE_ENGINE_COUNTER_METRIC(schema_change_requests_total, schema_change, total);
80
DEFINE_ENGINE_COUNTER_METRIC(schema_change_requests_failed, schema_change, failed);
81
DEFINE_ENGINE_COUNTER_METRIC(create_rollup_requests_total, create_rollup, total);
82
DEFINE_ENGINE_COUNTER_METRIC(create_rollup_requests_failed, create_rollup, failed);
83
DEFINE_ENGINE_COUNTER_METRIC(storage_migrate_requests_total, storage_migrate, total);
84
DEFINE_ENGINE_COUNTER_METRIC(storage_migrate_v2_requests_total, storage_migrate_v2, total);
85
DEFINE_ENGINE_COUNTER_METRIC(storage_migrate_v2_requests_failed, storage_migrate_v2, failed);
86
DEFINE_ENGINE_COUNTER_METRIC(delete_requests_total, delete, total);
87
DEFINE_ENGINE_COUNTER_METRIC(delete_requests_failed, delete, failed);
88
DEFINE_ENGINE_COUNTER_METRIC(clone_requests_total, clone, total);
89
DEFINE_ENGINE_COUNTER_METRIC(clone_requests_failed, clone, failed);
90
DEFINE_ENGINE_COUNTER_METRIC(finish_task_requests_total, finish_task, total);
91
DEFINE_ENGINE_COUNTER_METRIC(finish_task_requests_failed, finish_task, failed);
92
DEFINE_ENGINE_COUNTER_METRIC(base_compaction_request_total, base_compaction, total);
93
DEFINE_ENGINE_COUNTER_METRIC(base_compaction_request_failed, base_compaction, failed);
94
DEFINE_ENGINE_COUNTER_METRIC(cumulative_compaction_request_total, cumulative_compaction, total);
95
DEFINE_ENGINE_COUNTER_METRIC(cumulative_compaction_request_failed, cumulative_compaction, failed);
96
DEFINE_ENGINE_COUNTER_METRIC(publish_task_request_total, publish, total);
97
DEFINE_ENGINE_COUNTER_METRIC(publish_task_failed_total, publish, failed);
98
DEFINE_ENGINE_COUNTER_METRIC(alter_inverted_index_requests_total, alter_inverted_index, total);
99
DEFINE_ENGINE_COUNTER_METRIC(alter_inverted_index_requests_failed, alter_inverted_index, failed);
100
101
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(base_compaction_deltas_total, MetricUnit::ROWSETS, "",
102
                                     compaction_deltas_total, Labels({{"type", "base"}}));
103
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(cumulative_compaction_deltas_total, MetricUnit::ROWSETS, "",
104
                                     compaction_deltas_total, Labels({{"type", "cumulative"}}));
105
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(full_compaction_deltas_total, MetricUnit::ROWSETS, "",
106
                                     compaction_deltas_total, Labels({{"type", "full"}}));
107
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(base_compaction_bytes_total, MetricUnit::BYTES, "",
108
                                     compaction_bytes_total, Labels({{"type", "base"}}));
109
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(cumulative_compaction_bytes_total, MetricUnit::BYTES, "",
110
                                     compaction_bytes_total, Labels({{"type", "cumulative"}}));
111
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(full_compaction_bytes_total, MetricUnit::BYTES, "",
112
                                     compaction_bytes_total, Labels({{"type", "full"}}));
113
114
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(base_compaction_task_running_total, MetricUnit::ROWSETS, "",
115
                                     compaction_task_state_total, Labels({{"type", "base"}}));
116
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(base_compaction_task_pending_total, MetricUnit::ROWSETS, "",
117
                                     compaction_task_state_total, Labels({{"type", "base"}}));
118
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(binlog_compaction_task_running_total, MetricUnit::ROWSETS, "",
119
                                     compaction_task_state_total, Labels({{"type", "binlog"}}));
120
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(binlog_compaction_task_pending_total, MetricUnit::ROWSETS, "",
121
                                     compaction_task_state_total, Labels({{"type", "binlog"}}));
122
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(cumulative_compaction_task_running_total, MetricUnit::ROWSETS,
123
                                     "", compaction_task_state_total,
124
                                     Labels({{"type", "cumulative"}}));
125
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(cumulative_compaction_task_pending_total, MetricUnit::ROWSETS,
126
                                     "", compaction_task_state_total,
127
                                     Labels({{"type", "cumulative"}}));
128
129
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(segment_read_total, MetricUnit::OPERATIONS,
130
                                     "(segment_v2) total number of segments read", segment_read,
131
                                     Labels({{"type", "segment_read_total"}}));
132
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(
133
        segment_row_total, MetricUnit::ROWS,
134
        "(segment_v2) total number of rows in queried segments (before index pruning)",
135
        segment_read, Labels({{"type", "segment_row_total"}}));
136
137
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(condition_cache_search_count, MetricUnit::OPERATIONS,
138
                                     "number of condition cache lookups when digest != 0",
139
                                     condition_cache, Labels({{"type", "condition_cache_search"}}));
140
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(condition_cache_hit_count, MetricUnit::OPERATIONS,
141
                                     "number of condition cache hits", condition_cache,
142
                                     Labels({{"type", "condition_cache_hit"}}));
143
144
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_load_txn_begin_request_total, MetricUnit::OPERATIONS,
145
                                     "", stream_load_txn_request, Labels({{"type", "begin"}}));
146
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_load_txn_commit_request_total, MetricUnit::OPERATIONS,
147
                                     "", stream_load_txn_request, Labels({{"type", "commit"}}));
148
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_load_txn_rollback_request_total, MetricUnit::OPERATIONS,
149
                                     "", stream_load_txn_request, Labels({{"type", "rollback"}}));
150
151
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_receive_bytes_total, MetricUnit::BYTES, "", stream_load,
152
                                     Labels({{"type", "receive_bytes"}}));
153
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(stream_load_rows_total, MetricUnit::ROWS, "", stream_load,
154
                                     Labels({{"type", "load_rows"}}));
155
156
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(compaction_producer_callback_a_round_time,
157
                                     MetricUnit::ROWSETS);
158
159
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(local_compaction_read_rows_total, MetricUnit::ROWS, "",
160
                                     compaction_rows_total, Labels({{"type", "read"}}));
161
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(local_compaction_read_bytes_total, MetricUnit::BYTES, "",
162
                                     compaction_bytes_total, Labels({{"type", "read"}}));
163
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(local_compaction_write_rows_total, MetricUnit::ROWS, "",
164
                                     compaction_rows_total, Labels({{"type", "write"}}));
165
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(local_compaction_write_bytes_total, MetricUnit::BYTES, "",
166
                                     compaction_bytes_total, Labels({{"type", "write"}}));
167
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(remote_compaction_read_rows_total, MetricUnit::ROWS, "",
168
                                     compaction_rows_total, Labels({{"type", "read"}}));
169
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(remote_compaction_read_bytes_total, MetricUnit::BYTES, "",
170
                                     compaction_bytes_total, Labels({{"type", "read"}}));
171
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(remote_compaction_write_rows_total, MetricUnit::ROWS, "",
172
                                     compaction_rows_total, Labels({{"type", "write"}}));
173
DEFINE_COUNTER_METRIC_PROTOTYPE_5ARG(remote_compaction_write_bytes_total, MetricUnit::BYTES, "",
174
                                     compaction_bytes_total, Labels({{"type", "write"}}));
175
176
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(load_rows, MetricUnit::ROWS);
177
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(load_bytes, MetricUnit::BYTES);
178
179
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_get_msg_latency, MetricUnit::MILLISECONDS);
180
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_get_msg_count, MetricUnit::NOUNIT);
181
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_consume_rows, MetricUnit::ROWS);
182
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_consume_bytes, MetricUnit::BYTES);
183
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_kinesis_get_records_latency,
184
                                     MetricUnit::MILLISECONDS);
185
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_kinesis_get_records_count, MetricUnit::NOUNIT);
186
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_kinesis_throttle_count, MetricUnit::NOUNIT);
187
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_kinesis_retriable_error_count,
188
                                     MetricUnit::NOUNIT);
189
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(routine_load_kinesis_closed_shard_count, MetricUnit::NOUNIT);
190
191
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(memtable_flush_total, MetricUnit::OPERATIONS);
192
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(memtable_flush_duration_us, MetricUnit::MICROSECONDS);
193
194
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(memory_pool_bytes_total, MetricUnit::BYTES);
195
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(process_thread_num, MetricUnit::NOUNIT);
196
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(process_fd_num_used, MetricUnit::NOUNIT);
197
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(process_fd_num_limit_soft, MetricUnit::NOUNIT);
198
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(process_fd_num_limit_hard, MetricUnit::NOUNIT);
199
200
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(tablet_cumulative_max_compaction_score, MetricUnit::NOUNIT);
201
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(tablet_base_max_compaction_score, MetricUnit::NOUNIT);
202
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(tablet_binlog_max_compaction_score, MetricUnit::NOUNIT);
203
204
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(all_rowsets_num, MetricUnit::NOUNIT);
205
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(all_segments_num, MetricUnit::NOUNIT);
206
207
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(compaction_used_permits, MetricUnit::NOUNIT);
208
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(binlog_compaction_used_permits, MetricUnit::NOUNIT);
209
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(compaction_waitting_permits, MetricUnit::NOUNIT);
210
211
DEFINE_HISTOGRAM_METRIC_PROTOTYPE_2ARG(tablet_version_num_distribution, MetricUnit::NOUNIT);
212
213
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(query_scan_bytes_per_second, MetricUnit::BYTES);
214
215
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(readable_blocks_total, MetricUnit::BLOCKS);
216
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(writable_blocks_total, MetricUnit::BLOCKS);
217
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(blocks_created_total, MetricUnit::OPERATIONS);
218
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(blocks_deleted_total, MetricUnit::OPERATIONS);
219
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(bytes_read_total, MetricUnit::BYTES);
220
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(bytes_written_total, MetricUnit::BYTES);
221
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(disk_sync_total, MetricUnit::OPERATIONS);
222
223
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(blocks_open_reading, MetricUnit::BLOCKS);
224
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(blocks_open_writing, MetricUnit::BLOCKS);
225
226
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(query_cache_memory_total_byte, MetricUnit::BYTES);
227
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(query_cache_sql_total_count, MetricUnit::NOUNIT);
228
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(query_cache_partition_total_count, MetricUnit::NOUNIT);
229
230
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(upload_total_byte, MetricUnit::BYTES);
231
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(upload_rowset_count, MetricUnit::ROWSETS);
232
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(upload_fail_count, MetricUnit::ROWSETS);
233
234
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(local_file_reader_total, MetricUnit::FILESYSTEM);
235
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_file_reader_total, MetricUnit::FILESYSTEM);
236
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(hdfs_file_reader_total, MetricUnit::FILESYSTEM);
237
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(broker_file_reader_total, MetricUnit::FILESYSTEM);
238
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(local_file_writer_total, MetricUnit::FILESYSTEM);
239
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_file_writer_total, MetricUnit::FILESYSTEM);
240
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(file_created_total, MetricUnit::FILESYSTEM);
241
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_file_created_total, MetricUnit::FILESYSTEM);
242
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(local_bytes_read_total, MetricUnit::FILESYSTEM);
243
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_bytes_read_total, MetricUnit::FILESYSTEM);
244
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(local_bytes_written_total, MetricUnit::FILESYSTEM);
245
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(s3_bytes_written_total, MetricUnit::FILESYSTEM);
246
247
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(local_file_open_reading, MetricUnit::FILESYSTEM);
248
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(s3_file_open_reading, MetricUnit::FILESYSTEM);
249
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(hdfs_file_open_reading, MetricUnit::FILESYSTEM);
250
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(broker_file_open_reading, MetricUnit::FILESYSTEM);
251
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(local_file_open_writing, MetricUnit::FILESYSTEM);
252
DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(s3_file_open_writing, MetricUnit::FILESYSTEM);
253
254
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(num_io_bytes_read_total, MetricUnit::OPERATIONS);
255
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(num_io_bytes_read_from_cache, MetricUnit::OPERATIONS);
256
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(num_io_bytes_read_from_remote, MetricUnit::OPERATIONS);
257
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(num_io_bytes_read_from_peer, MetricUnit::OPERATIONS);
258
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(inverted_index_bytes_read_from_remote, MetricUnit::BYTES);
259
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(segment_footer_index_bytes_read_from_remote,
260
                                     MetricUnit::BYTES);
261
262
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(udf_close_bthread_count, MetricUnit::OPERATIONS);
263
264
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(query_ctx_cnt, MetricUnit::NOUNIT);
265
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(scanner_ctx_cnt, MetricUnit::NOUNIT);
266
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(scanner_cnt, MetricUnit::NOUNIT);
267
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(scanner_task_cnt, MetricUnit::NOUNIT);
268
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(pipeline_task_queue_size, MetricUnit::NOUNIT);
269
270
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(runtime_filter_consumer_num, MetricUnit::NOUNIT);
271
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(runtime_filter_consumer_ready_num, MetricUnit::NOUNIT);
272
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(runtime_filter_consumer_wait_ready_ms,
273
                                     MetricUnit::MILLISECONDS);
274
DEFINE_GAUGE_CORE_METRIC_PROTOTYPE_2ARG(runtime_filter_consumer_timeout_num, MetricUnit::NOUNIT);
275
276
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(get_remote_tablet_slow_time_ms, MetricUnit::MILLISECONDS);
277
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(get_remote_tablet_slow_cnt, MetricUnit::NOUNIT);
278
279
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_load_costs_ms, MetricUnit::MILLISECONDS);
280
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_load_cnt, MetricUnit::NOUNIT);
281
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_search_costs_ms, MetricUnit::MILLISECONDS);
282
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_search_cnt, MetricUnit::NOUNIT);
283
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_ivf_on_disk_fetch_page_costs_ms, MetricUnit::MILLISECONDS);
284
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_ivf_on_disk_fetch_page_cnt, MetricUnit::NOUNIT);
285
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_ivf_on_disk_search_costs_ms, MetricUnit::MILLISECONDS);
286
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_ivf_on_disk_search_cnt, MetricUnit::NOUNIT);
287
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_ivf_on_disk_cache_hit_cnt, MetricUnit::NOUNIT);
288
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_ivf_on_disk_cache_miss_cnt, MetricUnit::NOUNIT);
289
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_in_memory_cnt, MetricUnit::NOUNIT);
290
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_in_memory_rows_cnt, MetricUnit::ROWS);
291
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_construction, MetricUnit::NOUNIT);
292
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(ann_index_build_index_threads, MetricUnit::NOUNIT);
293
294
const std::string DorisMetrics::_s_registry_name = "doris_be";
295
const std::string DorisMetrics::_s_hook_name = "doris_metrics";
296
297
1
DorisMetrics::DorisMetrics() : _metric_registry(_s_registry_name) {
298
1
    _server_metric_entity = _metric_registry.register_entity("server");
299
300
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, fragment_requests_total);
301
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, fragment_request_duration_us);
302
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_scan_bytes);
303
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_scan_bytes_from_local);
304
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_scan_bytes_from_remote);
305
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_scan_rows);
306
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_cache_stale_hit_total);
307
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_cache_incremental_fallback_total);
308
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_cache_write_back_total);
309
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_cache_decision_sync_time_ms);
310
311
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_requests_success_total);
312
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_requests_fail_total);
313
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_request_duration_us);
314
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_request_write_bytes);
315
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, push_request_write_rows);
316
317
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, compaction_producer_callback_a_round_time);
318
319
    // engine_requests_total
320
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, create_tablet_requests_total);
321
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, create_tablet_requests_failed);
322
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, drop_tablet_requests_total);
323
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, report_all_tablets_requests_skip);
324
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, schema_change_requests_total);
325
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, schema_change_requests_failed);
326
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, create_rollup_requests_total);
327
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, create_rollup_requests_failed);
328
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, storage_migrate_requests_total);
329
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, storage_migrate_v2_requests_total);
330
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, storage_migrate_v2_requests_failed);
331
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, delete_requests_total);
332
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, delete_requests_failed);
333
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, clone_requests_total);
334
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, clone_requests_failed);
335
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, finish_task_requests_total);
336
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, finish_task_requests_failed);
337
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_request_total);
338
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_request_failed);
339
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_request_total);
340
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_request_failed);
341
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, publish_task_request_total);
342
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, publish_task_failed_total);
343
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, alter_inverted_index_requests_total);
344
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, alter_inverted_index_requests_failed);
345
346
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_compaction_read_rows_total);
347
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_compaction_read_bytes_total);
348
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_compaction_write_rows_total);
349
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_compaction_write_bytes_total);
350
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, remote_compaction_read_rows_total);
351
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, remote_compaction_read_bytes_total);
352
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, remote_compaction_write_rows_total);
353
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, remote_compaction_write_bytes_total);
354
355
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_deltas_total);
356
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_bytes_total);
357
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_deltas_total);
358
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_bytes_total);
359
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, full_compaction_deltas_total);
360
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, full_compaction_bytes_total);
361
362
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_task_running_total);
363
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, base_compaction_task_pending_total);
364
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, binlog_compaction_task_running_total);
365
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, binlog_compaction_task_pending_total);
366
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_task_running_total);
367
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, cumulative_compaction_task_pending_total);
368
369
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, segment_read_total);
370
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, condition_cache_search_count);
371
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, condition_cache_hit_count);
372
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, segment_row_total);
373
374
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_load_txn_begin_request_total);
375
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_load_txn_commit_request_total);
376
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_load_txn_rollback_request_total);
377
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_receive_bytes_total);
378
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, stream_load_rows_total);
379
380
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_get_msg_latency);
381
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_get_msg_count);
382
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_consume_bytes);
383
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_consume_rows);
384
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_kinesis_get_records_latency);
385
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_kinesis_get_records_count);
386
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_kinesis_throttle_count);
387
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_kinesis_retriable_error_count);
388
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, routine_load_kinesis_closed_shard_count);
389
390
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, memtable_flush_total);
391
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, memtable_flush_duration_us);
392
393
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, memory_pool_bytes_total);
394
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, process_thread_num);
395
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, process_fd_num_used);
396
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, process_fd_num_limit_soft);
397
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, process_fd_num_limit_hard);
398
399
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, tablet_cumulative_max_compaction_score);
400
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, tablet_base_max_compaction_score);
401
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, tablet_binlog_max_compaction_score);
402
403
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, all_rowsets_num);
404
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, all_segments_num);
405
406
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, compaction_used_permits);
407
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, binlog_compaction_used_permits);
408
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, compaction_waitting_permits);
409
410
1
    HISTOGRAM_METRIC_REGISTER(_server_metric_entity, tablet_version_num_distribution);
411
412
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, query_scan_bytes_per_second);
413
414
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, load_rows);
415
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, load_bytes);
416
417
1
    INT_UGAUGE_METRIC_REGISTER(_server_metric_entity, upload_total_byte);
418
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, upload_rowset_count);
419
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, upload_fail_count);
420
421
1
    _server_metric_entity->register_hook(_s_hook_name, std::bind(&DorisMetrics::_update, this));
422
423
1
    INT_UGAUGE_METRIC_REGISTER(_server_metric_entity, query_cache_memory_total_byte);
424
1
    INT_UGAUGE_METRIC_REGISTER(_server_metric_entity, query_cache_sql_total_count);
425
1
    INT_UGAUGE_METRIC_REGISTER(_server_metric_entity, query_cache_partition_total_count);
426
427
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_file_reader_total);
428
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_file_reader_total);
429
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, hdfs_file_reader_total);
430
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, broker_file_reader_total);
431
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_file_writer_total);
432
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_file_writer_total);
433
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, file_created_total);
434
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_file_created_total);
435
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_bytes_read_total);
436
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_bytes_read_total);
437
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, local_bytes_written_total);
438
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, s3_bytes_written_total);
439
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, local_file_open_reading);
440
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, s3_file_open_reading);
441
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, hdfs_file_open_reading);
442
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, broker_file_open_reading);
443
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, local_file_open_writing);
444
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, s3_file_open_writing);
445
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, num_io_bytes_read_total);
446
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, num_io_bytes_read_from_cache);
447
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, num_io_bytes_read_from_remote);
448
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, num_io_bytes_read_from_peer);
449
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, inverted_index_bytes_read_from_remote);
450
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, segment_footer_index_bytes_read_from_remote);
451
452
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, udf_close_bthread_count);
453
454
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, query_ctx_cnt);
455
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, scanner_ctx_cnt);
456
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, scanner_cnt);
457
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, scanner_task_cnt);
458
459
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, runtime_filter_consumer_num);
460
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, runtime_filter_consumer_ready_num);
461
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, runtime_filter_consumer_wait_ready_ms);
462
1
    INT_GAUGE_METRIC_REGISTER(_server_metric_entity, runtime_filter_consumer_timeout_num);
463
464
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, get_remote_tablet_slow_time_ms);
465
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, get_remote_tablet_slow_cnt);
466
467
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, pipeline_task_queue_size);
468
469
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_load_costs_ms);
470
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_load_cnt);
471
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_search_costs_ms);
472
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_search_cnt);
473
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_ivf_on_disk_fetch_page_costs_ms);
474
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_ivf_on_disk_fetch_page_cnt);
475
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_ivf_on_disk_search_costs_ms);
476
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_ivf_on_disk_search_cnt);
477
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_ivf_on_disk_cache_hit_cnt);
478
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_ivf_on_disk_cache_miss_cnt);
479
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_in_memory_cnt);
480
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_in_memory_rows_cnt);
481
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_construction);
482
1
    INT_COUNTER_METRIC_REGISTER(_server_metric_entity, ann_index_build_index_threads);
483
1
}
484
485
void DorisMetrics::initialize(bool init_system_metrics, const std::set<std::string>& disk_devices,
486
0
                              const std::vector<std::string>& network_interfaces) {
487
0
    if (init_system_metrics) {
488
0
        _system_metrics.reset(
489
0
                new SystemMetrics(&_metric_registry, disk_devices, network_interfaces));
490
0
    }
491
0
}
492
493
0
void DorisMetrics::init_jvm_metrics() {
494
0
    _jvm_metrics.reset(new JvmMetrics(&_metric_registry));
495
0
}
496
497
0
void DorisMetrics::_update() {
498
0
    _update_process_thread_num();
499
0
    _update_process_fd_num();
500
0
}
501
502
// get num of thread of doris_be process
503
// from /proc/self/task
504
0
void DorisMetrics::_update_process_thread_num() {
505
0
    std::error_code ec;
506
0
    std::filesystem::directory_iterator dict_iter("/proc/self/task/", ec);
507
0
    if (ec) {
508
0
        LOG(WARNING) << "failed to count thread num: " << ec.message();
509
0
        process_thread_num->set_value(0);
510
0
        return;
511
0
    }
512
0
    int64_t count =
513
0
            std::count_if(dict_iter, std::filesystem::end(dict_iter), [](const auto& entry) {
514
0
                std::error_code error_code;
515
0
                return entry.is_directory(error_code) && !error_code;
516
0
            });
517
518
0
    process_thread_num->set_value(count);
519
0
}
520
521
// get num of file descriptor of doris_be process
522
0
void DorisMetrics::_update_process_fd_num() {
523
    // fd used
524
0
    std::error_code ec;
525
0
    std::filesystem::directory_iterator dict_iter("/proc/self/fd/", ec);
526
0
    if (ec) {
527
0
        LOG(WARNING) << "failed to count fd: " << ec.message();
528
0
        process_fd_num_used->set_value(0);
529
0
        return;
530
0
    }
531
0
    int64_t count =
532
0
            std::count_if(dict_iter, std::filesystem::end(dict_iter), [](const auto& entry) {
533
0
                std::error_code error_code;
534
0
                return entry.is_regular_file(error_code) && !error_code;
535
0
            });
536
537
0
    process_fd_num_used->set_value(count);
538
539
    // fd limits
540
0
    FILE* fp = fopen("/proc/self/limits", "r");
541
0
    if (fp == nullptr) {
542
0
        char buf[64];
543
0
        LOG(WARNING) << "open /proc/self/limits failed, errno=" << errno
544
0
                     << ", message=" << strerror_r(errno, buf, 64);
545
0
        return;
546
0
    }
547
548
    // /proc/self/limits
549
    // Max open files            65536                65536                files
550
0
    int64_t values[2];
551
0
    size_t line_buf_size = 0;
552
0
    char* line_ptr = nullptr;
553
0
    while (getline(&line_ptr, &line_buf_size, fp) > 0) {
554
0
        memset(values, 0, sizeof(values));
555
0
        int num = sscanf(line_ptr, "Max open files %" PRId64 " %" PRId64, &values[0], &values[1]);
556
0
        if (num == 2) {
557
0
            process_fd_num_limit_soft->set_value(values[0]);
558
0
            process_fd_num_limit_hard->set_value(values[1]);
559
0
            break;
560
0
        }
561
0
    }
562
563
0
    if (line_ptr != nullptr) {
564
0
        free(line_ptr);
565
0
    }
566
567
0
    if (ferror(fp) != 0) {
568
0
        char buf[64];
569
0
        LOG(WARNING) << "getline failed, errno=" << errno
570
                     << ", message=" << strerror_r(errno, buf, 64);
571
0
    }
572
0
    fclose(fp);
573
0
}
574
575
} // namespace doris