diff --git a/examples/config.yml b/examples/config.yml index 9d0745c0..22a18ca3 100644 --- a/examples/config.yml +++ b/examples/config.yml @@ -13,7 +13,7 @@ modules: - name: example_timestamped_value type: object path: '{ .values[?(@.state == "INACTIVE")] }' - epochTimestamp: '{ .timestamp }' + epochtimestamp: '{ .timestamp }' help: Example of a timestamped value scrape in the json labels: environment: beta # static label diff --git a/examples/data.json b/examples/data.json index 2890657a..a76d0fdf 100644 --- a/examples/data.json +++ b/examples/data.json @@ -1,6 +1,5 @@ { "counter": 1234, - "timestamp": 1657568506, "values": [ { "id": "id-A", @@ -12,6 +11,7 @@ "id": "id-B", "count": 2, "some_boolean": true, + "timestamp": 1657568506, "state": "INACTIVE" }, { diff --git a/exporter/util.go b/exporter/util.go index 8374ddce..66915108 100644 --- a/exporter/util.go +++ b/exporter/util.go @@ -63,10 +63,12 @@ func SanitizeValue(s string) (float64, error) { func SanitizeIntValue(s string) (int64, error) { var err error + var valueFloat float64 var value int64 var resultErr string - if value, err = strconv.ParseInt(s, 10, 64); err == nil { + if valueFloat, err = strconv.ParseFloat(s, 64); err == nil { + value = int64(math.Round(valueFloat)) return value, nil } resultErr = fmt.Sprintf("%s", err)