Skip to content

Commit

Permalink
Add configurable endpoint for Prometheus scraping
Browse files Browse the repository at this point in the history
  • Loading branch information
SimunKaracic committed Feb 8, 2021
1 parent 28cdeac commit 331365b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ kamon.prometheus {
# Hostname and port used by the embedded web server to publish the scraping enpoint.
hostname = "0.0.0.0"
port = 9095
path = "/metrics"

# embedded server impl
# choose between
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ import scala.collection.mutable

class SunEmbeddedHttpServer(hostname: String, port: Int, scrapeSource: ScrapeSource, config: Config) extends EmbeddedHttpServer(hostname, port, scrapeSource, config) {
private val server = {
val path = config.getString("kamon.prometheus.embedded-server.path")
val s = HttpServer.create(new InetSocketAddress(InetAddress.getByName(hostname), port), 0)
s.setExecutor(null)
val handler = new HttpHandler {
override def handle(httpExchange: HttpExchange): Unit = {
if (httpExchange.getRequestURI.getPath == "/metrics") {
if (httpExchange.getRequestURI.getPath == path) {
val data = scrapeSource.scrapeData()
val bytes = data.getBytes(StandardCharsets.UTF_8)
var os: OutputStream = null
Expand Down

0 comments on commit 331365b

Please sign in to comment.