Open YeomansIII opened 4 years ago
This comment might be helpful to you: https://github.com/pR0Ps/grafana-trackmap-panel/issues/3#issuecomment-384655784 . I don't have any experience with Flux queries so I don't have any direct advice, sorry. If you end up figuring it out, let me know and I'll add an example to the readme for others.
I'm using a query as below, which works great:
from(bucket: "test-bucket-new")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "958D2219")
|> filter(fn: (r) => r["_field"] == "Latitude" or r["_field"] == "Longitude")
|> aggregateWindow(every: v.windowPeriod, fn: median)
|> yield(name: "median")
I have tried the above query, but it doesn't render anything. Any pointers what could be the issue? Or any updates about the support for flux.
Note that my query is rather specific to the way my Influx data is structured, so it should be viewed as an example only
Ofcourse I modified it to my needs. But I have a very simple dataset I use for this. It has 2 fields (latitude and longitude) and 2 tags (geohash and source) within one measurement (position). So your query (changing bucket and measurement) for this should work right?
I'm not sure what might be the reason - just shared my example in case it might be helpful for some. I have it working just fine with Flux on latest Grafana and using InfluxDB 1.8 or InfluxDB 2.0 (cloud starter) editions.
@etwobben The two queries I posted in my initial question actually ended up working. The "set" function was only required to change the name of the columns from lat -> latitude, etc.
Try using two separate queries for lat and lon.
How to show this in a map on InfluxDB 2.0?
You can see an example in our playground (see the maps queries): https://grafana.csselectronics.stellarhosted.com/d/hXdWa0VMk/css-playground
Done using Flux query language in InfluxDB 2.0 cloud version.
@MatinF Can I see the code? (no confidential data)
Hi again,
The query code is available if you click the maps panel. Not sure what other code you're looking for?
best,
Hi there! I have more or less a similar problem. The "lat" and "lon" is in one field as a string and I split this with my Influx query. The result seems OK but the map is showing nothing neither an error message.
Here is my query: import "strings" from(bucket: "source") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "LOCATION") |> filter(fn: (r) => r["_field"] == "value") |> map (fn: (r) => ({ r with latitude: float (v: strings.split(v: r._value, t: ",")[0]), longitude: float (v: strings.split(v: r._value, t: ",")[1]) }))
The data / result: _time | _value | latitude | longitude 2022-03-11T18:17:01.329Z | 49.4692537xxxxx,11.056303982xxxxx | 49.469253797xxxxx | 11.0563039xxxxx
Any thoughts? Thanks in advance! Best :-)
I'm using a query as below, which works great:
from(bucket: "test-bucket-new") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "958D2219") |> filter(fn: (r) => r["_field"] == "Latitude" or r["_field"] == "Longitude") |> aggregateWindow(every: v.windowPeriod, fn: median) |> yield(name: "median")
This worked great for me thanks! The only thing I've added was a filter for which device I want to display. from(bucket: "myBucket") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "findmy") |> filter(fn: (r) => r["name"] == "${Device}") |> filter(fn: (r) => r["_field"] == "latitude" or r["_field"] == "longitude") |> aggregateWindow(every: v.windowPeriod, fn: median) |> yield(name: "median")
I'm pulling in data using telegraf / starlark parsing of JSON files. new_metric.tags["serialnumber"] = group["serialNumber"] new_metric.fields["longitude"] = group["location"]["longitude"] new_metric.fields["altitude"] = group["location"]["altitude"] new_metric.fields["latitude"] = group["location"]["latitude"] new_metric.fields["positiontype"] = group["location"]["positionType"] new_metric.fields["address"] = group["address"]["mapItemFullAddress"] new_metric.fields["isold"] = group["location"]["isOld"] new_metric.tags["name"] = group["name"] new_metric.time = int(group["location"]["timeStamp"]*1000000)
So my measurements looks like this _time, name, serialnumber, address, altitude, isOld, latitude, longitude, positionType
If anyone is working with the sample data provided by Influx, I had to drop
the columns not expected by TrackMap. The following works for me with the birds migration dataset:
from(bucket: "Tutorial")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "migration")
|> filter(fn: (r) => r["_field"] == "lat" or r["_field"] == "lon")
|> filter(fn: (r) => r["id"] == "91761A")
|> drop(columns: ["s2_cell_id"])
|> aggregateWindow(every: v.windowPeriod, fn: median)
|> yield(name: "median")
THIS WORKS:
from(bucket: "ANDROMAXA") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "navigation.position") |> filter(fn: (r) => r["source"] == "Navi.1") |> filter(fn: (r) => r["_field"] == "lat" or r["_field"] == "lon") |> aggregateWindow(every: v.windowPeriod, fn: median) |> yield(name: "median")
HOWEVER, THE POINTER NOT. I navigate in the other grafs but the pointer is not appearing and not movin through the track.. Anyone knows why?
I am trying to display a geo track using this plugin. My InfluxDB data is stored on InfluxDB 2.0 and I am querying using a Flux query in Grafana. My data contains a
lat
andlon
field. What is the proper way of displaying this data on this plugin map?I have tried many different queries and transformations, I am currently using this, which still doesn't display any data.
Query A:
Query B:
This results in a Grafana data table with columns
Time
,latitude
, andlongitude
.