Grafana includes a WorldMap visualization so you can see geospatial data overlaid on a map. This can be helpful to understand how data changes based on its location.

This section visualizes taxi rides in Manhattan, where the distance traveled was greater than 5 miles. It uses the same query as the NYC Taxi Cab tutorial as a starting point.

  1. In your Grafana dashboard, create a new panel, select New Visualization, and select Worldmap Panel.

  2. Navigate to the Queries tab.

  3. Select your data source.

  4. In the Format as dropdown, select Table. Click Edit SQL and enter the query you want to use. This examples uses this query:

    SELECT time_bucket('5m', rides.pickup_datetime) AS time,
    rides.trip_distance AS value,
    rides.pickup_latitude AS latitude,
    rides.pickup_longitude AS longitude
    FROM rides
    WHERE $__timeFilter(rides.pickup_datetime) AND
    ST_Distance(pickup_geom,
    ST_Transform(ST_SetSRID(ST_MakePoint(-73.9851,40.7589),4326),2163)
    ) < 2000
    GROUP BY time,
    rides.trip_distance,
    rides.pickup_latitude,
    rides.pickup_longitude
    ORDER BY time
    LIMIT 500;
  5. Configure the visualization by navigating to the Visualization tab. Make sure the Map Data Options are set to table and current.

  6. In the Field Mappings section, set the Table Query Format to Table.

  7. Map the Latitude Field to the latitude variable, the Longitude Field to the longitude variable, and the Metric field to the value variable.

  8. In the Map Visual Options section, set the Min Circle Size to 1, and the Max Circle Size to 5.

  9. In the Threshold Options section, set the Thresholds to 2,5,10. This automatically configures a set of colors, which you can adjust later.

Visualizing time series data in PostgreSQL using the Grafana Worldmap

Keywords

Found an issue on this page?Report an issue or Edit this page in GitHub.