influxdata / influxdb-client-python

InfluxDB 2.0 python client
https://influxdb-client.readthedocs.io/en/stable/
MIT License
724 stars 187 forks source link

Unable to display Latitude/Longitude in Grafana Geomap panel for Flux data #552

Closed MatinF closed 3 months ago

MatinF commented 1 year ago

Specifications

Code sample to reproduce problem

I tried working with the Geomap panel in Grafana. My data is coming from an InfluxDB Cloud 2.0 database with Flux as query language. The query I'm running looks as follows:

from(bucket: v.defaultBucket)
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "1F4F8F26")
  |> filter(fn: (r) => r["_field"] == "Latitude" or r["_field"] ==  "Longitude")
  |> aggregateWindow(every: v.windowPeriod, fn: median)
  |> yield(name: "median")
  |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")

Expected behavior

Ideally, it would be possible to run below 'simpler' query without the pivot part:

from(bucket: v.defaultBucket)
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "1F4F8F26")
  |> filter(fn: (r) => r["_field"] == "Latitude" or r["_field"] ==  "Longitude")
  |> aggregateWindow(every: v.windowPeriod, fn: median)
  |> yield(name: "median")

Then, in the Geomap panel, selecting Location mode as Coords should allow me to manually set Latitude and Longitude as I attempted in 1) above. This is how the TrackMap panel works and it's very simple and intuitive.

I realize this is not directly linked to the Python API, but hoping somebody has inputs on how to use InfluxDB data for the Grafana Geomap panel.

Actual behavior

In a Table context, this yields below result (it produces 3 outputs, one with Time, Langitude, one with Time, Longitude and one with Time, Langitude, Longitude as per below selected output): image

However, even with the pivot output I struggle to get the points to display in the Geomap panel.

1) I have tried to display the data using the Markers and route layers (alpha version of Grafana). Below is the result if I try to leave the Data field unset and select the pre-pivoted Latitude/Longitude signals. It does not work: image

2) I also tried with the outputs from the Pivot, which is what I used to produce the output in the table above. Here, I first set the Data field to be equal to the pivot output (Time, Latitude, Longitude) before then selecting manually the signals coming from that pivot output. This also does not seem to work as per below: image

To make it even stranger, it appears that the 2nd version above "sometimes works" for just a moment, until e.g. a refresh causes the markers to disappear again. It seems to me that there is some form of problem with the combination of Flux queries and the Geomap panel.

Additional info

No response

srebhan commented 3 months ago

@MatinF sorry if I missed this, but how is your issue related to the python client?

MatinF commented 3 months ago

I think this has been resolved in the meantime