jetty (or HTTP) statistics via jmx | Community
Skip to main content
tim_funk
Level 3
February 24, 2022

jetty (or HTTP) statistics via jmx

  • February 24, 2022
  • 2 replies
  • 1426 views

Are there any jmx statistics exposes for the the number HTTP requests made,  as well as potentially broken out by status code response? Looking at /system/console/jmx - I didn't see anything out of the box that seemed to handle this.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Raja-Karuppsamy
Community Advisor
Community Advisor
February 25, 2022

@tim_funk From which instance you are looking for the above mentioned details - Author or Publisher ?

 

Regards,

Raja

tim_funk
tim_funkAuthor
Level 3
February 25, 2022

Both

Raja-Karuppsamy
Community Advisor
Community Advisor
February 25, 2022

Can we filter the status code or http request reaching the server from dispatcher logs ?

 

tim_funk
tim_funkAuthor
Level 3
February 25, 2022

As a workaround - I am toying with this idea .. 

@Service
@Properties({
        @Property(name = "sling.filter.scope", value = "REQUEST", propertyPrivate = true),
        @Property(name = "service.ranking", intValue = 100, propertyPrivate = true)
})
public class RequestCountFilter implements Filter {
    private AtomicLong requests = new AtomicLong(0);

    @Override
    public final void destroy() {
    }

    @Override
    public final void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        request.setAttribute("monitoring.requests", requests);
        chain.doFilter(request, response);

        // Overflow check (if we had this many requests between restarts i need a raise)
        if (requests.incrementAndGet() < 0) {
            requests.set(0);
        }
    }

    @Override
    public final void init(FilterConfig config) throws ServletException {
    }
}

And then if I need the count - I can pull it from the servletRequestAttribute