diff --git a/app/controllers/Main.scala b/app/controllers/Main.scala index 413676945bb29..453f0901a25e1 100644 --- a/app/controllers/Main.scala +++ b/app/controllers/Main.scala @@ -112,6 +112,11 @@ final class Main( env.security.lilaCookie.withSession(remember = true): s => s + ("theme" -> "ic") + ("pieceSet" -> "icpieces") + def prometheusMetrics(key: String) = Action: + if key == env.web.config.prometheusKey + then kamon.prometheus.PrometheusReporter.latestScrapeData().fold(NotFound("No metrics found"))(Ok(_)) + else NotFound("Invalid prometheus key") + def legacyQaQuestion(id: Int, _slug: String) = Open: MovedPermanently: StaticContent.legacyQaQuestion(id) diff --git a/conf/base.conf b/conf/base.conf index 68ab6c22145d8..cf0058a107c62 100644 --- a/conf/base.conf +++ b/conf/base.conf @@ -437,6 +437,7 @@ kamon { } } prometheus { + lilaKey = "" buckets { default-buckets = [10, 100, 1000, 10000, 100000] time-buckets = [0.01, 0.05, 0.1, 0.5, 1, 5, 10] diff --git a/conf/routes b/conf/routes index fb7335bc6f56d..7edcdad023ee0 100644 --- a/conf/routes +++ b/conf/routes @@ -874,6 +874,7 @@ POST /dev/cli controllers.Dev.cliPost GET /dev/settings controllers.Dev.settings POST /dev/settings/:id controllers.Dev.settingsPost(id) +GET /prometheus-metrics/:key controllers.Main.prometheusMetrics(key: String) POST /dev/socket-test controllers.Dev.socketTestResult # Push diff --git a/modules/web/src/main/WebConfig.scala b/modules/web/src/main/WebConfig.scala index c87ce3f7e4801..dfe25b3da342b 100644 --- a/modules/web/src/main/WebConfig.scala +++ b/modules/web/src/main/WebConfig.scala @@ -10,6 +10,7 @@ final class WebConfig( val apiToken: Secret, val influxEventEndpoint: String, val influxEventEnv: String, + val prometheusKey: String, val pagerDuty: WebConfig.PagerDuty ) @@ -32,6 +33,7 @@ object WebConfig: c.get[Secret]("api.token"), c.get[String]("api.influx_event.endpoint"), c.get[String]("api.influx_event.env"), + c.get[String]("kamon.prometheus.lilaKey"), new PagerDuty( c.get[String]("pagerDuty.serviceId"), c.get[Secret]("pagerDuty.apiKey")