Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Question: how to scrape the prometheus reporter in v2.0.0? #35

Closed
dcastro opened this issue Oct 18, 2019 · 3 comments
Closed

Question: how to scrape the prometheus reporter in v2.0.0? #35

dcastro opened this issue Oct 18, 2019 · 3 comments

Comments

@dcastro
Copy link

dcastro commented Oct 18, 2019

To manually scrape the reporter in v1, you can do something like this:

val reporter = new PrometheusReporter()
Kamon.addReporter(new PrometheusReporter())

val data = reporter.scrapeData()

But in v2, Kamon.addReporter doesn't exist anymore. What's the correct way of doing this in v2?

@jneumaier
Copy link

I used the following workaround in Java to register my own PrometheusReporter instance (serving the scrape data on another HTTP server with TLS support):

Kamon.init(config);
Kamon._moduleRegistry().register("Prometheus Reporter", scala.Option.apply(null), prometheusReporter);

If this does not work a reporter with the exact same name "Prometheus Reporter" might have already been registered. In this case the ModuleRegistry might skip registration with a warning ("Cannot register module [$name], a module with that name already exists.")

@ane
Copy link

ane commented Jan 17, 2020

You can probably get away with by disabling the built-in module by setting kamon.modules.prometheus-reporter.enabled to false and then starting the reporter manually:

val reporter = new PrometheusReporter
Kamon.registerModule("prometheus", reporter)
// ...
val data = reporter.scrapeData()

@dcastro
Copy link
Author

dcastro commented Feb 12, 2020

Thanks @ane! Replacing addReporter with registerModule worked!

@dcastro dcastro closed this as completed Feb 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants