discourse / prometheus_exporter

A framework for collecting and aggregating prometheus metrics
MIT License
532 stars 154 forks source link

how to specify client options when using rails middleware? #105

Closed ckolderup closed 4 years ago

ckolderup commented 4 years ago

Hi,

I want to get started just using the standard rails middleware to instrument status codes/timings. I've set everything up, but I'm running the exporter in a separate container and want to configure things in the rails app container to use a hostname/port instead of just localhost:9394. Right now I've got the initializer set up as described in the README:

require 'prometheus_exporter/middleware'
Rails.application.middleware.unshift PrometheusExporter::Middleware

how can I pass in options to the client that gets created by the middleware (or create a client and pass it in)? I see that the middleware class has a constructor that accepts this as a parameter but after some searching around I can't understand how to actually pass parameters to it.

SamSaffron commented 4 years ago

if it is inside a container would you not just export/publish the port from the container?

ckolderup commented 4 years ago

@SamSaffron there's two different containers; one whose entry point is starting the rails app and one that's running bundle exec prometheus_exporter. Both the rails container and the exporter container are on the same docker network, but not the same host, right? I need to set the hostname to something, even if the port stays the same. (This is what we do for things like mysql and redis in the same rails apps-- refer to them via hostnames named after the service they're set up as in the docker-compose.yml)

ckolderup commented 4 years ago

We're going to go with a different strategy-- closing this.