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

Run query based on URL POST Request #86

Open
mrueg opened this issue Nov 3, 2020 · 4 comments
Open

Run query based on URL POST Request #86

mrueg opened this issue Nov 3, 2020 · 4 comments

Comments

@mrueg
Copy link

mrueg commented Nov 3, 2020

It would be a nice feature, if prometheus-es-exporter could execute a query based on a POST request, similar to blackbox_exporter (compare e.g. https://github.com/prometheus/blackbox_exporter#checking-the-results )
e.g. https://es-exporter/metrics?query=$MY_QUERY

This has certain advantages, as one could quickly replace the query without redeploying the exporter or run multiple queries (based on different requests) at different intervals.

@braedon
Copy link
Owner

braedon commented Nov 6, 2020

Hi @mrueg, could you clarify what kind of queries you'd like to run?

We could use an endpoint like this to run a query string query and get basic count metrics, but I don't know of a reasonable way to do aggregations?

@askz
Copy link

askz commented Nov 16, 2020

we could support urlencoded or base64 encoded query string to achieve this

@braedon
Copy link
Owner

braedon commented Nov 18, 2020

Yeah, it's definitely possible to encode the query JSON in a URL, but it doesn't seem like it'd be very user friendly...

Just supporting doc count metrics from a query string query would be a lot friendlier - it's a direct translation from the ES API - but I'm not sure if that'd satisfy @mrueg's use case.

To be honest, I'm a little reluctant to add a custom metrics endpoint full stop, as it'd require moving away from the built-in Prometheus library HTTP server. There's also potentially extra security implications - the ability to run arbitrary queries on the cluster could be used to extract sensitive data if an attacker has access to the exporter metrics endpoint, but not the Elasticsearch API itself.

I'm open to adding it if there's a clear benefit and user demand, but need to be convinced 😄.

@mrueg
Copy link
Author

mrueg commented Nov 18, 2020

@braedon The setup I image would use prometheus-operator on Kubernetes with trusted users being able to hit the prometheus-es-exporter with custom queries by creating their own ServiceMonitor objects. I agree that the endpoint needs protection from abuse, similar to blackbox-exporter or others that allow running custom queries.

The advantages I see from this approach is getting an easy way to update/change queries without redeploying the whole exporter and its configuration as well as allowing multiple users to share the same exporter instance.

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

No branches or pull requests

3 participants