Skip to content

Commit

Permalink
Merge pull request #21 from K-Yo/20-parse-strings-as-numbers-in-index…
Browse files Browse the repository at this point in the history
…-metrics

🐛 parse stringified floats from splunk api
  • Loading branch information
K-Yo authored May 13, 2024
2 parents e878e58 + 22d2f63 commit 1e7fef8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package exporter
import (
"fmt"
"net/url"
"strconv"
"strings"

"github.com/K-Yo/splunk_exporter/config"
Expand Down Expand Up @@ -175,6 +176,7 @@ func (e *Exporter) measureIndex(ch chan<- prometheus.Metric, index *splunklib.Da
indexName := index.ID.Title
for typ, ival := range index.Content {
var val float64
var err error

// FIXME add minDate and maxDate as titmestamps

Expand All @@ -183,6 +185,11 @@ func (e *Exporter) measureIndex(ch chan<- prometheus.Metric, index *splunklib.Da
val = float64(v)
case float64:
val = v
case string:
val, err = strconv.ParseFloat(v, 64)
if err != nil {
continue
}
default:
continue
}
Expand Down

0 comments on commit 1e7fef8

Please sign in to comment.