Skip to content

Commit cb559f0

Browse files
authored
Compatible with parsing for block_cache_usage (#26)
1 parent 3422fff commit cb559f0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

exporter/info.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,25 @@ func (e *Exporter) handleMetricsReplication(ch chan<- prometheus.Metric, masterH
249249
}
250250

251251
func (e *Exporter) handleMetricsRocksDB(ch chan<- prometheus.Metric, fieldKey string, fieldValue string) {
252+
sharedMetric := []string{"block_cache_usage"}
253+
for _, field := range sharedMetric {
254+
// format like `block_cache_usage:0`
255+
if strings.Compare(fieldKey, field) == 0 {
256+
if statValue, err := strconv.ParseFloat(fieldValue, 64); err == nil {
257+
e.registerConstMetricGauge(ch, fieldKey, statValue, "-")
258+
}
259+
// return ASAP
260+
return
261+
}
262+
}
263+
252264
prefixs := []string{
253265
"block_cache_usage", "block_cache_pinned_usage", "index_and_filter_cache_usage", "estimate_keys",
254266
"level0_file_limit_slowdown", "level0_file_limit_stop", "pending_compaction_bytes_slowdown",
255267
"pending_compaction_bytes_stop", "memtable_count_limit_slowdown", "memtable_count_limit_stop",
256268
}
257269
for _, prefix := range prefixs {
258-
// format like `block_cache_usage[default]:0`
270+
// format like `estimate_keys[default]:0`
259271
if strings.HasPrefix(fieldKey, prefix) {
260272
fields := strings.Split(fieldKey, "[")
261273
if len(fields) != 2 {
@@ -266,6 +278,7 @@ func (e *Exporter) handleMetricsRocksDB(ch chan<- prometheus.Metric, fieldKey st
266278
if statValue, err := strconv.ParseFloat(fieldValue, 64); err == nil {
267279
e.registerConstMetricGauge(ch, metricName, statValue, columnFamily)
268280
}
281+
return
269282
}
270283
}
271284
}

0 commit comments

Comments
 (0)