Exposing Prometheus metrics

To expose the Prometheus metrics, we will use a set of Elixir libraries that let us emit new metrics and also introduce out-of-the-box Phoenix, Plug, and Ecto metrics:

$ cat apps/elixir_drip/mix.exs  # ...  defp deps do    [      # ...      {:prometheus, "~> 4.0", override: true},      {:prometheus_ex, "~> 3.0", override: true},      {:prometheus_ecto, "~> 1.0"},    ]  end  # ...$ cat apps/elixir_drip_web/mix.exs  # ...  defp deps do    [      # ...      {:prometheus_phoenix, "~> 1.2"},      {:prometheus_plugs, "~> 1.1"},    ]  end  # ...

Let's now start with the Phoenix metrics. We need to define a simple EndpointInstrumenter module, which will use the PhoenixInstrumenter module:

$ cat apps/elixir_drip_web/lib/elixir_drip_web/prometheus/endpoint_instrumenter.exdefmodule ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.