Im trying to create a metrics endpoint as part of my web application using
the Java_client project https://github.com/prometheus/client_java as a
proof of concept.
I have the hibernatestatisticscollector created and been used in other
sessions.
I want an endpoint that I can query these metrics in another session.
I am accessing the registry and getting results like so
CollectorRegistry collector = CollectorRegistry.defaultRegistry;
Enumeration<Collector.MetricFamilySamples> metricSample =
collector.metricFamilySamples();
StringBuilder sb =new StringBuilder();
for (Enumeration<Collector.MetricFamilySamples> e = metricSample;
e.hasMoreElements();){
sb.append(e.nextElement());
}
return sb.toString();
This seems to me to be a bit of a hack.
CollectorRegistry.defaultRegistry; can contain many registries, but these
objects dont give me a public way to find a registry by the name I use to
create it.
Also, I dont like the loop I need to pass each line to a string builder, is
there some way I can just dump the contents to a return type, like a string?
Im pretty sure Im doing something wrong here, but I'm finding the examples
a little confusing so any help will be appreciated.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/d3aaf8af-abb3-4a13-95c2-cac7589826b6n%40googlegroups.com.