Package codes.grow.packages.loki
Class LokiClient.Builder
java.lang.Object
codes.grow.packages.loki.LokiClient.Builder
- Enclosing class:
LokiClient
Builder that configures and creates a client in one chain.
-
Method Summary
Modifier and TypeMethodDescriptionallowedLabels(List<String> names) Sets the cardinality guard allowlist.Sets Basic-auth credentials.Sets Basic-auth credentials (gateways, Grafana Cloud).bearerToken(Secret token) Sets the Bearer token for gateways.bearerToken(String token) Sets the Bearer token for gateways.build()Builds the configuration and the client.Sets the connect timeout.disableLabelGuard(boolean disable) Disables the cardinality guard forLokiClient.push(java.util.List<codes.grow.packages.loki.LokiStream>).Fills unset fields from an environment reader.Adds a header.Sets hooks.Sets the logger.multiTenantQueries(boolean allow) Allows tenant ids joined with|(multi-tenant queries).Sets the proxy URL.Sets the per-attempt timeout.retry(RetryPolicy retry) Sets the retry policy.Sets the tenant (X-Scope-OrgID).tls(TlsOptions tls) Sets the TLS options.Sets the total timeout.Sets the endpoint base URL.userAgentSuffix(String suffix) Sets the user agent suffix.
-
Method Details
-
fromEnv
Fills unset fields from an environment reader.- Parameters:
env- reader, e.g.EnvReader.system()- Returns:
- this builder
-
url
Sets the endpoint base URL.- Parameters:
url- URL- Returns:
- this builder
-
tenantId
Sets the tenant (X-Scope-OrgID).- Parameters:
tenantId- tenant id- Returns:
- this builder
-
basicAuth
Sets Basic-auth credentials (gateways, Grafana Cloud).- Parameters:
username- userpassword- password or access token- Returns:
- this builder
-
basicAuth
Sets Basic-auth credentials.- Parameters:
username- userpassword- password or access token- Returns:
- this builder
-
bearerToken
Sets the Bearer token for gateways.- Parameters:
token- token- Returns:
- this builder
-
bearerToken
Sets the Bearer token for gateways.- Parameters:
token- token- Returns:
- this builder
-
multiTenantQueries
Allows tenant ids joined with|(multi-tenant queries).- Parameters:
allow- whether to allow them- Returns:
- this builder
-
allowedLabels
Sets the cardinality guard allowlist.- Parameters:
names- label names- Returns:
- this builder
-
disableLabelGuard
Disables the cardinality guard forLokiClient.push(java.util.List<codes.grow.packages.loki.LokiStream>).- Parameters:
disable- whether to disable it- Returns:
- this builder
-
connectTimeout
Sets the connect timeout.- Parameters:
d- duration- Returns:
- this builder
-
requestTimeout
Sets the per-attempt timeout.- Parameters:
d- duration- Returns:
- this builder
-
totalTimeout
Sets the total timeout.- Parameters:
d- duration- Returns:
- this builder
-
retry
Sets the retry policy.- Parameters:
retry- policy- Returns:
- this builder
-
tls
Sets the TLS options.- Parameters:
tls- options- Returns:
- this builder
-
proxy
Sets the proxy URL.- Parameters:
proxy- URL- Returns:
- this builder
-
header
Adds a header.- Parameters:
name- namevalue- value- Returns:
- this builder
-
userAgentSuffix
Sets the user agent suffix.- Parameters:
suffix- suffix- Returns:
- this builder
-
hooks
Sets hooks.- Parameters:
hooks- hooks- Returns:
- this builder
-
logger
Sets the logger.- Parameters:
logger- logger- Returns:
- this builder
-
build
Builds the configuration and the client.- Returns:
- a new client
- Throws:
ConfigException- when the configuration is invalid
-