How to merge rows from 3 Loki queries by 1-second time buckets in Geomap?

  • What Grafana version and what operating system are you using?

Grafana Cloud v12.4.0

  • What are you trying to achieve?

I have a Geomap panel with 3 Loki queries that each return different data with their own timestamps:

  • Query A: GPS coordinates (latitude, longitude)

  • Query B: “No image” event duration (ms)

  • Query C: Reconnect event duration (ms)

I want to merge these into a single row per time bucket so I can plot markers on the map with color/size based on duration.

  • How are you trying to achieve it?

Since the timestamps don’t match exactly across queries (millisecond precision), I created a calculated field Time / 1000 to bucket into 1-second intervals, then used:

  1. Extract fields — parse lat, lon, duration from JSON log lines

  2. Convert field type — to numbers

  3. Calculate fieldTime / 1000 for 1s bucketing

  4. Join by field — outer join on Time / 1000

  5. Organize fields — rename/hide duplicates

  6. Group by — group on Time / 1000 with firstNotNull for coordinates, max for durations

  • What happened?

Rows with the same Time / 1000 value do not merge. For example, timestamp 1770642598 shows up as 3 separate rows instead of one:

Time / 1000 latitude longitude no-image-duration reconnect-duration
1770642598 4501
1770642598 534
1770642598 51.0 3.84
  • What did you expect to happen?

All three rows to collapse into one:

Time / 1000 latitude longitude no-image-duration reconnect-duration
1770642598 51.0 3.84 4501 534
  • Can you copy/paste the configuration(s) that you are having problems with?

No errors in the UI. My suspicion is that Time / 1000 produces slightly different floating-point values per query (e.g. 1770642598.123 vs 1770642598.456), so the Group By treats them as distinct keys even though they display identically.

Please try this



Hi Shanker,

Thanks for the answer, it worked.

I added a join by field (Outer(time series)) and organize field by name between the Binary and Unary operation. The binary operation creates multiple Time/1000 fields (one for each tab listed at start before the join).

solution: use unary operation floor operation to round the values (not visible) and then Group by operation and do the Group by on that rounded off field.

EDIT: Do not forget to do *1000 for the time field and convert this back to a time format with Convert Field Type transformation

Overview

1 Like

Thanks @toon2 for your feedback :star_struck: