Expand my Community achievements bar.

jetty (or HTTP) statistics via jmx

Avatar

Level 4

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.

5 Replies

Avatar

Community Advisor

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

 

Regards,

Raja

Avatar

Community Advisor

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

 

Avatar

Level 4

The dispatcher logs are a different server.

 

My use case is I have a custom servlet exporting as JSON various metrics. Those metrics are pulled into an external monitoring tool. I'd like to also add HTTP metrics in that export by by getting the data first hand from the appropriate HTTP MBeans.

 

I can do a  work around and tail access logs and do something with them ... but that feels like a hacky workaround.

Avatar

Level 4

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