View Source PromEx.Plugins.PlugCowboy (PromEx v1.10.0)
This plugin captures HTTP request metrics emitted by Plug.Cowboy.
This plugin exposes the following metric group:
:plug_cowboy_http_event_metrics
Plugin options
routers
: Required This is a list with the full module names of your Routers (e.g MyAppWeb.Router). Phoenix and Plug routers are supported. When the Phoenix dependency is present in your project, a list of Phoenix Routers is expected. Otherwise a list of Plug.Router modules must be providedevent_prefix
: Optional, allows you to set the event prefix for the Telemetry events.metric_prefix
: This option is OPTIONAL and is used to override the default metric prefix of[otp_app, :prom_ex, :plug_cowboy]
. If this changes you will also want to setplug_cowboy_metric_prefix
in yourdashboard_assigns
to the snakecase version of your prefix, the defaultplug_cowboy_metric_prefix
is{otp_app}_prom_ex_plug_cowboy
.duration_unit
: This is an OPTIONAL option and is aTelemetry.Metrics.time_unit()
. It can be one of::second | :millisecond | :microsecond | :nanosecond
. It is:millisecond
by default.
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.PlugCowboy, routers: [MyApp.Router]}
]
end
@impl true
def dashboards do
[
...
{:prom_ex, "plug_cowboy.json"}
]
end
end
To ignore certain paths, pass a list of routes using the :ignore_routes
option
defmodule WebApp.PromEx do
use PromEx, otp_app: :web_app
@impl true
def plugins do
[
...
{PromEx.Plugins.PlugCowboy, routers: [MyApp.Router], ignore_routes: ["/metrics"]}
]
end
@impl true
def dashboards do
[
...
{:prom_ex, "plug_cowboy.json"}
]
end
end