I am looking to send statistics like the number of requests being handled by the jetty server, the number of requests waiting in queue etc. I would like to periodically send this as a count to my statsd agent to be able to plot it on Grafana. But I could not find any public apis on the Server class that expose such metrics.
I am guessing there are other people who are already doing it. I would like to know if there is a standard way to fetch these metrics programatically?
Jetty provides an API to collect and expose statistics - StatisticsHandler. The handler can expose metrics via JMX but it doesn't have a built-in integration with StatsD.
In order to integrate it with StatsD manually, you could use one of the java statsd clients, e.g. java-statsd-client. For instance, you could schedule a task to read the data from the StatisticsHandler and send it to the StatsD agent using the abovementioned library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With