Skip to content

Commit 41cba64

Browse files
authored
feat(new_metrics): show replica-level resource usage by shell nodes command based on new metrics (apache#1885)
1 parent 7d581a4 commit 41cba64

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/shell/commands/node_management.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ dsn::metric_filters resource_usage_filters()
9898
{
9999
dsn::metric_filters filters;
100100
filters.with_metric_fields = {dsn::kMetricNameField, dsn::kMetricSingleValueField};
101-
filters.entity_types = {"server"};
102-
filters.entity_metrics = {"resident_mem_usage_mb", "rdb_block_cache_mem_usage_bytes"};
101+
filters.entity_types = {"server", "replica"};
102+
filters.entity_metrics = {"resident_mem_usage_mb",
103+
"rdb_block_cache_mem_usage_bytes",
104+
"rdb_memtable_mem_usage_bytes",
105+
"rdb_index_and_filter_blocks_mem_usage_bytes"};
103106
return filters;
104107
}
105108

@@ -115,13 +118,19 @@ dsn::error_s parse_resource_usage(const std::string &json_string, list_nodes_hel
115118
}
116119

117120
for (const auto &entity : query_snapshot.entities) {
118-
if (entity.type == "server") {
119-
for (const auto &m : entity.metrics) {
121+
for (const auto &m : entity.metrics) {
122+
if (entity.type == "server") {
120123
if (m.name == "resident_mem_usage_mb") {
121124
stat.memused_res_mb += m.value;
122125
} else if (m.name == "rdb_block_cache_mem_usage_bytes") {
123126
stat.block_cache_bytes += m.value;
124127
}
128+
} else if (entity.type == "replica") {
129+
if (m.name == "rdb_memtable_mem_usage_bytes") {
130+
stat.mem_tbl_bytes += m.value;
131+
} else if (m.name == "rdb_index_and_filter_blocks_mem_usage_bytes") {
132+
stat.mem_idx_bytes += m.value;
133+
}
125134
}
126135
}
127136
}
@@ -275,8 +284,6 @@ bool ls_nodes(command_executor *e, shell_context *sc, arguments args)
275284
// TODO(wangdan): following replica-level and disk-level metrics would be replaced:
276285
// "replica*eon.replica_stub*disk.available.total.ratio"
277286
// "replica*eon.replica_stub*disk.available.min.ratio"
278-
// "replica*app.pegasus*rdb.memtable.memory_usage"
279-
// "replica*app.pegasus*rdb.index_and_filter_blocks.memory_usage"
280287

281288
for (size_t i = 0; i < nodes.size(); ++i) {
282289
auto tmp_it = tmp_map.find(nodes[i].address);
@@ -313,11 +320,6 @@ bool ls_nodes(command_executor *e, shell_context *sc, arguments args)
313320
stat.disk_available_total_ratio += m.value;
314321
else if (m.name.find("disk.available.min.ratio") != std::string::npos)
315322
stat.disk_available_min_ratio += m.value;
316-
else if (m.name.find("rdb.memtable.memory_usage") != std::string::npos)
317-
stat.mem_tbl_bytes += m.value;
318-
else if (m.name.find("rdb.index_and_filter_blocks.memory_usage") !=
319-
std::string::npos)
320-
stat.mem_idx_bytes += m.value;
321323
}
322324
}
323325
}

0 commit comments

Comments
 (0)