Package codes.grow.packages.betterstack
Class BetterStackConfig.Builder
java.lang.Object
codes.grow.packages.betterstack.BetterStackConfig.Builder
- Enclosing class:
BetterStackConfig
Builder of the configuration.
Unset fields take the environment (when fromEnv(EnvReader) is called) or the
default.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds and validates the configuration.Sets the connect timeout (default 10 s).encoding(IngestEncoding encoding) Sets the ingest body encoding (defaultIngestEncoding.JSON).Fills every field that was not set explicitly from the environment:GROW_BETTER_STACK_LOGS_<NAME>first, then the vendor variables (BETTERSTACK_INGESTING_URL,BETTERSTACK_INGESTING_HOST,BETTERSTACK_SOURCE_TOKEN,BETTERSTACK_QUERY_URL,BETTERSTACK_QUERY_HOST,BETTERSTACK_QUERY_USERNAME,BETTERSTACK_QUERY_PASSWORD,BETTERSTACK_SOURCE_TABLE).Adds a header sent with every request to both hosts.Sets request hooks.Sets the logger (default silent).Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.queryPassword(Secret password) Sets the SQL connection password (HTTP Basic, query host only).queryPassword(String password) Sets the SQL connection password.Sets the SQL query base URL (ClickHouse HTTP interface).queryUsername(String username) Sets the SQL connection username.Sets the per-attempt timeout (default 30 s).retry(RetryPolicy retry) Sets the retry policy (defaultRetryPolicy.defaults()).sourceTable(String sourceTable) Sets the default collection (t1234_myapp).sourceToken(Secret token) Sets the source token (sent asAuthorization: Bearerto the ingesting host only).sourceToken(String token) Sets the source token.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 ingest base URL: the source's ingesting host (s1234.eu-nbg-2.betterstackdata.combecomeshttps://…).userAgentSuffix(String suffix) Sets the text appended to theUser-Agent.
-
Method Details
-
fromEnv
Fills every field that was not set explicitly from the environment:GROW_BETTER_STACK_LOGS_<NAME>first, then the vendor variables (BETTERSTACK_INGESTING_URL,BETTERSTACK_INGESTING_HOST,BETTERSTACK_SOURCE_TOKEN,BETTERSTACK_QUERY_URL,BETTERSTACK_QUERY_HOST,BETTERSTACK_QUERY_USERNAME,BETTERSTACK_QUERY_PASSWORD,BETTERSTACK_SOURCE_TABLE).- Parameters:
env- environment reader- Returns:
- this builder
- Throws:
ConfigException- when a variable holds an invalid value
-
url
Sets the ingest base URL: the source's ingesting host (s1234.eu-nbg-2.betterstackdata.combecomeshttps://…).- Parameters:
url- host orhttp(s)URL- Returns:
- this builder
-
sourceToken
Sets the source token (sent asAuthorization: Bearerto the ingesting host only).- Parameters:
token- token- Returns:
- this builder
-
sourceToken
Sets the source token.- Parameters:
token- token- Returns:
- this builder
-
queryUrl
Sets the SQL query base URL (ClickHouse HTTP interface).- Parameters:
queryUrl- host orhttp(s)URL- Returns:
- this builder
-
queryUsername
Sets the SQL connection username.- Parameters:
username- username- Returns:
- this builder
-
queryPassword
Sets the SQL connection password (HTTP Basic, query host only).- Parameters:
password- password- Returns:
- this builder
-
queryPassword
Sets the SQL connection password.- Parameters:
password- password- Returns:
- this builder
-
sourceTable
Sets the default collection (t1234_myapp).- Parameters:
sourceTable- identifier- Returns:
- this builder
-
encoding
Sets the ingest body encoding (defaultIngestEncoding.JSON).- Parameters:
encoding- encoding- 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 to both hosts.- 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
-