elastic / elastic/elastic-agent
[Elastic Agent][Standalone] Add configuration validation command
- Dominant language
- Go
- Stars
- 275
- Forks
- 264
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 298
Description
**Describe the enhancement:**
Currently, there is no good way of validating a configuration for a standalone Elastic Agent.
The only way to do this currently, is to load up an agent with a configuration and wait to see if it (or its subprocesses (beats)) run into any issues.
(Running the help command against the Elastic Agent binary shows no "configuration"/"validation" command)
```bash
elastic-agent help
Usage:
elastic-agent [subcommand] [flags]
elastic-agent [command]
Available Commands:
diagnostics Gather diagnostics information from the elastic-agent and running processes.
enroll Enroll the Agent into Fleet
help Help about any command
inspect Shows configuration of the agent
install Install Elastic Agent permanently on this system
restart Restart the currently running Elastic Agent daemon
run Start the elastic-agent.
status Status returns the current status of the running Elastic Agent daemon.
uninstall Uninstall permanent Elastic Agent from this system
upgrade Upgrade the currently running Elastic Agent to the specified version
version Display the version of the elastic-agent.
watch Watch watches Elastic Agent for failures and initiates rollback.
Flags:
-c, --c string Configuration file, relative to path.config (default "elastic-agent.yml")
-d, --d string Enable certain debug selectors
-e, --e Log to stderr and disable syslog/file output
--environment environmentVar set environment being ran in (default default)
-h, --help help for elastic-agent
--path.config string Config path is the directory Agent looks for its config file (default "/usr/share/elastic-agent")
--path.downloads string Downloads path contains binaries Agent downloads
--path.home string Agent root path (default "/usr/share/elastic-agent")
--path.install string Install path contains binaries Agent extracts
--path.logs string Logs path contains Agent log output (default "/usr/share/elastic-agent")
-v, --v Log at INFO level
Use "elastic-agent [command] --help" for more information about a command.
```
**Describe a specific use case for the enhancement or feature:**
## Generalized Use Case 1
If I write a standalone configuration, I would like to know that the configuration I have written is valid, without having to actually run an Elastic Agent process.
## Generalized Use Case 2
If I am upgrading a standalone Elastic Agent, I would like to be able to test my configuration against the newer version before I perform the upgrade to ensure there are no breaking changes (or even warnings/deprecations).
## Specific Use Case
I am trying to write some automation around CI/CD for users to build abstracted Elastic Agent configurations then have Terraform take these abstracted configurations and turn them into real Elastic Agent standalone configurations and deploy them.
The issue I'm running into, is that there isn't a good way to actually validate that a configuration generated is valid in a test phase.
I would like to simply just have a step which runs a command like:
```bash
elastic-agent validate --path.config
```
And use the response code to determine the needed action:
Exit 0 - success
Exit 1 - error
Exit ? - Warning/deprecated
Contributor guide
Assessment
This issue has not been assessed yet.