Prometheus - when I call http://localhost:4000/metrics - no route found for GET / metrics

I’m setting up Prometheus with Phoenix. I’m having trouble
When I call http://localhost:4000/metrics - no route found for GET / metrics

Here are the settings I’m following:

config.ex


instrumenters: [EudorosProducerWeb.PhoenixInstrumenter]

config: prometheus, ProducerWeb.Endpoint.Instrumenter,
  controller_call_labels: [: controller,: action],
  channel_join_labels: [: channel,: topic,: transport],
  duration_unit:: microseconds,
  registry:: default

phoenix_instrumenter.ex

defmodule ProducerWeb.PhoenixInstrumenter
    @moduledoc "" "
    Provides instrumentation for Phoenix specific metrics.
    "" "
    use Prometheus.PhoenixInstrumenter
end

mix.ex

 def application do
    [
      ...
      extra_applications: [:logger, :runtime_tools, :prometheus_phoenix]
    ]
  end
defp deps do
    [
....
      {:prometheus, "~> 4.0", override: true},
      {:prometheus_ex, "~> 3.0"},
      {:prometheus_ecto, "~> 1.0"},
      {:prometheus_phoenix, "~> 1.2"},
      {:prometheus_plugs, "~> 1.0"},
      {:prometheus_process_collector, "~> 1.3"}
...]

Where could I be wrong?

Thank you.

How does your router.ex file looks like?

It seems that you missed to add the route to the router.

1 Like

:wave:

I have a demo project that integrates prometheus with ecto and phoenix. Might be helpful.

I think I just create a metrics exporter plug there using Prometheus.PlugExporter, add it to endpoint.ex and then call setup during app startup.

Even though I haven’t tried it, the docs state not to add the plug to the router pipeline:

Do not add to Phoenix Router pipelines! You will be getting 404!