Skip to content

Commit

Permalink
fix #2048
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuancelin committed Dec 11, 2024
1 parent 4d588a4 commit c21f1e0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions otoroshi/app/next/plugins/otoroshi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -583,5 +583,28 @@ class OtoroshiHealthEndpoint extends NgBackendCall {
}
}

class OtoroshiMetricsEndpoint extends NgBackendCall {

override def steps: Seq[NgStep] = Seq(NgStep.CallBackend)
override def categories: Seq[NgPluginCategory] = Seq(NgPluginCategory.Authentication)
override def visibility: NgPluginVisibility = NgPluginVisibility.NgUserLand
override def multiInstance: Boolean = true
override def core: Boolean = true
override def name: String = "Otoroshi Metrics endpoint"
override def description: Option[String] = "This plugin provide an endpoint to return Otoroshi metrics data for the current node".some
override def defaultConfigObject: Option[NgPluginConfig] = None
override def useDelegates: Boolean = false
override def noJsForm: Boolean = true
override def configFlow: Seq[String] = Seq.empty
override def configSchema: Option[JsObject] = None

override def callBackend(ctx: NgbBackendCallContext, delegates: () => Future[Either[NgProxyEngineError, BackendCallResponse]])(implicit env: Env, ec: ExecutionContext, mat: Materializer): Future[Either[NgProxyEngineError, BackendCallResponse]] = {
val format = ctx.rawRequest.getQueryString("format")
val filter = ctx.rawRequest.getQueryString("filter")
val acceptsJson = ctx.rawRequest.accepts("application/json")
val acceptsProm = ctx.rawRequest.accepts("application/prometheus")
val res = HealthController.fetchMetrics(format, acceptsJson, acceptsProm, filter)
Right(BackendCallResponse(NgPluginHttpResponse.fromResult(res), None)).vfuture
}
}

0 comments on commit c21f1e0

Please sign in to comment.