Hi family I am working with Plug.Telemetry and trying to catch the metrics that are generated by it
this is my example:
defmodule PlugExample.Router do
use Plug.Router
plug Plug.Telemetry, event_prefix: [:http, :request] # metrics to generate
plug :match
plug Plug.Parsers, parsers: [:urlencoded, :multipart]
plug :dispatch
get "/" do
Process.sleep(1000)
send_resp(conn, 200, "Welcome")
end
end
the metrics that are generated are captured and exposed by telemetry_metrics_prometheus :
counter("http.request.start", event_name: [:http, :request, :start], measurement: :value),
counter("http.request.stop", event_name: [:http, :request, :stop], measurement: :value),
and show in the following path http://localhost:8081/metrics
# HELP http_request_stop
# TYPE http_request_stop counter
http_request_stop 1
# HELP http_request_start
# TYPE http_request_start counter
http_request_start 1
however I do not know how to capture other metrics for example last_value as is shown :
last_value(“http.request.stop”, event_name: [:http, :request, :stop], measurement: :duration)
I mean if I want to capture with the last_value all metadata that is generated by Plug.Telemetry, I cannot.
for example, I want to capture something like this:
http_response_stop_duration{event_type="RESPONSE",message_id="123",method="POST",path="/pockets/retrieve",request_ending_time="2023-03-09 16:53:13.482000Z",status="SUCCESS",status_desc="200",systemId="123"} 55.0