telemetry_metrics_prometheus
telemetry_metrics_prometheus copied to clipboard
Link to repo that use TelemetryMetricsPrometheus
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
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.
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)?
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).
It only accepts integers
On Sat, Sep 16, 2023, 12:56 PM bengt kleberg @.***> wrote:
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 sum/2. But that gives this error when testing :
20:38:52.988 mfa=:telemetry.execute/3 [error] Handler {TelemetryMetricsPrometheus.Core.EventHandler, #PID<0.471.0>, [:excdf, :repo, :query, :total_time]} has failed and has been detached. Class=:error Reason=:badarg Stacktrace=[ {:ets, :update_counter, [ :prometheus_metrics, {[:excdf, :repo, :query, :total_time], %{}}, 1.196542, {{[:excdf, :repo, :query, :total_time], %{}}, 0} ], [error_info: %{module: :erl_stdlib_errors}]}, {TelemetryMetricsPrometheus.Core.Sum, :handle_event, 4, [file: ~c"lib/core/sum.ex", line: 62]},
Is there an option to sum/2 that will make this error go away?
— Reply to this email directly, view it on GitHub https://github.com/beam-telemetry/telemetry_metrics_prometheus/issues/42#issuecomment-1722293695, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLXHVJEF6PKP2L3ZQCYX43X2XY5VANCNFSM6AAAAAA4Z2RTCQ . You are receiving this because you commented.Message ID: @.*** com>
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.