PromEx.Plugins.Phoenix (PromEx v1.2.2) View Source
This plugin captures metrics emitted by Phoenix. Specifically, it captures HTTP request metrics and Phoenix channel metrics.
This plugin supports the following options:
router
: This is a REQUIRED option and is the full module name of your Phoenix Router (e.g MyAppWeb.Router).event_prefix
: This option is OPTIONAL and allows you to set the event prefix for the Telemetry events. This value should align with what you pass toPlug.Telemetry
in yourendpoint.ex
file (see the plug docs for more information https://hexdocs.pm/plug/Plug.Telemetry.html)additional_routes
: This option is OPTIONAL and allows you to specify route path labels for applications routes not defined in your Router module. For example, if you want to track telemetry events for a plug in yourendpoint.ex
file, you can provide a keyword list with the structure[some-route: ~r(/some-path)]
and any time that the route is called and the plug handles the call, the path label for this particular Prometheus metric will be set tosome-route
. You can pass in either a regular expression or a string to match the incoming request.
This plugin exposes the following metric groups:
:phoenix_http_event_metrics
:phoenix_channel_event_metrics
To use plugin in your application, add the following to your PromEx module:
defmodule WebApp.PromEx do
use PromEx, otp_app: :web_app
@impl true
def plugins do
[
...
{PromEx.Plugins.Phoenix, router: WebAppWeb.Router}
]
end
@impl true
def dashboards do
[
...
{:prom_ex, "phoenix.json"}
]
end
end