View Source Peep.Plug (peep v3.3.0)
Use this plug to expose your metrics on an endpoint for scraping. This is useful if you are using Prometheus.
This plug accepts the following options:
:peep_worker
- The name of the Peep worker to use. This is required.:path
- The path to expose the metrics on. Defaults to"/metrics"
.
Usage
You can use this plug in your Phoenix endpoint like this:
plug Peep.Plug, peep_worker: :my_peep_worker
Or if you'd rather use a different path:
plug Peep.Plug, path: "/my-metrics"
If you are not using Phoenix, you can use it directly with Cowboy by adding this to your applications's supervision tree:
{Plug.Cowboy, scheme: :http, plug: Peep.Plug, options: [port: 9000]}
Similarly, if you are using Bandit, you can use it like so:
{Bandit.Plug, scheme: :http, plug: Peep.Plug, options: [port: 9000]}