prometheus_plugs v1.1.5 Prometheus.PlugExporter View Source
Exports Prometheus metrics via configurable endpoint:
# define plug
defmodule MetricsPlugExporter do
use Prometheus.PlugExporter
end
# on app startup (e.g. supervisor setup)
MetricsPlugExporter.setup()
# in your plugs pipeline
plug MetricsPlugExporter
Do not add to Phoenix Router pipelines! You will be getting 404!
Note that router pipelines are only invoked after a route is found.
No plug is invoked in case no matches were found.
Metrics
Also maintains telemetry metrics:
- telemetry_scrape_duration_seconds
- telemetry_scrape_size_bytes
Do not forget to call setup/0
before using plug, for example on application start!
Configuration
Plugs exporter can be configured via PlugsExporter key of :prometheus
app env.
Default configuration:
config :prometheus, MetricsPlugExporter, # (you should replace this with the name of your plug)
path: "/metrics",
format: :auto, ## or :protobuf, or :text
registry: :default,
auth: false
Export endpoint can be optionally secured using HTTP Basic Authentication:
auth: {:basic, "username", "password"}