2022-12-14 19:02:07 -07:00
|
|
|
defmodule Pleroma.Web.AkkomaAPI.MetricsController do
|
|
|
|
use Pleroma.Web, :controller
|
|
|
|
|
|
|
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
2022-12-16 04:17:04 -07:00
|
|
|
alias Pleroma.Config
|
2022-12-14 19:02:07 -07:00
|
|
|
|
2022-12-15 20:32:51 -07:00
|
|
|
plug(
|
|
|
|
OAuthScopesPlug,
|
|
|
|
%{scopes: ["admin:metrics"]}
|
|
|
|
when action in [
|
|
|
|
:show
|
|
|
|
]
|
|
|
|
)
|
2022-12-14 19:02:07 -07:00
|
|
|
|
|
|
|
def show(conn, _params) do
|
2022-12-16 04:17:04 -07: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-14 19:02:07 -07:00
|
|
|
end
|
|
|
|
end
|