Skip to content

Commit adf0e8f

Browse files
Rocksdb metrics in status json (apple#11321)
1 parent 728c7a7 commit adf0e8f

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

documentation/sphinx/source/mr-status-json-schemas.rst.inc

+11
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@
176176
"unknown"
177177
]}
178178
},
179+
"rocksdb_metrics":{
180+
"block_cache_hits":12341234,
181+
"block_cache_misses":12341234,
182+
"pending_compaction_bytes":12341234,
183+
"memtable_bytes":12341234,
184+
"sst_reader_bytes":12341234,
185+
"block_cache_usage":12341234,
186+
"block_cache_limit":12341234,
187+
"throttled_commits":12341234,
188+
"write_stall_microseconds":12341234
189+
},
179190
"data_version":12341234,
180191
"durable_version":12341234,
181192
"data_lag": {

fdbclient/Schemas.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ const KeyRef JSONSchemas::statusSchema = R"statusSchema(
162162
"unknown"
163163
]}
164164
},
165+
"rocksdb_metrics":{
166+
"block_cache_hits":12341234,
167+
"block_cache_misses":12341234,
168+
"pending_compaction_bytes":12341234,
169+
"memtable_bytes":12341234,
170+
"sst_reader_bytes":12341234,
171+
"block_cache_usage":12341234,
172+
"block_cache_limit":12341234,
173+
"throttled_commits":12341234,
174+
"write_stall_microseconds":12341234
175+
},
165176
"data_version":12341234,
166177
"durable_version":12341234,
167178
"data_lag": {

fdbserver/KeyValueStoreRocksDB.actor.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1078,12 +1078,15 @@ ACTOR Future<Void> rocksDBMetricLogger(UID id,
10781078
{ "NumTimesReadIteratorsReused", 0 },
10791079
};
10801080

1081+
state std::string rocksdbMetricsTrackingKey = id.toString() + "/RocksDBMetrics";
10811082
loop {
10821083
wait(delay(SERVER_KNOBS->ROCKSDB_METRICS_DELAY));
10831084
if (sharedState->isClosing()) {
10841085
break;
10851086
}
10861087
TraceEvent e("RocksDBMetrics", id);
1088+
e.trackLatest(rocksdbMetricsTrackingKey);
1089+
10871090
uint64_t stat;
10881091
for (auto& [name, ticker, cum] : tickerStats) {
10891092
stat = statistics->getTickerCount(ticker);

fdbserver/Status.actor.cpp

+20-5
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,24 @@ struct RolesInfo {
615615
}
616616
}
617617

618+
TraceEventFields const& rocksdbMetrics = metrics.at("RocksDBMetrics");
619+
if (rocksdbMetrics.size()) {
620+
JsonBuilderObject rocksdbMetricsObj;
621+
rocksdbMetricsObj.setKeyRawNumber("block_cache_hits", rocksdbMetrics.getValue("BlockCacheHits"));
622+
rocksdbMetricsObj.setKeyRawNumber("block_cache_misses", rocksdbMetrics.getValue("BlockCacheMisses"));
623+
rocksdbMetricsObj.setKeyRawNumber("pending_compaction_bytes",
624+
rocksdbMetrics.getValue("EstPendCompactBytes"));
625+
rocksdbMetricsObj.setKeyRawNumber("memtable_bytes", rocksdbMetrics.getValue("AllMemtablesBytes"));
626+
rocksdbMetricsObj.setKeyRawNumber("sst_reader_bytes",
627+
rocksdbMetrics.getValue("EstimateSstReaderBytes"));
628+
rocksdbMetricsObj.setKeyRawNumber("block_cache_usage", rocksdbMetrics.getValue("BlockCacheUsage"));
629+
rocksdbMetricsObj.setKey("block_cache_limit", SERVER_KNOBS->ROCKSDB_BLOCK_CACHE_SIZE);
630+
rocksdbMetricsObj.setKeyRawNumber("throttled_commits", rocksdbMetrics.getValue("CommitDelayed"));
631+
rocksdbMetricsObj.setKeyRawNumber("write_stall_microseconds", rocksdbMetrics.getValue("StallMicros"));
632+
633+
obj["rocksdb_metrics"] = std::move(rocksdbMetricsObj);
634+
}
635+
618636
} catch (AttributeNotFoundError& e) {
619637
TraceEvent(SevWarnAlways, "StorageServerStatusJson").detail("MissingAttribute", e.getMissingAttribute());
620638
}
@@ -1976,11 +1994,8 @@ static Future<std::vector<std::pair<iface, EventMap>>> getServerMetrics(
19761994

19771995
namespace {
19781996

1979-
const std::vector<std::string> STORAGE_SERVER_METRICS_LIST{ "StorageMetrics",
1980-
"ReadLatencyMetrics",
1981-
"ReadLatencyBands",
1982-
"BusiestReadTag",
1983-
"BusiestWriteTag" };
1997+
const std::vector<std::string> STORAGE_SERVER_METRICS_LIST{ "StorageMetrics", "ReadLatencyMetrics", "ReadLatencyBands",
1998+
"BusiestReadTag", "BusiestWriteTag", "RocksDBMetrics" };
19841999

19852000
} // namespace
19862001

0 commit comments

Comments
 (0)