use Pleroma.Web, :controller
alias Pleroma.Web.Plugs.OAuthScopesPlug
+ alias Pleroma.Config
- @unauthenticated_access %{fallback: :proceed_unauthenticated, scopes: []}
- plug(:skip_auth)
-
+ plug(
+ OAuthScopesPlug,
+ %{scopes: ["admin:metrics"]}
+ when action in [
+ :show
+ ]
+ )
def show(conn, _params) do
- stats = TelemetryMetricsPrometheus.Core.scrape()
-
- conn
- |> text(stats)
+ if Config.get([:instance, :export_prometheus_metrics], true) do
+ conn
+ |> text(Pleroma.PrometheusExporter.show())
+ else
+ conn
+ |> send_resp(404, "Not Found")
+ end
end
end