English 中文(简体)
How to Count and Group Geohash Values in InfluxDB V2 Using Grafana
原标题:
The bounty expires in 7 days. Answers to this question are eligible for a +50 reputation bounty. iamyusuf is looking for an answer from a reputable source.

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"])

enter image description here

My expected:

Geohash Count
qqt4fxmz 3

So I can use the field Geohash and Count into Geohash Field and Size Field enter image description here

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
问题回答

暂无回答




相关问题
Grafana with Litespeed server both not working

I try to install Grafana and OpenLitespeed (CyberPanel) in same VPC server. When I install both same server, both pages are not loading. Example: VPC public ip - a.b.c.d, when go to a.b.c.d IP address ...

Grafana interval variable: minimum threshold function?

I m adding an interval variable to a dashboard to allow averaging some prometheus time series over an interval to get cleaner looking graphs. But I want to leave in the base sample rate (15s) so the ...

How to specify time range in {aggregate}_over_time?

I have a Grafana chart that makes use of the sum_over_time(data_source[$__interval]) and count_over_time(data_source[$__interval]) command in Prometheus. Normally, it is working fine. But, the ...

change grafana port using docker host network

I am trying to spin up a grafana container in docker, however my setup in docker does not allow ipv4 forwarding and thus I cannot use the default bridge network in docker. All I can use is the host ...

Promtail Targets Failed

What Grafana version and what operating system are you using? Promtail:latest & Loki:2.2.0, Kubernetes (GitVersion:"v1.18.8") and Helm (Version:"v3.6.2") What are you trying ...

Last known timestamp of a metric sample?

How do I get the timestamp of the last known sample of a metric? I want to display a table that lists when was the last time a specific service was running before it disappeared (died or whatever). ...

热门标签