Add support for multiple scrape addresses by brandon1024 · Pull Request #539 · nginx/nginx-prometheus-exporter (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation7 Commits1 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Proposed changes
Make the nginx.scrape-uri
accept a slice of addresses, and register prometheus collectors for each monitored nginx instance.
This revision came out of a discussion in #229. The general concensus by those in the thread was that it would be better to run an nginx-exporter for every monitored nginx instance. I had implemented these changes for my own use, so I decided to make them available to the wider community here.
Feel free to merge, or don't :-) I'm fine with either.
Checklist
Before creating a PR, run through this checklist and mark each as complete.
- I have read the CONTRIBUTING
guide - I have proven my fix is effective or that my feature works
- I have checked that all unit tests pass after adding my changes
- I have ensured the README is up to date
- I have rebased my branch onto main
- I will ensure my PR is targeting the main branch and pulling from my branch on my own fork
Hi @brandon1024, thanks for the PR!
It seems like a relatively small change and it would make a few people happy 🙂
My only concern is that we're adding a new label addr
to all the metrics and this is generally not recommended (as I mentioned in the issue). Do you think it would make sense to add the label only if there are multiple scrape URIs? So the majority of the users would not see any difference when running the exporter with just one URI? Or do we want to keep it consistent?
Also, do you think this is considered a breaking change?
Thanks for the review @lucacome 🙂
My only concern is that we're adding a new label
addr
to all the metrics and this is generally not recommended (as I mentioned in the issue). Do you think it would make sense to add the label only if there are multiple scrape URIs? So the majority of the users would not see any difference when running the exporter with just one URI? Or do we want to keep it consistent?
That's fair, and this did cross my mind when I was implementing these changes. I agree it would be better to add the address label only when more than one address is given. This will be pretty easy to implement, I'll make some tweaks today and push a new revision.
Also, do you think this is considered a breaking change?
Once I make those minor changes, it would be completely backwards compatible :-)
Make the nginx.scrape-uri
accept a slice of addresses, and register
prometheus collectors for each nginx instance. When multiple scrape
addresses are registered, include the scrape address as a label to
differentiate the metrics for each instance.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lucacome requested review froma team and removed request fora team
Done!
Hi,
sorry, but I am running in circles and don't get it done...
How is the final syntax to get several nginx servers collected by one prometheus-nginx-exporter?
ARGS=" -nginx.scrape-uri .... how ever, but at least two uri-adresses"
Regards
Gerhard
To configure several scrape addresses, you just need to provide the flag more than once:
$ docker run -it --rm nginx/nginx-prometheus-exporter:latest --nginx.scrape-uri=<addr-1> --nginx.scrape-uri=<addr-2>
Hi,
thx!!!
Works perfect.
Regards
Gerhard