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

Load inputs from external configuration files in Elastic Agent in standalone mode #30087

Merged
merged 5 commits into from
Feb 1, 2022

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Jan 28, 2022

What does this PR do?

This PR adds support for loading external configuration files to load inputs when running Agent in standalone mode.
Users have to put their configuration files into {path.config}/inputs.d with the extension yml.

When it is configured, Agent takes the inputs configuration from the last standalone configuration and appends the inputs from the external configuration files to it. When the standalone configurations are reloaded, external input configurations are reloaded as well.

The external configuration file must include inputs, otherwise the file is invalid. Example for correct file:

inputs:
- data_stream:
    dataset: system.auth
    type: logs
  id: logfile-system.auth-my-id
  paths:
  - /var/log/auth.log*
  use_output: default

Why is it important?

Users can configure external configuration files, similar to Filebeat. So managing configuration can be done by Git or Chef instead of Fleet.

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.

@kvch kvch requested review from blakerouse and faec January 28, 2022 11:42
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jan 28, 2022
@kvch kvch added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jan 28, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jan 28, 2022
@kvch kvch added needs_team Indicates that the issue/PR needs a Team:* label Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Jan 28, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jan 28, 2022
@botelastic
Copy link

botelastic bot commented Jan 28, 2022

This pull request doesn't have a Team:<team> label.

@mergify
Copy link
Contributor

mergify bot commented Jan 28, 2022

This pull request does not have a backport label. Could you fix it @kvch? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Jan 28, 2022
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jan 28, 2022

💚 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

  • Reason: null

  • Start Time: 2022-02-01T12:26:40.666+0000

  • Duration: 106 min 1 sec

  • Commit: e2fef84

Test stats 🧪

Test Results
Failed 0
Passed 7248
Skipped 16
Total 7264

💚 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!)

@ph ph self-requested a review January 28, 2022 14:45
@kvch
Copy link
Contributor Author

kvch commented Jan 28, 2022

@ph are the errors in the E2E tests related to my change?

@ph
Copy link
Contributor

ph commented Jan 28, 2022

@kvch I do not think they are

[2022-01-28T13:55:52.855Z] WARN[2022-01-28T13:55:52Z] The Elastic artifacts API is not available yet  artifact=elastic-agent artifactName=elastic-agent-8.1.0-SNAPSHOT-linux-x86_64.tar.gz elapsedTime=52.96205476s error="GET request failed with 404" retry=15 statusEndpoint="https://artifacts-api.elastic.co/v1/search/8.1.0-dbc834fd/elastic-agent?x-elastic-no-kpi=true" version=8.1.0-dbc834fd

I see the unified build failed on master. https://internal-ci.elastic.co/job/elastic+unified-release+master+distributed-snapshot-multijob-master/1059/

@ph
Copy link
Contributor

ph commented Jan 28, 2022

/test

@ruflin
Copy link
Contributor

ruflin commented Jan 31, 2022

Lets make sure we test this also as part of the e2e test framework to have some integration tests for it.

@kvch In the Beats days, I remember there were always discussions around using inputs (in this case) in the inputs.d/*.yml files vs not. No strong preference on either but it would be nice if users use the wrong config, a clear message shows how it should be or link to the docs.

@kvch
Copy link
Contributor Author

kvch commented Jan 31, 2022

Lets make sure we test this also as part of the e2e test framework to have some integration tests for it.

👍

@kvch In the Beats days, I remember there were always discussions around using inputs (in this case) in the inputs.d/*.yml files vs not. No strong preference on either but it would be nice if users use the wrong config, a clear message shows how it should be or link to the docs.

I have somewhat strong preference because otherwise the file cannot be parsed. I can probably workaround the problem but I rather keep it this way. If the users miss the inputs line, Agent will report the error.

@ruflin
Copy link
Contributor

ruflin commented Feb 1, 2022

I have somewhat strong preference because otherwise the file cannot be parsed. I can probably workaround the problem but I rather keep it this way. If the users miss the inputs line, Agent will report the error.

My strong preference is to make sure only 1 way works :-) Lets make sure the error that is shown to the user is very descriptive.

@mergify
Copy link
Contributor

mergify bot commented Feb 1, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b feature-agent-load-input-config-from-dir upstream/feature-agent-load-input-config-from-dir
git merge upstream/master
git push upstream feature-agent-load-input-config-from-dir

@cmacknz
Copy link
Member

cmacknz commented Feb 1, 2022

Looks good to me, but I'll wait to see if someone with more knowledge of the agent configuration files can review this before approving.

@kvch
Copy link
Contributor Author

kvch commented Feb 1, 2022

e2e tests require elastic/e2e-testing#2064

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Overall the code looks good.

I do want to confirm the behavior that I am reading in the code. It seems this is only used when in standalone mode (which I am glad to see). But in the description of the PR it describes that it allows usage of infrastructure as code instead of Fleet. How does this help solve that, when a single elastic-agent.yml also did the same thing. The single elastic-agent.yml could be committed in Git as well. Just trying to understand the reason for adding this.

@kvch
Copy link
Contributor Author

kvch commented Feb 1, 2022

But in the description of the PR it describes that it allows usage of infrastructure as code instead of Fleet. How does this help solve that, when a single elastic-agent.yml also did the same thing. The single elastic-agent.yml could be committed in Git as well. Just trying to understand the reason for adding this.

When a separate, dedicated team manages Elastic Agent, they might want to limit the access to a single elastic-agent.yml file. If we provide a folder from where Elastic Agent can load input configurations, the Agent manager team can allow other teams in their org to put their own input configuration there without giving access to the whole infrastructure.

@kvch kvch merged commit 3c2072d into elastic:master Feb 1, 2022
@kvch
Copy link
Contributor Author

kvch commented Feb 1, 2022

Ooops, I merged it without a changelog entry. I will open a follow-up PR.

@kvch
Copy link
Contributor Author

kvch commented Feb 1, 2022

Changelog: #30144

kvch added a commit that referenced this pull request Feb 1, 2022
Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

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

LGTM, after merge.

@kvch
Copy link
Contributor Author

kvch commented Feb 2, 2022

Documentation: elastic/observability-docs#1515

@kvch kvch removed the needs_docs label Feb 2, 2022
ruflin added a commit to ruflin/elastic-agent that referenced this pull request Apr 28, 2023
The inputs.d feature was added in elastic/beats#30087 for elastic agent but unfortunately without any documentation. inputs.d directory is especially useful in the elastic-agent standalone mode. The close the first gap around documentation, I added it to the elastic-agent.yml file.

For awareness, this is an open issue around inputs.d directory: elastic#622
ruflin added a commit to elastic/elastic-agent that referenced this pull request May 3, 2023
The inputs.d feature was added in elastic/beats#30087 for elastic agent but unfortunately without any documentation. inputs.d directory is especially useful in the elastic-agent standalone mode. The close the first gap around documentation, I added it to the elastic-agent.yml file.

For awareness, this is an open issue around inputs.d directory: #622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify needs tests Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants