Builder

Builds an EmbeddedAgentConfig. Each method returns the builder, so calls chain in Java and read as statements in Kotlin's embeddedAgent block; a method called twice keeps its last value, and path and scrapeSelf add a path each time. Anything the builder has no method for, setting sets by its key. A value the builder can tell is wrong, such as a port out of range, throws ConfigLoadException, as start does for one the agent rejects.

In Kotlin, a setting that takes one value is a property too, so name = "my-app" does what name("my-app") does; Java sees only the methods.

Properties

Link copied to clipboard

The port of the agent's own metrics endpoint, which is off unless one is given (agent.metrics.enabled and agent.metrics.port); null turns it off again.

Link copied to clipboard

Whether the agent registers its paths in consolidated mode, alongside other agents (agent.consolidated).

Link copied to clipboard
var name: String?

The agent's name, as the proxy's dashboard and logs show it (agent.name).

Link copied to clipboard

The proxy the agent connects to, as host or host:port (the port defaults to 50051), or several, separated by commas, in the order the agent fails over through them, as PROXY_HOSTNAME takes them (agent.proxy.endpoints).

Link copied to clipboard

The token the agent presents to the proxy, which has to match the proxy's (agent.agentToken).

Functions

Link copied to clipboard

Turns on the agent's own metrics endpoint, on port; sets agentMetricsPort.

Link copied to clipboard

The settings, ready to start.

Link copied to clipboard

The agent's own certificate chain and private key, as PEM text or its base64, for a proxy that requires mutual TLS (agent.tls.certChainPem and agent.tls.privateKeyPem).

Link copied to clipboard

Sets consolidated; with no argument, turns it on.

Link copied to clipboard
Link copied to clipboard
fun path(path: String, url: String, username: String? = null, password: String? = null, labels: Map<String, String> = emptyMap()): EmbeddedAgentConfig.Builder

Has the agent scrape the target at url, served to Prometheus at the proxy's path. A username and password are sent as Basic Auth; they're percent-encoded into the URL, which then mustn't carry credentials of its own. Both empty means none.

Link copied to clipboard
fun proxy(vararg endpoints: String): EmbeddedAgentConfig.Builder

Sets proxy to one endpoint or several, in the order the agent fails over through them.

Link copied to clipboard
fun scrapeSelf(path: String, port: Int, username: String? = null, password: String? = null, metricsPath: String = "metrics", labels: Map<String, String> = emptyMap()): EmbeddedAgentConfig.Builder

Has the agent scrape the app it's embedded in: its metrics at http://127.0.0.1:<port>/<metricsPath>, served to Prometheus at the proxy's path. A username and password are sent as Basic Auth; they're percent-encoded into the URL, which the agent leaves out of its logs. Both empty means none.

Link copied to clipboard

Sets any other agent setting by its key, relative to agent, such as scrapeTimeoutSecs or http.clientTimeoutSecs (see the agent's configuration reference). It takes precedence over a builder method that sets the same key. Keys aren't checked, so a misspelled one has no effect: prefer a builder method where there is one.

Link copied to clipboard
Link copied to clipboard

The certificate the agent trusts the proxy's certificate by, as PEM text or its base64 (agent.tls.trustCertCollectionPem), which turns TLS on. authority is the name the proxy's certificate was issued to, when it isn't the host the agent connects to (agent.tls.overrideAuthority).