Tracking Metrics Per Session/Request

68 views
Skip to first unread message

KW

unread,
Jul 3, 2023, 3:18:35 PM7/3/23
to Prometheus Users
Hello,

I work with an ASP.NET Core API that uses sessions to store the user's state. The API calls out to many other different microservices to run logic based on the user's request, we update and save the state on the server, and return the relevant information in the response. I'm looking to be able to troubleshoot performance issues by looking at metrics for an entire session. I roughly understand how I can add timing metrics, but what is the mechanism I'd use to differentiate sessions, and even similar requests within the session? For example, I'd like to know that the third identical request that was made on a given session took 43 seconds while the others were only 2 seconds. If I use a label for session id, I won't see the individual request timings... would I need to create an additional "request id" label that I can use? Perhaps pull the Activity.Current trace id that is used for exemplars? Not sure what the best practices are here.

Stuart Clark

unread,
Jul 3, 2023, 4:51:26 PM7/3/23
to KW, Prometheus Users
This sounds like you might actually want traces rather than just
metrics, which can be added using Tempo or other tools.

--
Stuart Clark

KW

unread,
Jul 5, 2023, 9:38:44 AM7/5/23
to Prometheus Users
Thank you!

Matt Doughty

unread,
Jul 5, 2023, 12:24:16 PM7/5/23
to KW, Prometheus Users
To expand on this a bit. If you added session-id as a label, you would
end up with an unbounded cardinality problem, and that leads to a very
bad time in Prometheus. Never try to capture things like client-ip,
session-id, order-number etc. in your metrics.

Definitely look into tracing for this sort of thing.

--Matt
> --
> You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/8a533bc5-8357-4059-8d10-c0092b3ee09cn%40googlegroups.com.



--
--Matt
Reply all
Reply to author
Forward
0 new messages