Class CloudWatchLogsConfig
java.lang.Object
codes.grow.packages.cloudwatchlogs.CloudWatchLogsConfig
Immutable configuration of a
CloudWatchLogsClient (SPEC section 2.2, API.md section 5).
Build one with builder() or read it from the environment with fromEnv().
Precedence: explicit builder value > GROW_AWS_CLOUDWATCH_LOGS_<NAME> > standard AWS
/ CloudWatch variables (AWS_ENDPOINT_URL_CLOUDWATCH_LOGS, AWS_REGION,
AWS_ACCESS_KEY_ID, CLOUDWATCH_LOG_GROUP, …) > default. Credentials left unset use the
AWS SDK default chain. toString() never prints credentials.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder of the configuration. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCloudWatch Logs API version.static final intDefault per-event message limit in UTF-8 bytes (256 KiB).static final StringDefault STS role session name used withroleArn.static final intLargest message PutLogEvents accepts: 1 MiB minus the 26 bytes AWS counts per event. -
Method Summary
Modifier and TypeMethodDescriptionReturns the access key id.Returns the AWS account id used to build log group ARNs for live tail.booleanReturns whetherputLogEventscreates a missing log stream (default true).static CloudWatchLogsConfig.Builderbuilder()Starts an empty builder (every field at its default).Returns the connect timeout (default 10 s).Optional<software.amazon.awssdk.auth.credentials.AwsCredentialsProvider> Returns the explicit AWS credentials provider.static StringDefault stream name<hostname>-<pid>-<random6>(characters outside the allowed set become-).endpoint()Returns the explicit endpoint override passed to the AWS SDK.Returns the STS external id.static CloudWatchLogsConfigfromEnv()Reads the configuration from the process environment.static CloudWatchLogsConfigReads the configuration from an explicit variable map (tests).headers()Returns the extra request headers.hooks()Returns the hooks.static booleanisValidLogGroupName(String name) Returns whethernameis a valid log group name (1–512 of[.-_/#A-Za-z0-9]).static booleanisValidLogStreamName(String name) Returns whethernameis a valid log stream name (1–512 characters, no:or*).Credential values to redact from error messages and logs.logger()Returns the logger.logGroup()Returns the default log group of the log client and the query client.Returns the log stream of the log client (default<hostname>-<pid>-<random6>).intReturns the per-event message limit in UTF-8 bytes (default 262 144).Returns the policy for oversized events (defaultOversizePolicy.TRUNCATE).profile()Returns the shared config profile.proxy()Returns the explicit proxy URL.region()Returns the AWS region.Returns the per-attempt timeout (default 30 s).retry()Returns the retry policy (maxAttempts = maxRetries + 1in the SDK standard mode).roleArn()Returns the role assumed with STS.Returns the STS session name (defaultgrow-sdk).Optional<software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsAsyncClient> Returns the caller-supplied AWS SDK client.Returns the secret access key.Returns the session token.tls()Returns the TLS options.Returns a builder holding every value of this configuration.toString()Returns the total timeout per call including retries (default 120 s).Translates the common fields into transport settings (used by the Grow HTTP client of the AWS SDK).url()Effective endpoint:endpoint()when set, otherwise the public AWS endpoint ofregion()(us-east-1when the region is left to the SDK).Returns the user agent suffix.voidvalidate()Checks every rule (URL, timeouts, TLS, credential pairs, names, limits).
-
Field Details
-
DEFAULT_MAX_EVENT_BYTES
public static final int DEFAULT_MAX_EVENT_BYTESDefault per-event message limit in UTF-8 bytes (256 KiB).- See Also:
-
MAX_EVENT_BYTES_HARD_CAP
public static final int MAX_EVENT_BYTES_HARD_CAPLargest message PutLogEvents accepts: 1 MiB minus the 26 bytes AWS counts per event.- See Also:
-
DEFAULT_ROLE_SESSION_NAME
Default STS role session name used withroleArn.- See Also:
-
API_VERSION
CloudWatch Logs API version.- See Also:
-
-
Method Details
-
isValidLogGroupName
Returns whethernameis a valid log group name (1–512 of[.-_/#A-Za-z0-9]).- Parameters:
name- candidate name- Returns:
- true when valid
-
isValidLogStreamName
Returns whethernameis a valid log stream name (1–512 characters, no:or*).- Parameters:
name- candidate name- Returns:
- true when valid
-
defaultLogStreamName
Default stream name<hostname>-<pid>-<random6>(characters outside the allowed set become-).- Returns:
- a new stream name
-
builder
Starts an empty builder (every field at its default).- Returns:
- a new builder
-
fromEnv
Reads the configuration from the process environment.- Returns:
- the validated configuration
- Throws:
ConfigException- when a variable holds an invalid value (the message names the variable, never the value)
-
fromEnv
Reads the configuration from an explicit variable map (tests).- Parameters:
env- variable map- Returns:
- the validated configuration
-
toBuilder
Returns a builder holding every value of this configuration.- Returns:
- a new builder
-
validate
public void validate()Checks every rule (URL, timeouts, TLS, credential pairs, names, limits).- Throws:
ConfigException- when a rule is violated (all problems in one message)
-
toTransportConfig
Translates the common fields into transport settings (used by the Grow HTTP client of the AWS SDK).- Returns:
- the transport configuration
-
knownSecrets
Credential values to redact from error messages and logs.- Returns:
- the live secret values
-
url
Effective endpoint:endpoint()when set, otherwise the public AWS endpoint ofregion()(us-east-1when the region is left to the SDK). Informational.- Returns:
- the URL
-
endpoint
Returns the explicit endpoint override passed to the AWS SDK.- Returns:
- the endpoint, or empty when the SDK resolves it
-
connectTimeout
Returns the connect timeout (default 10 s).- Returns:
- the timeout
-
requestTimeout
Returns the per-attempt timeout (default 30 s).- Returns:
- the timeout
-
totalTimeout
Returns the total timeout per call including retries (default 120 s).- Returns:
- the timeout
-
retry
Returns the retry policy (maxAttempts = maxRetries + 1in the SDK standard mode).- Returns:
- the policy
-
tls
Returns the TLS options.- Returns:
- the options
-
proxy
Returns the explicit proxy URL.- Returns:
- the proxy, or empty
-
headers
Returns the extra request headers.- Returns:
- immutable map
-
userAgentSuffix
Returns the user agent suffix.- Returns:
- the suffix, or empty
-
hooks
Returns the hooks.- Returns:
- the hooks
-
logger
Returns the logger.- Returns:
- the logger
-
region
Returns the AWS region.- Returns:
- the region, or empty (SDK chain: environment, profile)
-
accessKeyId
Returns the access key id.- Returns:
- the key id, or empty
-
secretAccessKey
Returns the secret access key.- Returns:
- the secret, or empty
-
sessionToken
Returns the session token.- Returns:
- the token, or empty
-
profile
Returns the shared config profile.- Returns:
- the profile, or empty
-
credentialsProvider
public Optional<software.amazon.awssdk.auth.credentials.AwsCredentialsProvider> credentialsProvider()Returns the explicit AWS credentials provider.- Returns:
- the provider, or empty
-
roleArn
Returns the role assumed with STS.- Returns:
- the role ARN, or empty
-
roleSessionName
Returns the STS session name (defaultgrow-sdk).- Returns:
- the session name
-
externalId
Returns the STS external id.- Returns:
- the external id, or empty
-
logGroup
Returns the default log group of the log client and the query client.- Returns:
- the group, or empty
-
logStream
Returns the log stream of the log client (default<hostname>-<pid>-<random6>).- Returns:
- the stream name
-
accountId
Returns the AWS account id used to build log group ARNs for live tail.- Returns:
- the account id, or empty (looked up with
DescribeLogGroups)
-
maxEventBytes
public int maxEventBytes()Returns the per-event message limit in UTF-8 bytes (default 262 144).- Returns:
- the limit
-
oversizePolicy
Returns the policy for oversized events (defaultOversizePolicy.TRUNCATE).- Returns:
- the policy
-
autoCreate
public boolean autoCreate()Returns whetherputLogEventscreates a missing log stream (default true).- Returns:
- the flag
-
sdkClient
public Optional<software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsAsyncClient> sdkClient()Returns the caller-supplied AWS SDK client.- Returns:
- the client, or empty
-
toString
-