This is my first question in the forum. First of all, many thanks to those who developed Grafana—an excellent open-source tool.
Let me explain my limitations. I have a local web service that returns a GeoJSON with polygons and associated properties. This GeoJSON is correctly structured (I tested it in geojson.io, and it works fine).
Now, this API updates every 10 seconds, as polygons may be added to its response, or it may contain none at all. It is a dynamic solution.
My goal is to add these dynamic polygons to a GeoMap layer.
Initially, I was using the GeoJSON layer, but it is not dynamic. Even though there is a place to enter the URL, the data does not refresh when the dashboard refreshes. That is, once the dashboard is created, the data remains cached statically, and even if the API returns new polygons, the dashboard does not update.
I then enabled the Dynamic GeoJSON (Alpha) option in Grafana, which provides more capabilities. The option to add the GeoJSON via URL still exists (and remains static). However, I can now also query the data source directly. In my case, I installed and configured the JSON API data source, setting it up with my web service URL.
However, I have not been able to structure the query correctly to plot the polygons on the map.
Somewhere in grafana installation folder, there are sample geojson files, I think on map folder, open those up and it should give you an idea as to what structure is expected
Thank you for the response. The structure of my GeoJSON is correct, there are no issues there.
I’m sorry that my issue wasn’t understood. If I place my API URL in the GeoJSON URL of my layer, the polygons published by my API are correctly projected onto the map, but this is a static solution. That is, it does not refresh with the dashboard’s auto-refresh.
On the other hand, if I set the Infinity connector as the Data Source and add my API URL (http://127.0.0.1:3030/geojson?ts=${__time}), I can see the API response in the table view. However, I don’t know how to integrate this (now dynamic) data into the query provided by the Dynamic GeoJSON (Alpha) layer.
I believe I managed to share an image of my dashboard editing screen. On one side, in the Dynamic GeoJSON (Alpha) layer, I marked in blue the query component that I can’t get to work, and in red the GeoJSON URL, which I left with a placeholder value. If I set my API URL there, the polygons are correctly projected, but they do not update afterward.
I’ve already tried it and the behavior is the same as geomap. If I write the GeoURL in the layer, it shows the current polygon but won’t refresh automatically with auto refresh set up.
I’ve read an answer written by you in some other post where you mentioned how you could parse the data retrieved with Infinity to dynamically plot some polygons using Orchesrta. However, I couldn’t apply it to my solution. It didn’t work
I can see the changes in the API response correctly in the browser when I change the original geojson file.
What I don’t understand is the reason to add a data source that is not needed. I could change the data source to the grafana sample data and write my API URL to the GeoJSON URL in the dynamic geoJSON layer and it will work, but won’t refresh.
So, why is it important to add a data source? Or how could I use the data source response to plot the polygon retrieved without writing the GeoJSON URL in the layer?
The ${__time} at the end of the API URL was proposed by chatGPT as a workaround to get sure that Grafana is looking at the last published response.
It works in the sense that the API response is identical with or without that term, but didn’t solve my problem about the autorefreshing the polygons on the dashboard
Hi Josiah, again, thanks for your time and effort. I finally desisted on trying this plugin for my needs. I decided to find another way with other tools and using html and leaflet was a smoother path. I could achieve what I need with much more adaptations. I’ll keep trying grafana and maybe in a newer version the geojson plugin improved enough.