Class PrometheusMetricsServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
io.prometheus.metrics.exporter.servlet.javax.PrometheusMetricsServlet
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
public class PrometheusMetricsServlet
extends javax.servlet.http.HttpServlet
This class extends HttpServlet to create a servlet for exporting Prometheus metrics. It uses a
PrometheusScrapeHandler to handle HTTP GET requests and export metrics. The servlet can be
configured with custom PrometheusProperties and a PrometheusRegistry.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.PrometheusMetricsServlet(io.prometheus.metrics.config.PrometheusProperties config) Constructor with custom PrometheusProperties.PrometheusMetricsServlet(io.prometheus.metrics.config.PrometheusProperties config, io.prometheus.metrics.model.registry.PrometheusRegistry registry) Constructor with custom PrometheusProperties and PrometheusRegistry.PrometheusMetricsServlet(io.prometheus.metrics.model.registry.PrometheusRegistry registry) Constructor with a custom PrometheusRegistry. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Handles HTTP GET requests.Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, serviceMethods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Constructor Details
-
PrometheusMetricsServlet
public PrometheusMetricsServlet()Default constructor. Uses the default PrometheusProperties and PrometheusRegistry. -
PrometheusMetricsServlet
public PrometheusMetricsServlet(io.prometheus.metrics.model.registry.PrometheusRegistry registry) Constructor with a custom PrometheusRegistry. Uses the default PrometheusProperties.- Parameters:
registry- the PrometheusRegistry to use
-
PrometheusMetricsServlet
public PrometheusMetricsServlet(io.prometheus.metrics.config.PrometheusProperties config) Constructor with custom PrometheusProperties. Uses the default PrometheusRegistry.- Parameters:
config- the PrometheusProperties to use
-
PrometheusMetricsServlet
public PrometheusMetricsServlet(io.prometheus.metrics.config.PrometheusProperties config, io.prometheus.metrics.model.registry.PrometheusRegistry registry) Constructor with custom PrometheusProperties and PrometheusRegistry.- Parameters:
config- the PrometheusProperties to useregistry- the PrometheusRegistry to use
-
-
Method Details
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException Handles HTTP GET requests. Exports Prometheus metrics by delegating to the PrometheusScrapeHandler.- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Parameters:
request- the HttpServletRequestresponse- the HttpServletResponse- Throws:
IOException- if an I/O error occurs
-