Package io.prometheus.client.exporter
Class HTTPServer.Builder
- java.lang.Object
-
- io.prometheus.client.exporter.HTTPServer.Builder
-
- Enclosing class:
- HTTPServer
public static class HTTPServer.Builder extends Object
We keep the original constructors ofHTTPServer
for compatibility, but new configuration parameters likesampleNameFilter
must be configured using the Builder.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HTTPServer
build()
Build the HTTPServerHTTPServer.Builder
withAuthenticator(com.sun.net.httpserver.Authenticator authenticator)
Optional:Authenticator
to use to support authentication.HTTPServer.Builder
withDaemonThreads(boolean daemon)
By default, theHTTPServer
uses non-daemon threads.HTTPServer.Builder
withHostname(String hostname)
Use this hostname to resolve the IP address to bind to.HTTPServer.Builder
withHttpsConfigurator(com.sun.net.httpserver.HttpsConfigurator configurator)
Optional:HttpsConfigurator
to use to support TLS/SSLHTTPServer.Builder
withHttpServer(com.sun.net.httpserver.HttpServer httpServer)
Use this httpServer.HTTPServer.Builder
withInetAddress(InetAddress address)
Bind to this IP address.HTTPServer.Builder
withInetSocketAddress(InetSocketAddress address)
Listen on this address.HTTPServer.Builder
withPort(int port)
Port to bind to.HTTPServer.Builder
withRegistry(io.prometheus.client.CollectorRegistry registry)
Optional: Default isCollectorRegistry.defaultRegistry
.HTTPServer.Builder
withSampleNameFilter(io.prometheus.client.Predicate<String> sampleNameFilter)
Optional: Only export time series wheresampleNameFilter.test(name)
returns true.HTTPServer.Builder
withSampleNameFilterSupplier(io.prometheus.client.Supplier<io.prometheus.client.Predicate<String>> sampleNameFilterSupplier)
Optional: Only export time series wheresampleNameFilter.test(name)
returns true.
-
-
-
Constructor Detail
-
Builder
public Builder()
-
-
Method Detail
-
withPort
public HTTPServer.Builder withPort(int port)
Port to bind to. Must not be called together withwithInetSocketAddress(InetSocketAddress)
orwithHttpServer(HttpServer)
. Default is 0, indicating that a random port will be selected.
-
withHostname
public HTTPServer.Builder withHostname(String hostname)
Use this hostname to resolve the IP address to bind to. Must not be called together withwithInetAddress(InetAddress)
orwithInetSocketAddress(InetSocketAddress)
orwithHttpServer(HttpServer)
. Default is empty, indicating that the HTTPServer binds to the wildcard address.
-
withInetAddress
public HTTPServer.Builder withInetAddress(InetAddress address)
Bind to this IP address. Must not be called together withwithHostname(String)
orwithInetSocketAddress(InetSocketAddress)
orwithHttpServer(HttpServer)
. Default is empty, indicating that the HTTPServer binds to the wildcard address.
-
withInetSocketAddress
public HTTPServer.Builder withInetSocketAddress(InetSocketAddress address)
Listen on this address. Must not be called together withwithPort(int)
,withHostname(String)
,withInetAddress(InetAddress)
, orwithHttpServer(HttpServer)
.
-
withHttpServer
public HTTPServer.Builder withHttpServer(com.sun.net.httpserver.HttpServer httpServer)
Use this httpServer. ThehttpServer
is expected to already be bound to an address. Must not be called together withwithPort(int)
, orwithHostname(String)
, orwithInetAddress(InetAddress)
, orwithInetSocketAddress(InetSocketAddress)
.
-
withDaemonThreads
public HTTPServer.Builder withDaemonThreads(boolean daemon)
By default, theHTTPServer
uses non-daemon threads. Set this totrue
to run theHTTPServer
with daemon threads.
-
withSampleNameFilter
public HTTPServer.Builder withSampleNameFilter(io.prometheus.client.Predicate<String> sampleNameFilter)
Optional: Only export time series wheresampleNameFilter.test(name)
returns true.Use this if the sampleNameFilter remains the same throughout the lifetime of the HTTPServer. If the sampleNameFilter changes during runtime, use
withSampleNameFilterSupplier(Supplier)
.
-
withSampleNameFilterSupplier
public HTTPServer.Builder withSampleNameFilterSupplier(io.prometheus.client.Supplier<io.prometheus.client.Predicate<String>> sampleNameFilterSupplier)
Optional: Only export time series wheresampleNameFilter.test(name)
returns true.Use this if the sampleNameFilter may change during runtime, like for example if you have a hot reload mechanism for your filter config. If the sampleNameFilter remains the same throughout the lifetime of the HTTPServer, use
withSampleNameFilter(Predicate)
instead.
-
withRegistry
public HTTPServer.Builder withRegistry(io.prometheus.client.CollectorRegistry registry)
Optional: Default isCollectorRegistry.defaultRegistry
.
-
withAuthenticator
public HTTPServer.Builder withAuthenticator(com.sun.net.httpserver.Authenticator authenticator)
Optional:Authenticator
to use to support authentication.
-
withHttpsConfigurator
public HTTPServer.Builder withHttpsConfigurator(com.sun.net.httpserver.HttpsConfigurator configurator)
Optional:HttpsConfigurator
to use to support TLS/SSL
-
build
public HTTPServer build() throws IOException
Build the HTTPServer- Throws:
IOException
-
-