[Metricbeat] Stop continual error with multiple Logstash pipelines #31985
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.
What does this PR do?
This PR closes #31739.
This PR stops multiple errors being logged when using Logstash with multiple pipelines.
Why is it important?
The Logs are noisy.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Follow the docs to setup your environment to build Beats (here: https://www.elastic.co/guide/en/beats/devguide/current/beats-contributing.html#setting-up-dev-environment)
Checkout this branch, and then
cd metricbeat
, and thenmage build
.Make a Metricbeat config file that contains the following (change the credentials):
Then run
./metricbeat -e -c PATH_TO_YOUR_METRICBEAT_YML_FILE
Run Logstash with multiple pipelines.
You should not see excessive logging, e.g.:
Related issues
Closes #31739.
Logs
Excessive logging before:
Fields / mapping inconsistency
It is noted in the issue that:
and this seemed like a very reasonable assumption. As such I originally moved
below
because it's
commonFieldsMapping
that callsfields.Delete()
. This means things likehost
andversion
wouldn't end up onlogstash.node
. This also aligned with the documentation. We can see there thatlogstash.node.host
and co are supposed to be an alias. However, that's not the way the mappings seem to work. These are not aliased. So havingevent.MetricSetFields.Update(fields)
copy everything (the full set of fields) seems necessary. It doesn't align with the docs, but it aligns with the mappings (and most likely how solutions are accessing these fields). There definitely seems to be confusion here in expectation, unless I'm misunderstanding.I have also added a Gist here with results produced by all three. Before changes, after changes with field deletion, and after changes with no field deletion. We can see that in terms of indexed data before and after changes with no field deletion match.
As such, this PR just fixes the logging problem by making a new
fields
map each time, which aligns with this loop example.I am not sure how we want to approach the fields and mappings. It seems that we should update the mappings to accurately reflect the docs regarding aliases, and
id
,host
,version
should no longer exist onlogstash.node
.