Mapping Locations with Grafana

Using timestream we can meter two values in this case the GPS lat and long to chart them with a map component in graphana.

WITH cte1 AS ( SELECT device_id, time, measure_value::double as "Lat_Value" FROM $__database.config WHERE device_id = 'AM-5046' and measure_name = 'lat' ), cte2 AS ( SELECT device_id, time, measure_value::double as "Long_Value" FROM $__database.config WHERE device_id = 'AM-5046' and measure_name = 'long' ), location AS ( SELECT cte1.device_id as "label", cte1.Lat_Value as "lat", cte2.Long_Value as "long" FROM cte1 INNER JOIN cte2 ON cte1.time = cte2.time and cte1.device_id = cte2.device_id ), sensor AS ( SELECT arbitrary(device_id) as "label", max(measure_value::double) as "tvoc" FROM $__database.sensors WHERE $__timeFilter and device_id = 'AM-5046' and measure_name = 'tvoc' ) SELECT arbitrary(location.label) as "Label", arbitrary(location.lat) as "Lat", arbitrary(location.long) as "Long", arbitrary(sensor.tvoc) as "TVOC" FROM location INNER JOIN sensor ON location.label = sensor.label

Back to blog