Geomap with FLUX

Grfana V10.0
InFluxDB 2.7

image

With this below I get one point

from(bucket: "flood")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["tag1"] == "Kwezimbovu")
  |> filter(fn: (r) => r["_field"] == "Site" or r["_field"] == "battery" or r["_field"] == "latitude" or r["_field"] == "level" or r["_field"] == "longitude")
  |> last()
  |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
  |> drop(columns: ["_start", "_stop", "_measurement"])

If I add the or in the “tag” I still get only one geo point displayed

from(bucket: "flood")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["tag1"] == "Kwezimbovu" or r["tag1"] == "Landulwazi" or r["tag1"] == "Mabedlana")
  |> filter(fn: (r) => r["_field"] == "Site" or r["_field"] == "battery" or r["_field"] == "latitude" or r["_field"] == "level" or r["_field"] == "longitude")
  |> last()
  |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
  |> drop(columns: ["_start", "_stop", "_measurement"])

Any help will be appreciated, thank you

Welcome @mwengiineeringbuild

Might be because you are using

|> last()

please follow this thread here.

https://localhost:3000/t/grafana-geomap-with-influxdb/88772/11

Also we dont have access to your influxdb so you might want to share sample data as show in above thread

I have 3 sites and they are “Kwezimbovu”, “Landulwazi” and “Mabedlana” those I made the tags.

Then each site have 5 fields - “Site”, “battery”, “latitude”, “level”, “longitude”

image

I only want to display the last record of each o the sites.

Would you structure the data differently? (the only record really varying is the ‘level’)

So Sites have sub site?

Also as far as design I guess it depends but look at documentations. For tags you do not want something with high cardinality, meaning changes a lot like a guid. but the sites I would not use them as tags, I would put those as field sets

floods,tag1=Maqwath loc=Kwezimbovu latitude=52.4943817 1687867620000000000
floods,tag1=Maqwath loc=Kwezimbovu longitude=52.4943909 1687867620000000000
floods,tag1=Maqwath battery=23.5 1687867620000000000

or

floods,tag1=Maqwath loc="Kwezimbovu",latitude=1i, latitude=
1 Like

Thank you, have amended the structure, I understand the limiting the cardinality.

image

How do I select the last or each site?

from(bucket: "flood")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "flood")
  |> filter(fn: (r) => r["tag1"] == "KZN")
  |> filter(fn: (r) => r["_field"] == "Site" or r["_field"] == "battery" or r["_field"] == "latitude" or r["_field"] == "level" or r["_field"] == "longitude")
  |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")  
  |> drop(columns: ["_start", "_stop", "_measurement", "type"])

As this retunes all the records for each site.

This is the same issue i reported a few months ago. No solution was found and i had to move out of Graphana…