Skip to content

Commit

Permalink
Compatible with parsing for block_cache_usage (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjz921024 authored Apr 16, 2024
1 parent 3422fff commit cb559f0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion exporter/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,25 @@ func (e *Exporter) handleMetricsReplication(ch chan<- prometheus.Metric, masterH
}

func (e *Exporter) handleMetricsRocksDB(ch chan<- prometheus.Metric, fieldKey string, fieldValue string) {
sharedMetric := []string{"block_cache_usage"}
for _, field := range sharedMetric {
// format like `block_cache_usage:0`
if strings.Compare(fieldKey, field) == 0 {
if statValue, err := strconv.ParseFloat(fieldValue, 64); err == nil {
e.registerConstMetricGauge(ch, fieldKey, statValue, "-")
}
// return ASAP
return
}
}

prefixs := []string{
"block_cache_usage", "block_cache_pinned_usage", "index_and_filter_cache_usage", "estimate_keys",
"level0_file_limit_slowdown", "level0_file_limit_stop", "pending_compaction_bytes_slowdown",
"pending_compaction_bytes_stop", "memtable_count_limit_slowdown", "memtable_count_limit_stop",
}
for _, prefix := range prefixs {
// format like `block_cache_usage[default]:0`
// format like `estimate_keys[default]:0`
if strings.HasPrefix(fieldKey, prefix) {
fields := strings.Split(fieldKey, "[")
if len(fields) != 2 {
Expand All @@ -266,6 +278,7 @@ func (e *Exporter) handleMetricsRocksDB(ch chan<- prometheus.Metric, fieldKey st
if statValue, err := strconv.ParseFloat(fieldValue, 64); err == nil {
e.registerConstMetricGauge(ch, metricName, statValue, columnFamily)
}
return
}
}
}
Expand Down

0 comments on commit cb559f0

Please sign in to comment.