Package codes.grow.packages.loki
Class LokiConfig.Builder
java.lang.Object
codes.grow.packages.loki.LokiConfig.Builder
- Enclosing class:
LokiConfig
Builder of the configuration.
Unset fields take the environment (when fromEnv(EnvReader) is called) or the
default.
-
Method Summary
Modifier and TypeMethodDescriptionallowedLabels(List<String> names) Sets the cardinality guard allowlist (label names that may become index labels; everything else goes to structured metadata).bearerToken(Secret token) Sets the Bearer token sent to a gateway (Authorization: Bearer …).bearerToken(String token) Sets the Bearer token.build()Builds and validates the configuration.Sets the connect timeout (default 10 s).disableLabelGuard(boolean disable) Sends every label ofLokiClient.push(java.util.List<codes.grow.packages.loki.LokiStream>)streams as an index label (the guard is still applied by the log exporter).Fills every field that was not set explicitly from the environment.Adds a header sent with every request (and the tail handshake).Sets request hooks.Sets the logger (default silent).multiTenantQueries(boolean allow) Allows tenant ids joined with|(Loki's multi-tenant query syntax; the server must enablemulti_tenant_queries_enabled).Sets the Basic-auth password (or Grafana Cloud access token).Sets the Basic-auth password.Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.Sets the per-attempt timeout (default 30 s).retry(RetryPolicy retry) Sets the retry policy (defaultRetryPolicy.defaults()).Sets the tenant sent asX-Scope-OrgIDon every request and tail handshake.tls(TlsOptions tls) Sets the TLS options; environment TLS variables are then ignored.Sets the total timeout per call including retries (default 120 s).Sets the endpoint base URL (defaulthttp://127.0.0.1:3100).userAgentSuffix(String suffix) Sets the text appended to theUser-Agent.Sets the Basic-auth user (gateways, Grafana Cloud instance id).
-
Method Details
-
fromEnv
Fills every field that was not set explicitly from the environment.- Parameters:
env- environment reader- Returns:
- this builder
- Throws:
ConfigException- when a variable holds an invalid value
-
url
Sets the endpoint base URL (defaulthttp://127.0.0.1:3100).- Parameters:
url-httporhttpsURL; a base path (reverse proxy) is kept- Returns:
- this builder
-
tenantId
Sets the tenant sent asX-Scope-OrgIDon every request and tail handshake.- Parameters:
tenantId- tenant id (nullor empty sends no header)- Returns:
- this builder
-
username
Sets the Basic-auth user (gateways, Grafana Cloud instance id).- Parameters:
username- user- Returns:
- this builder
-
password
Sets the Basic-auth password (or Grafana Cloud access token).- Parameters:
password- password- Returns:
- this builder
-
password
Sets the Basic-auth password.- Parameters:
password- password- Returns:
- this builder
-
bearerToken
Sets the Bearer token sent to a gateway (Authorization: Bearer …).- Parameters:
token- token- Returns:
- this builder
-
bearerToken
Sets the Bearer token.- Parameters:
token- token- Returns:
- this builder
-
multiTenantQueries
Allows tenant ids joined with|(Loki's multi-tenant query syntax; the server must enablemulti_tenant_queries_enabled).- Parameters:
allow- whether to allow them (default false)- Returns:
- this builder
-
allowedLabels
Sets the cardinality guard allowlist (label names that may become index labels; everything else goes to structured metadata).- Parameters:
names- label names, ornullforLabels.DEFAULT_ALLOWED_LABELS- Returns:
- this builder
-
disableLabelGuard
Sends every label ofLokiClient.push(java.util.List<codes.grow.packages.loki.LokiStream>)streams as an index label (the guard is still applied by the log exporter).- Parameters:
disable- whether to disable the guard forpush(default false)- Returns:
- this builder
-
connectTimeout
Sets the connect timeout (default 10 s).- Parameters:
d- positive duration- Returns:
- this builder
-
requestTimeout
Sets the per-attempt timeout (default 30 s).- Parameters:
d- positive duration- Returns:
- this builder
-
totalTimeout
Sets the total timeout per call including retries (default 120 s).- Parameters:
d- positive duration- Returns:
- this builder
-
retry
Sets the retry policy (defaultRetryPolicy.defaults()).- Parameters:
retry- policy- Returns:
- this builder
-
tls
Sets the TLS options; environment TLS variables are then ignored.- Parameters:
tls- options- Returns:
- this builder
-
proxy
Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.- Parameters:
proxy- proxy URL- Returns:
- this builder
-
header
Adds a header sent with every request (and the tail handshake).- Parameters:
name- header namevalue- header value- Returns:
- this builder
-
userAgentSuffix
Sets the text appended to theUser-Agent.- Parameters:
suffix- suffix- Returns:
- this builder
-
hooks
Sets request hooks.- Parameters:
hooks- hooks- Returns:
- this builder
-
logger
Sets the logger (default silent).- Parameters:
logger- logger- Returns:
- this builder
-
build
Builds and validates the configuration.- Returns:
- the configuration
- Throws:
ConfigException- when a rule is violated
-