grafana / worldmap-panel

Worldmap panel plugin for Grafana 3.0 that can be overlaid with circles for data points.
MIT License
310 stars 199 forks source link

Provide query parameters to JSON endpoint (from e.g. Loki query results) #317

Open systemcrash opened 3 years ago

systemcrash commented 3 years ago

How do we provide query parameters (to a JSON endpoint)?

I have a Loki query for JSON logs flowing in:

sum by (remote_addr) (count_over_time({host=~"$host"} | json | __error__="" [1m]))

Which, I don't know, I think it should give me a list of remote_addr which is a list of IPs. Whatever. Not important. Whichever Loki query returns a list of remote_addr.

I have a JSON endpoint in the map panel (don't know what aggregation should be). The endpoint returns location data for corresponding IPs. IPs could just as well be some other entity we could look up.

So I can query either (for a single remote_addr): http://localhost/country/

produces

{
  "country": "US",
  "country_3": "USA",
  "ip": "1.2.3.4",
  "name": "United States"
}

or (for multiple remote_addr) http://localhost/country/?ip=ip1,ip2,ip3

produces

[
  {
    "country": "US",
    "country_3": "USA",
    "ip": "8.8.8.8",
    "name": "United States"
  },
  {
    "country": "US",
    "country_3": "USA",
    "ip": "1.2.3.4",
    "name": "United States"
  }
]

This could be augmented to JSONP.

Is this possible today? easy to implement? JSON endpoint can take something like:

http://localhost/country/{{.remote_addr}} for both single and multiple remote_addr