From ca2d851f61f387d48997fcbb902a538f8b5dbf6e Mon Sep 17 00:00:00 2001 From: Ilario Gelmetti Date: Thu, 7 Dec 2023 13:58:27 +0100 Subject: [PATCH 1/3] util SanitizeIntValue accept exponential notation Signed-off-by: Ilario Gelmetti --- exporter/util.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) From d049e77865576f9713788bfbe9522ae6e83a861b Mon Sep 17 00:00:00 2001 From: Ilario Gelmetti Date: Thu, 7 Dec 2023 14:03:48 +0100 Subject: [PATCH 2/3] examples config epochtimestamp to lower case Signed-off-by: Ilario Gelmetti --- examples/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 72885237e79c52f0facc0603748b6b1db23d97cd Mon Sep 17 00:00:00 2001 From: Ilario Gelmetti Date: Thu, 7 Dec 2023 14:04:28 +0100 Subject: [PATCH 3/3] examples data.json move timestamp inside the path Signed-off-by: Ilario Gelmetti --- examples/data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" }, {