Merge default values with custom API Key Elasticsearch settings #3342
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation/summary
When configuring an Elasticsearch instance for API Key usage, Elasticsearch default values should be merged with the custom configuration.
At the moment default values are not merged as soon as any of the
apm-server.api_key.elasticsearch.*
options is configured, which is unexpected behavior and not aligned with how other configuration options are merged with default values.This PR changes the behavior to use default options where no dedicated configuration option is provided. This change also allows to add the
required
flag for the Elasticsearchhost
option again, as now the host is always set by default.Checklist
- [ ] I have signed the Contributor License Agreement.make check-full
for static code checks and linting)- [ ] I have made corresponding changes to the documentationHow to test these changes
Configure some option of
apm-server.api_key.elasticsearch.*
and ensure default values are applied for missing configuration options.Default values are
hosts: []string{"localhost:9200"}, protocol: "http", timeout: 5s
.E.g. ensure to have a locally running Elasticsearch instance with security enabled and run
./apm-server apikey create -e -E apm-server.api_key.enabled=true -E apm-server.api_key.elasticsearch.username=foo -E apm-server.api_key.elasticsearch.password=bar
When providing proper username+password this should create an API Key, by using the default
host
configuration oflocalhost:9200
.Related issues
fixes #3341