Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metricbeat] Stop continual error with multiple Logstash pipelines #31985

Conversation

Kerry350
Copy link
Contributor

@Kerry350 Kerry350 commented Jun 17, 2022

What does this PR do?

This PR closes #31739.

This PR stops multiple errors being logged when using Logstash with multiple pipelines.

⚠️ Please see the fields / mapping inconsistency section I've added in this description, because whilst this PR fixes the logging issue, there are some questions. ⚠️

Why is it important?

The Logs are noisy.

Checklist

  • My code follows the style guidelines of this project (I think so, couldn't find a STYLEGUIDE file)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

How to test this PR locally

http.enabled: true
metricbeat.modules:
  - module: system

  - module: logstash
    xpack.enabled: true
    period: 10s
    hosts: [ "localhost:9600" ]

output.elasticsearch:
  hosts: [ "localhost:9200" ]
  username: "elastic"
  password: "changeme"
docker run --name logstash \
  --pull always --rm \
  --hostname=logstash \
  --publish=9600:9600 \
  --volume="$(pwd)/x-pack/plugins/monitoring/dev_docs/reference/logstash.yml:/usr/share/logstash/config/logstash.yml:ro" \
  --volume="$(pwd)/x-pack/plugins/monitoring/dev_docs/reference/pipelines.yml:/usr/share/logstash/config/pipelines.yml:ro" \
  docker.elastic.co/logstash/logstash:master-SNAPSHOT

You should not see excessive logging, e.g.:

Screenshot 2022-06-17 at 17 19 20

Related issues

Closes #31739.

Logs

Excessive logging before:

Screenshot 2022-06-17 at 17 19 20

Fields / mapping inconsistency

It is noted in the issue that:

The deletions seem to have been added in #10350 presumably to avoid leaving fields in the document that don't comply with ECS

and this seemed like a very reasonable assumption. As such I originally moved

event.MetricSetFields.Update(fields)

below

if err = commonFieldsMapping(&event, fields); err != nil {
  return err
}

because it's commonFieldsMapping that calls fields.Delete(). This means things like host and version wouldn't end up on logstash.node. This also aligned with the documentation. We can see there that logstash.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 having event.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 on logstash.node.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 17, 2022
@Kerry350 Kerry350 added Feature:Stack Monitoring Team:Infra Monitoring UI - DEPRECATED Infrastructure Monitoring UI team - DEPRECATED - Use Team:Monitoring v8.4.0 labels Jun 17, 2022
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 17, 2022
@Kerry350 Kerry350 marked this pull request as ready for review June 17, 2022 18:05
@Kerry350 Kerry350 requested a review from a team as a code owner June 17, 2022 18:05
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-06-17T17:57:53.237+0000

  • Duration: 62 min 46 sec

Test stats 🧪

Test Results
Failed 0
Passed 3541
Skipped 887
Total 4428

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@klacabane
Copy link
Contributor

It seems that we should update the mappings to accurately reflect the docs regarding aliases, and id, host, version should no longer exist on logstash.node.

Agreed. looks like the aliases were lost in translation when creating the logstash integrations (which the .monitoring-{product}-mb mappings are based on) because they were defined in the 7.x version

@Kerry350
Copy link
Contributor Author

Agreed. looks like the aliases were lost in translation when creating the logstash integrations (which the .monitoring-{product}-mb mappings are based on) because they were defined in the 7.x version

Gotcha, makes sense 👍

I'll merge this since it's part of the GA work. And file an issue for the mappings / aliases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Stack Monitoring Team:Infra Monitoring UI - DEPRECATED Infrastructure Monitoring UI team - DEPRECATED - Use Team:Monitoring v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Stack Monitoring] Logstash module logs continual error when monitoring multiple pipelines
3 participants