Package nl.nlighten.prometheus.tomcat
Class TomcatServletMetricsFilter
- java.lang.Object
-
- nl.nlighten.prometheus.tomcat.TomcatServletMetricsFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
public class TomcatServletMetricsFilter extends Object implements javax.servlet.Filter
A servlet filter that can be configured in Tomcat's global web.xml and that provides the following metrics: - A Histogram with response time distribution per context - A Gauge with the number of concurrent request per context - A Gauge with a the number of responses per context and status codeIf you are running Tomcat in the conventional non-embedded way you should add the client_tomcat jar and all its dependencies (see POM.XML) to the $CATALINA_BASE/lib directory or another directory on the common.loader path. Next, add this filter to the $CATALINA_BASE/lib/web.xml, e.g.:
If you running Tomcat embedded, please check AbstractTomcatMetricsTest for example configuration. Example metrics being exported:<filter> <filter-name>ServletMetricsFilter</filter-name> <filter-class>nl.nlighten.prometheus.TomcatServletMetricsFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>buckets</param-name> <param-value>.01, .05, .1, .25, .5, 1, 2.5, 5, 10, 30</param-value> </init-param> </filter>servlet_request_seconds_bucket{"/foo", "GET", "0.1",} 1.0 .... servlet_request_seconds_bucket{"/foo", "GET", "+Inf",} 1.0 servlet_request_concurrent_total{"/foo",} 1.0 servlet_response_status_total{"/foo", "200",} 1.0
-
-
Constructor Summary
Constructors Constructor Description TomcatServletMetricsFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()voiddoFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain)voidinit(javax.servlet.FilterConfig filterConfig)
-
-
-
Constructor Detail
-
TomcatServletMetricsFilter
public TomcatServletMetricsFilter()
-
-
Method Detail
-
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
- Specified by:
initin interfacejavax.servlet.Filter- Throws:
javax.servlet.ServletException
-
doFilter
public void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws IOException, javax.servlet.ServletException
- Specified by:
doFilterin interfacejavax.servlet.Filter- Throws:
IOExceptionjavax.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroyin interfacejavax.servlet.Filter
-
-