akkoma/lib/pleroma/web/akkoma_api/controllers/metrics_controller.ex

25 lines
506 B
Elixir
Raw Normal View History

2022-12-15 02:02:07 +00:00
defmodule Pleroma.Web.AkkomaAPI.MetricsController do
use Pleroma.Web, :controller
alias Pleroma.Web.Plugs.OAuthScopesPlug
2022-12-16 11:17:04 +00:00
alias Pleroma.Config
2022-12-15 02:02:07 +00:00
plug(
OAuthScopesPlug,
%{scopes: ["admin:metrics"]}
when action in [
:show
]
)
2022-12-15 02:02:07 +00:00
def show(conn, _params) do
2022-12-16 11:17:04 +00:00
if Config.get([:instance, :export_prometheus_metrics], true) do
conn
|> text(TelemetryMetricsPrometheus.Core.scrape())
else
conn
|> send_resp(404, "Not Found")
end
2022-12-15 02:02:07 +00:00
end
end