Skip to content

Commit

Permalink
sanitizeMetricName instead of ignoring dashed metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
azr authored Aug 16, 2017
1 parent 02859cc commit 353b064
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions exporter/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {

func includeMetric(s string) bool {

if strings.Contains(s, "-") {
return false
}
if strings.HasPrefix(s, "db") || strings.HasPrefix(s, "cmdstat_") || strings.HasPrefix(s, "cluster_") {
return true
}
Expand All @@ -270,6 +267,11 @@ func includeMetric(s string) bool {
return ok
}

func sanitizeMetricName(n string) string {
n = strings.Replace(n, "-", "_", 0)
return n
}

func extractVal(s string) (val float64, err error) {
split := strings.Split(s, "=")
if len(split) != 2 {
Expand Down Expand Up @@ -391,7 +393,7 @@ func (e *Exporter) extractInfoMetrics(info, addr string, alias string, scrapes c
continue
}

metricName := split[0]
metricName := sanitizeMetricName(split[0])
if newName, ok := metricMap[metricName]; ok {
metricName = newName
}
Expand Down

0 comments on commit 353b064

Please sign in to comment.