I m working on a project where I need to display locations on a map grouped by Geohash values. I m struggling with writing a query to show Geohash values, group them, and count the occurrences within each group.
Here s a sample of the data I have inserted into InfluxDB:
geoip2influx,type=geomaphash City="Jakarta",Count=2,Country_code="ID",Country_name="Indonesia",Geohash="qqt4fxmz",Host="Server-1",Ip="203.12.34.56",Latitude="-6.2088",Longitude="106.8456"
geoip2influx,type=geomaphash City="Jakarta",Count=2,Country_code="ID",Country_name="Indonesia",Geohash="qqt4fxmz",Host="Server-1",Ip="203.12.34.56",Latitude="-6.2088",Longitude="106.8456"
geoip2influx,type=geomaphash City="Jakarta",Count=2,Country_code="ID",Country_name="Indonesia",Geohash="qqt4fxmz",Host="Server-1",Ip="203.12.34.56",Latitude="-6.2088",Longitude="106.8456"
geoip2influx,type=geomaphash City="Jakarta",Count=2,Country_code="ID",Country_name="Indonesia",Geohash="qqt4fxmz",Host="Server-1",Ip="203.12.34.56",Latitude="-6.2088",Longitude="106.8456"
I m using Grafana to query the data with the following Flux query:
from(bucket: "geoip2influx")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "geoip2influx")
|> filter(fn: (r) => r["_field"] == "Geohash" )
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> drop(columns: ["_start", "_stop", "_measurement", "type"])
|> group(columns: ["_value"])
My expected:
Geohash | Count |
---|---|
qqt4fxmz | 3 |
So I can use the field Geohash and Count into Geohash Field and Size Field
I m looking for guidance on how to modify my query to effectively count and group Geohash values.
My Grafana and InfluxDB environment details are as follows:
- Grafana version: 10.1.4
- Data source type & version: InfluxDB 2.0.4
- OS Grafana is installed on: Docker
- User OS & Browser: Ubuntu 20.04 & Chrome
- Grafana plugins: Geomap