Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
systemcrash opened this issue Jun 17, 2021 · 0 comments

Comments

@systemcrash
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant