Comments (6)
Hello,
Could you show us some sample code, or provide a bit more context of what you are doing?
from client_ruby.
My idea was to write a python client exporter for prometheus which spawns a webservice where prometheus can scrape the data of the gauges i write in this python program. Something like most existing exporters.
But for this i need to be able to specify the IP-address and port address.
Maybe another example to clarify. There exist a dovecot exporter for prometheus but you can specify the parameters.
"--web.listen-address="127.0.0.1:9166". So explicitly you can tell prometheus then to scrape on that IP-address and that specific port.
This is import in the case a port is already used by another instance which i think is in my case.
Or compare to python-code , because my knowledge of the ruby API is limited.
-> from prometheus_client import start_http_server
if name == 'main':
start_http_server(8000)
Works, but it is binding to all interfaces which is a serious security risk.
Maybe I need something like
prometheus = Prometheus::Client.registry(host:"127.0.0.1",port:"8000")
I looked at your code but was unable to find places where you pass IP-address or portnumber information which is essential for my use case.
Luckely the python api knows : "start_http_server(addr="127.0.0.1",port=38000)", but the ruby equivalent would be nice to have.
from client_ruby.
Our exporter middleware will allow you to filter by port, once we release the new version (which should be soon), so that's half the use case you are looking for. To also filter by IP you'd have to make your own exporter, you can start by copying the one in our master branch, and then adding the IP filtering.
That said, the error you describe seems to be that the same metric is being registered twice. This sounds like you are adding the Collector middleware twice?
from client_ruby.
Currently I have 80 tcp listeners running for different reasons, so probably that port was already occupied.
One final question. Could you guide me to which ruby file in this repo, or which function within it, where i can, after cloning this repo, hardcode an IP-address & Port. Probably this is the deepest function, where not all parameters are given or the defaults are taken.
from client_ruby.
You don't need to clone the repo. The way our middleware works, you can just copy the contents of it into a file in your app, and add that middleware to Rack, you don't need to modify the gem, just point to your copy of the middleware instead.
This is the file you are looking for:
https://github.com/prometheus/client_ruby/blob/master/lib/prometheus/middleware/exporter.rb
That said, I still think the error you are receiving is not a "two things tried to open the same port". That error is "the same metric got registered twice".
from client_ruby.
Closing this as it's stale, and I think wasn't for something our gem would handle in the first place.
Luckely the python api knows : "start_http_server(addr="127.0.0.1",port=38000)", but the ruby equivalent would be nice to have.
We don't start any HTTP servers directly in the gem, and by extension don't bind to any network interfaces.
from client_ruby.
Related Issues (20)
- CPU usage growing over time with DirectFileStore HOT 1
- better path handling HOT 14
- Update README.md with changes to pushgateway client
- Update CHANGELOG.md for 3.0.0 release HOT 1
- `generate_path` yields incorrect values for Sinatra+Rack::Build apps HOT 6
- Exporter port option doesn't work HOT 2
- Counter metric is reset when it has no labels HOT 8
- ERROR: Permission to prometheus/client_ruby.git denied HOT 2
- The rack example does not work because of `Rack::Lint::LintError` HOT 1
- Aaup HOT 1
- How to metrify ActiveRecord sql queries and Redis jobs (sidekiq/resque)? HOT 1
- pushing metrics with instance grouping_key would result: instance is reserved HOT 6
- Fix `Rack` deprecation warning
- Improving DirectFileStore for performance and scalability HOT 18
- Implement native histograms support HOT 4
- cannot load such file -- prometheus/middleware/collector (LoadError) HOT 2
- Job name for pushgateway can't be a symbol HOT 1
- UTF-8: Implement support in Ruby client library HOT 5
- How can I change how paths are labelled? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from client_ruby.