Influxdb v2 and grafana geomaps?

I'm using signalk-to-influxdb2 to record navigation.position. I thought I would be able to then have grafana query influxdb and draw on a map. But I can't seem to get anything to work using the fluxQL query builder. It works find for "scalar data" such as speed, course, etc, to draw graphs, but can't grafana to understand navigation.position and get the lat/lon data. Any suggestions?
3 Replies
Tony
Tony4w ago
import "join"

lat = from(bucket: "boat")
|> range(start: -5m)
|> filter(fn: (r) => r["_measurement"] == "navigation.position")
|> filter(fn: (r) => r["source"] == "N2K.c078c3003f0322e2")

|> filter(fn: (r) => r["_field"] == "lat")
|> group(columns: ["_time"])
lon = from(bucket: "boat")
|> range(start: -5m)
|> filter(fn: (r) => r["_measurement"] == "navigation.position")
|> filter(fn: (r) => r["source"] == "N2K.c078c3003f0322e2")

|> filter(fn: (r) => r["_field"] == "lon")
|> group(columns: ["_time"])
join.time(
left: lat,
right: lon,
as: (l, r) => ({l with latitude: l._value, longitude: r._value}),
)
|> drop(columns: [ "source", "_start","_stop", "_measurement", "_value","_field"])
import "join"

lat = from(bucket: "boat")
|> range(start: -5m)
|> filter(fn: (r) => r["_measurement"] == "navigation.position")
|> filter(fn: (r) => r["source"] == "N2K.c078c3003f0322e2")

|> filter(fn: (r) => r["_field"] == "lat")
|> group(columns: ["_time"])
lon = from(bucket: "boat")
|> range(start: -5m)
|> filter(fn: (r) => r["_measurement"] == "navigation.position")
|> filter(fn: (r) => r["source"] == "N2K.c078c3003f0322e2")

|> filter(fn: (r) => r["_field"] == "lon")
|> group(columns: ["_time"])
join.time(
left: lat,
right: lon,
as: (l, r) => ({l with latitude: l._value, longitude: r._value}),
)
|> drop(columns: [ "source", "_start","_stop", "_measurement", "_value","_field"])
The combined position exhibits jitter due to systematic offsets between different GPS sources so it's good to limit to just one
Copprhead
Copprhead4w ago
I also experimented with this, but the results did not really satisfy me. So I developed the TrackViewer webapp, which not only shows the tracks on a nice chart background but also simplifies the tracks to smooth out jitter and cut out anchoring times. Give it a try, it's in the SK App Store, and let me know how it works for you.
steveberl
steveberlOP3w ago
I have gotten distracted and have not had a chance to try this out yet, but I will soon, and appreciate the help.

Did you find this page helpful?