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 #23831 to 7.x: Add system.hostfs configuration option for system module #23900

Merged
merged 2 commits into from
Feb 8, 2021

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Feb 8, 2021

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

What does this PR do?

This PR adds system.hostfs configuration option for system module.
It will be used instead of the flag -system.hostfs=/hostfs where adding a flag is not possible ie in Agent. Using the -system.hostfs will still be available until we completely remove it in 8.0

Why is it important?

In some cases setting the proc filesystem using the -system.hostfs is not possible like when running with Agent, see #22915. A configuration option should be used instead.

How to test this PR manually

  1. Build Metricbeat: GOOS=linux GOARCH=amd64 go build
  2. Prepare a configuration file vim system.yml:
- module: system
  period: 10s
  metricsets:
    - process
  # Configure the mount point of the host’s filesystem for use in monitoring a host from within a container
  system.hostfs: "/hostfs"
  1. Use the following Dockerfile.debug to build a custom image locally:
FROM docker.elastic.co/beats/metricbeat:7.10.2
COPY metricbeat.yml /usr/share/metricbeat/metricbeat.yml
COPY metricbeat /usr/share/metricbeat/metricbeat
COPY system.yml /usr/share/metricbeat/modules.d/system.yml
USER root
RUN chown root:metricbeat /usr/share/metricbeat/metricbeat.yml
USER metricbeat
  1. Build the image: docker build -f Dockefile.debug . -t metricbeat-hostfs
  2. Run Metricbeat and verify that process metricset collects data:
docker run --mount type=bind,source=/proc,target=/hostfs/proc,readonly --mount type=bind,source=/sys/fs/cgroup,target=/hostfs/sys/fs/cgroup,readonly --mount type=bind,source=/,target=/hostfs,readonly --net=host metricbeat-hostfs -e -d "*" 
  1. Try to break Metricbeat by adding a random hostpath flag: -system.hostfs=/hostfs45

Related issues

cc: @blakerouse

@ChrsMark ChrsMark added [zube]: In Review backport Team:Integrations Label for the Integrations team labels Feb 8, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@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 Feb 8, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Feb 8, 2021

💚 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

Expand to view the summary

Build stats

  • Build Cause: Pull request #23900 updated

    • Start Time: 2021-02-08T08:25:29.060+0000
  • Duration: 34 min 43 sec

  • Commit: ad33c5b

Test stats 🧪

Test Results
Failed 0
Passed 8694
Skipped 2140
Total 10834

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 8694
Skipped 2140
Total 10834

Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

LGTM

@ChrsMark ChrsMark merged commit 5fbd81c into elastic:7.x Feb 8, 2021
@zube zube bot removed the [zube]: Done label May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants