Skip to content

Commit

Permalink
Support exporting configured_hz from info server (#944)
Browse files Browse the repository at this point in the history
* Support exporting configured_hz from info

When the `dynamic-hz` configuration option is in-use (Redis 6+), Redis
will include `configured_hz` in the output of `info server`. The `hz`
that is currently configured can impact Redis CPU utilization.

This introduces exporting the server's current `configured_hz` value.

* add hz

---------

Co-authored-by: Justin Miron <[email protected]>
Co-authored-by: Oliver <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2024
1 parent 262770b commit 82cc804
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions exporter/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,18 @@ func (e *Exporter) handleMetricsServer(ch chan<- prometheus.Metric, fieldKey str
e.registerConstMetricGauge(ch, "start_time_seconds", float64(time.Now().Unix())-uptime)
}
}

if fieldKey == "configured_hz" {
if hz, err := strconv.ParseInt(fieldValue, 10, 64); err == nil {
e.registerConstMetricGauge(ch, "configured_hz", float64(hz))
}
}

if fieldKey == "hz" {
if hz, err := strconv.ParseInt(fieldValue, 10, 64); err == nil {
e.registerConstMetricGauge(ch, "hz", float64(hz))
}
}
}

func parseMetricsCommandStats(fieldKey string, fieldValue string) (cmd string, calls float64, rejectedCalls float64, failedCalls float64, usecTotal float64, extendedStats bool, errorOut error) {
Expand Down

0 comments on commit 82cc804

Please sign in to comment.