From aec94f85b0e71d5b17552f600a19141d66f23d96 Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Fri, 16 Apr 2021 10:35:42 +0200 Subject: [PATCH] fix last time 2 --- check_nodes/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/check_nodes/main.go b/check_nodes/main.go index eff85f7..0f7662b 100644 --- a/check_nodes/main.go +++ b/check_nodes/main.go @@ -287,9 +287,9 @@ func getLastMetrics(deveui string) OneMetric { url := "http://localhost:8086/api/v2/query?org=wobischorg" data := []byte(fmt.Sprintf(`from(bucket:"wobischbucket") |> range(start:-5d) - |> tail(n:10) |> filter(fn: (r) => r._measurement == "measurement" and r.deveui == "%s") - |> filter(fn: (r) => r._field == "vbat") + |> filter(fn: (r) => r._field == "lon" or r._field == "lat" or r._field == "vbat" or r._field == "fw") + |> last(column: "_time") |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")`, deveui)) req, err := http.NewRequest("POST", url, bytes.NewBuffer(data)) @@ -328,9 +328,9 @@ func getLastMetrics(deveui string) OneMetric { for scanner.Scan() { s := strings.Split(scanner.Text(), ",") if (len(s) >= 9) && !(strings.HasPrefix(s[3], "_")) { - t, err := time.Parse(time.RFC3339, s[3]) + t, err := time.Parse(time.RFC3339, s[5]) if err != nil { - fmt.Printf("error converting time: %s\n", s[3]) + fmt.Printf("error converting time: %s\n", s[5]) continue }