Added custom headers to cloudwatch logs sink#5906
Conversation
Signed-off-by: Manuel Mangas Zurita <mzurita@amazon.com>
dlvenable
left a comment
There was a problem hiding this comment.
Thank you @mzurita-amz for this contribution.
| @Max(50) | ||
| private int workers = DEFAULT_NUM_WORKERS; | ||
|
|
||
| @JsonProperty("custom_headers") |
There was a problem hiding this comment.
For STS, we use a configuration named sts_header_overrides. We should stay consistent. So perhaps header_overrides would be a better name.
| @Constraint(validatedBy = ValidCustomHeaders.CustomHeadersValidator.class) | ||
| @Target({ElementType.FIELD}) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @interface ValidCustomHeaders { |
There was a problem hiding this comment.
Java standards call for one class per file. Please move this into another file in the same directory named ValidCustomHeaders.java.
| * | ||
| * @param customHeaders The custom headers map to log | ||
| */ | ||
| private void logCustomHeadersConfiguration(Map<String, String> customHeaders) { |
There was a problem hiding this comment.
Please add a conditional to prevent running any of this code (e.g. String.join) when the INFO logger is not enabled.
Here is an example on debug logging. It would be similar for INFO.
There was a problem hiding this comment.
Addressed. I also removed the debug logging, as it was redundant.
| public static CloudWatchLogsClient createCwlClient(final AwsConfig awsConfig, | ||
| final AwsCredentialsSupplier awsCredentialsSupplier, | ||
| final Map<String, String> customHeaders) { | ||
| final AwsCredentialsProvider awsCredentialsProvider = awsConfig != null |
There was a problem hiding this comment.
Please change this logic a little.
final AwsCredentialsOptions awsCredentialsOptions = awsConfig != null
? convertToCredentialOptions(awsConfig)
: AwsCredentialsOptions.defaultOptions();
final AwsCredentialsProvider awsCredentialsProvider = awsCredentialsSupplier.getProvider(awsCredentialsOptions);
6c7e313 to
be176b5
Compare
|
@dlvenable I've addressed your comments. The changes are in commit be176b5. Please take a look! |
* Rename custom_headers to header_overrides * Move validator to separate file * Refactor logging and credentials logic Signed-off-by: Manuel Mangas Zurita <mzurita@amazon.com>
be176b5 to
e8a6c57
Compare
|
@dlvenable apologies, but I forgot to cleanup some unused imports on tests, and build failed after your approval. I think that by amending I can't access now the error. But I cleaned up the imports, and now I see it passing by running: |
Description
This change adds support for custom HTTP headers in the CloudWatch Logs sink plugin. Users can now configure custom headers that will be included in all CloudWatch Logs API requests. The implementation includes:
• New custom_headers configuration option in CloudWatchLogsSinkConfig
• Updated CloudWatchLogsClientFactory to accept and apply custom headers to the AWS SDK client
• Comprehensive validation for header names and values following HTTP standards
• Maximum limit of 10 custom headers to prevent configuration bloat
• Logging of configured headers (names only, values redacted for security)
• Full backward compatibility - existing configurations continue to work unchanged
Issues Resolved
Resolves #5905
Check List
• [x] New functionality includes testing.
• Added comprehensive unit tests for configuration validation
• Added tests for client factory header integration
• Added tests for sink initialization with custom headers
• [ ] New functionality has a documentation issue. Please link to it in this PR.
• [x] New functionality has javadoc added
• [x] Commits are signed with a real name per the DCO
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.