Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link to repo that use TelemetryMetricsPrometheus #42

Open
ebengt opened this issue Sep 15, 2023 · 5 comments
Open

Link to repo that use TelemetryMetricsPrometheus #42

ebengt opened this issue Sep 15, 2023 · 5 comments

Comments

@ebengt
Copy link

ebengt commented Sep 15, 2023

Greetings,

I have read Hex documentation for TelemetryMetricsPrometheus, Telemetry.Metrics, OpentelemetryPhoenix
It probably should be enough, but I fail to get content from localhost:9568/metrics. I get a 200 Response, but 0 content-length.

A link to any repo using TelemetryMetricsPrometheus (and Phoenix, if possible), would be much appreciated.

From my application.ex

  def start(_type, _args) do
    :opentelemetry_cowboy.setup()
    OpentelemetryPhoenix.setup(adapter: :cowboy2)
    OpentelemetryEcto.setup([:excdf, :repo])

    metrics =  [
    Telemetry.Metrics.last_value("vm.memory.total", unit: :byte),
    Telemetry.Metrics.counter("http.request.count", unit: :byte),
    Telemetry.Metrics.sum("http.request.payload_size", unit: :byte)
    ]

    children = [
      # Start the Telemetry supervisor
      ExcdfWeb.Telemetry,
      {Phoenix.PubSub, name: ExcdfWeb.PubSub},
      {TelemetryMetricsPrometheus, [metrics: metrics]},
      # Start the Endpoint (http/https)
      ExcdfWeb.Endpoint
    ]

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: ExcdfWeb.Supervisor]
    Supervisor.start_link(children, opts)
  end

@bryannaegele
Copy link
Collaborator

Hey @ebengt. It looks like you're missing some setup still.

Of the metrics you have defined, there's not enough definition to capture phoenix events, for instance. Example.

For the other metric, you're trying to record metrics for the VM but didn't start telemetry poller which is what emits those events, but maybe it's getting started someplace else?

You might want to consider using uplink to simplify and organize things.

@ebengt
Copy link
Author

ebengt commented Sep 15, 2023

Thank you.

I am migrating from prometheus.ex and there prometheus_ecto/prometheus_phoenix did not need a poller.
I will try to add uplink and see if I progress.

The presence of "vm.memory.total" is mostly due to copy/paste, if it had worked that would have been nice but it is not my main goal.

Is there no publicly available repo using TelemetryMetricsPrometheus (and Phoenix, if possible)?

@ebengt
Copy link
Author

ebengt commented Sep 16, 2023

Greetings,

Yes, Uplink works with the Uplink monitors.

When creating a new Phoenix app I get a sample file with Telemetry.Metrics.ConsoleReporter as reporter. It says that I can add more reporters, so I tried TelemetryMetricsPrometheus. The metrics for Telemetry.Metrics.ConsoleReporter are all summary/2, and that is not available in Prometheus. I changed to last_value/2 and that works. This way I can use TelemetryMetricsPrometheus without adding Uplink (because Phoenix added a module for me).

@bryannaegele
Copy link
Collaborator

bryannaegele commented Sep 16, 2023 via email

@ebengt
Copy link
Author

ebengt commented Sep 17, 2023

As an example I added TelemetryMetricsPrometheus to my repo https://github.com/ebengt/becomics
It is Phoenix based and I use last_value/2 instead of summary/2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants