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

Cherry-pick #20490 to 7.x: Add replace_fields config option in add_host_metadata for replacing host fields #20617

Merged
merged 1 commit into from
Aug 17, 2020

Conversation

kaiyan-sheng
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng commented Aug 14, 2020

Cherry-pick of PR #20490 to 7.x branch. Original message:

What does this PR do?

This PR adds replace_fields config option in add_host_metadata for replacing host fields. By default, replace_fields equals to true to make sure this PR is not a breaking change.

Why is it important?

We are adding common host fields into several modules in Metricbeat, such as host.id and host.name. But add_host_metadata processor would overwrite host.id field without this PR.

Checklist

  • My code follows the style guidelines of this project
  • 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.

How to test this PR locally

This PR should work for any module/metricset. I'm using aws module as an example here:

  1. Make sure Add host inventory metrics to ec2 metricset #20171 is in the code and then enable aws module by
    ./metricbeat modules enable aws
  2. Change aws config modules.d/aws.yml to:
- module: aws
  period: 5m
  credential_profile_name: elastic-beats
  metricsets:
    - ec2
  1. Make sure in metricbeat.yml, add_host_metadata processor is enabled and replace_fields is set to false:
processors:
  - add_host_metadata:
      - replace_fields: false
  1. Start Metricbeat with ./metricbeat -e
  2. Check metrics sent to ES from Kibana discover. Metrics should have host.* fields only from ec2 metricset but not any fields from add_host_metadata such as host.hostname, host.architecture, host.os.* etc.

Related issues

#20464

…ost fields (#20490)

* add replace_host_fields config param

(cherry picked from commit 7bb31e6)
@kaiyan-sheng kaiyan-sheng added [zube]: In Review backport Team:Platforms Label for the Integrations - Platforms team labels Aug 14, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-platforms (Team:Platforms)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Aug 14, 2020
@kaiyan-sheng kaiyan-sheng self-assigned this Aug 14, 2020
@elasticmachine
Copy link
Collaborator

💔 Build Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20617 opened]

  • Start Time: 2020-08-14T18:35:33.109+0000

  • Duration: 77 min 23 sec

Test stats 🧪

Test Results
Failed 0
Passed 17810
Skipped 1853
Total 19663

Steps errors

Expand to view the steps failures

  • Name: Mage build test
    • Description: mage build test

    • Duration: 11 min 3 sec

    • Start Time: 2020-08-14T19:00:17.343+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-08-14T19:52:23.753Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats
