public class MetricsFilter extends Object implements javax.servlet.Filter
The Histogram name itself is required, and configured with a metric-name init parameter.
The help parameter, configured with the help init parameter, is not required but strongly recommended.
By default, this filter will provide metrics that distinguish only 1 level deep for the request path
(including servlet context path), but can be configured with the path-components init parameter. Any number
provided that is less than 1 will provide the full path granularity (warning, this may affect performance).
The Histogram buckets can be configured with a buckets init parameter whose value is a comma-separated list
of valid double values.
<filter>
<filter-name>prometheusFilter</filter-name>
<filter-class>io.prometheus.client.filter.MetricsFilter</filter-class>
<init-param>
<param-name>metric-name</param-name>
<param-value>webapp_metrics_filter</param-value>
</init-param>
<init-param>
<param-name>help</param-name>
<param-value>The time taken fulfilling servlet requests</param-value>
</init-param>
<init-param>
<param-name>buckets</param-name>
<param-value>0.005,0.01,0.025,0.05,0.075,0.1,0.25,0.5,0.75,1,2.5,5,7.5,10</param-value>
</init-param>
<init-param>
<param-name>path-components</param-name>
<param-value>0</param-value>
</init-param>
</filter>
| Constructor and Description |
|---|
MetricsFilter() |
MetricsFilter(String metricName,
String help,
Integer pathComponents,
double[] buckets) |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
void |
doFilter(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse,
javax.servlet.FilterChain filterChain) |
void |
init(javax.servlet.FilterConfig filterConfig) |
public MetricsFilter()
public MetricsFilter(String metricName, String help, Integer pathComponents, double[] buckets)
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
init in interface javax.servlet.Filterjavax.servlet.ServletExceptionpublic void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws IOException, javax.servlet.ServletException
doFilter in interface javax.servlet.FilterIOExceptionjavax.servlet.ServletExceptionpublic void destroy()
destroy in interface javax.servlet.FilterCopyright © 2018. All rights reserved.