[2020-08-14T19:52:23.803Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Lint
[2020-08-14T19:52:23.967Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Elastic-Agent-Mac-OS-X
[2020-08-14T19:52:24.133Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Winlogbeat-oss
[2020-08-14T19:52:24.298Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Auditbeat-crosscompile
[2020-08-14T19:52:24.461Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Journalbeat-oss
[2020-08-14T19:52:24.625Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Filebeat-x-pack-Mac-OS-X
[2020-08-14T19:52:24.787Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Dockerlogbeat
[2020-08-14T19:52:24.953Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Generators-Metricbeat-Linux
[2020-08-14T19:52:25.119Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Auditbeat-oss-Mac-OS-X
[2020-08-14T19:52:25.282Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Functionbeat-x-pack
[2020-08-14T19:52:25.456Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Filebeat-Mac-OS-X
[2020-08-14T19:52:25.627Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Packetbeat-Linux
[2020-08-14T19:52:25.802Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-08-14T19:52:25.985Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-Mac-OS-X
[2020-08-14T19:52:26.158Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-OSS-Unit-tests
[2020-08-14T19:52:26.321Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Heartbeat-oss
[2020-08-14T19:52:26.484Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Auditbeat-x-pack-Windows
[2020-08-14T19:52:26.653Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-crosscompile
[2020-08-14T19:52:26.827Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Auditbeat-x-pack-Mac-OS-X
[2020-08-14T19:52:26.992Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Auditbeat-oss-Windows
[2020-08-14T19:52:27.163Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Auditbeat-x-pack
[2020-08-14T19:52:27.326Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-08-14T19:52:27.496Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Functionbeat-Mac-OS-X-x-pack
[2020-08-14T19:52:27.658Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Auditbeat-oss-Linux
[2020-08-14T19:52:27.826Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-08-14T19:52:27.991Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Packetbeat-Mac-OS-X
[2020-08-14T19:52:28.155Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Winlogbeat-Windows-x-pack
[2020-08-14T19:52:28.317Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Libbeat-x-pack
[2020-08-14T19:52:28.480Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-x-pack-Mac-OS-X
[2020-08-14T19:52:28.641Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Filebeat-Windows
[2020-08-14T19:52:28.804Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-Windows
[2020-08-14T19:52:28.968Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-x-pack-Windows
[2020-08-14T19:52:29.131Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Winlogbeat-Windows
[2020-08-14T19:52:29.294Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Generators-Beat-Linux
[2020-08-14T19:52:29.456Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Heartbeat-Mac-OS-X
[2020-08-14T19:52:29.620Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Functionbeat-Windows
[2020-08-14T19:52:29.784Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Packetbeat-Windows
[2020-08-14T19:52:29.953Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Filebeat-oss
[2020-08-14T19:52:30.113Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Filebeat-x-pack
[2020-08-14T19:52:30.275Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Libbeat-oss
[2020-08-14T19:52:30.439Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests
[2020-08-14T19:52:30.602Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-OSS-Python-Integration-tests
[2020-08-14T19:52:30.761Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Generators-Metricbeat-Mac-OS-X
[2020-08-14T19:52:30.923Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Libbeat-crosscompile
[2020-08-14T19:52:31.083Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-x-pack
[2020-08-14T19:52:31.245Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Libbeat-stress-tests
[2020-08-14T19:52:31.405Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Generators-Beat-Mac-OS-X
[2020-08-14T19:52:31.568Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Heartbeat-Windows
[2020-08-14T19:52:32.090Z] + cat
[2020-08-14T19:52:32.090Z] + /usr/local/bin/runbld ./runbld-script --job-name elastic+beats+pull-request
[2020-08-14T19:52:32.090Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-08-14T19:52:38.690Z] runbld>>> runbld started
[2020-08-14T19:52:38.690Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-08-14T19:52:40.618Z] runbld>>> The following profiles matched the job 'elastic+beats+pull-request' in order of occurrence in the config (last value wins).
[2020-08-14T19:52:40.618Z] runbld>>> Matches in the system config:
[2020-08-14T19:52:40.618Z] runbld>>> - Matched ^elastic\+beats
[2020-08-14T19:52:40.618Z] runbld>>> - Matched ^elastic\+beats\+pull-request
[2020-08-14T19:52:42.010Z] runbld>>> Debug logging enabled.
[2020-08-14T19:52:42.010Z] runbld>>> Storing result
[2020-08-14T19:52:42.272Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-08-14T19:52:42.272Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200814195241-C24B620E
[2020-08-14T19:52:42.272Z] runbld>>> Adding system facts.
[2020-08-14T19:52:43.246Z] runbld>>> Adding vcs info for the latest commit:  44ffed6949915a0abaeb1d43cf84ecef0a8bf021
[2020-08-14T19:52:43.246Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-08-14T19:52:43.246Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-08-14T19:52:43.507Z] Processing JUnit reports with runbld...
[2020-08-14T19:52:43.507Z] + echo 'Processing JUnit reports with runbld...'
[2020-08-14T19:52:43.768Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-08-14T19:52:43.768Z] runbld>>> DURATION: 21ms
[2020-08-14T19:52:43.768Z] runbld>>> STDOUT: 40 bytes
[2020-08-14T19:52:43.768Z] runbld>>> STDERR: 49 bytes
[2020-08-14T19:52:43.768Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-08-14T19:52:43.768Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-20617
[2020-08-14T19:52:44.710Z] runbld>>> Storing build metadata: 
[2020-08-14T19:52:44.710Z] runbld>>> Adding test report.
[2020-08-14T19:52:44.711Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats
[2020-08-14T19:52:45.282Z] runbld>>> Found 136 test output files
[2020-08-14T19:52:47.196Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-08-14T19:52:47.196Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-08-14T19:52:47.196Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-08-14T19:52:47.196Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-08-14T19:52:47.196Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-08-14T19:52:47.196Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests/metricbeat/build/TEST-go-integration-graphite.xml
[2020-08-14T19:52:47.196Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats_PR-20617/src/github.com/elastic/beats/Metricbeat-OSS-Go-Integration-tests/metricbeat/build/TEST-go-integration-windows.xml
[2020-08-14T19:52:48.591Z] runbld>>> Test output logs contained: Errors: 0 Failures: 0 Tests: 19517 Skipped: 1575
[2020-08-14T19:52:48.591Z] runbld>>> Storing result
[2020-08-14T19:52:48.591Z] runbld>>> FAILURES: 0
[2020-08-14T19:52:48.591Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-08-14T19:52:48.854Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200814195241-C24B620E
[2020-08-14T19:52:48.854Z] runbld>>> Email notification disabled by environment variable.
[2020-08-14T19:52:48.854Z] runbld>>> Slack notification disabled by environment variable.
[2020-08-14T19:52:55.173Z] Running on worker-395930 in /var/lib/jenkins/workspace/Beats_beats_PR-20617
[2020-08-14T19:52:55.313Z] [INFO] getVaultSecret: Getting secrets
[2020-08-14T19:52:55.413Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-08-14T19:52:57.755Z] + chmod 755 generate-build-data.sh
[2020-08-14T19:52:57.755Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20617/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20617/runs/1 FAILURE 4643226
[2020-08-14T19:52:57.755Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20617/runs/1/steps/?limit=10000 -o steps-info.json
[2020-08-14T19:53:00.017Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20617/runs/1/tests/?status=FAILED -o tests-errors.json
[2020-08-14T19:53:00.719Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-20617/runs/1/log/ -o pipeline-log.txt

Copy link
Contributor

@narph narph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kaiyan-sheng kaiyan-sheng merged commit 44103e9 into elastic:7.x Aug 17, 2020
@kaiyan-sheng kaiyan-sheng deleted the backport_20490_7.x branch August 17, 2020 18:37
@zube zube bot removed the [zube]: Done label Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Platforms Label for the Integrations - Platforms team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants