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

feat: flag to validate config files #15726

Closed
llamafilm opened this issue Aug 9, 2024 · 2 comments · Fixed by #15732
Closed

feat: flag to validate config files #15726

llamafilm opened this issue Aug 9, 2024 · 2 comments · Fixed by #15732
Assignees
Labels
feature request Requests for new plugin and for new features to existing plugins

Comments

@llamafilm
Copy link
Contributor

llamafilm commented Aug 9, 2024

Use Case

My telegraf instance receives new config files automatically from an external service, so I'd like to validate the config file works before running it. It should catch these errors:

  • Invalid TOML
  • Plugins which are not compiled into the binary
  • Incorrect plugin options

This could be implemented as a new command-line flag --check-config. If it passes, it returns 0, and if it fails, it returns 78 (or any other code except 1) to differentiate this from a failed --test.

The --test flag is inadequate for this purpose for 3 reasons:

  • It returns 1 if any of the inputs fail, even though the config is valid
  • It takes a long time because it has to wait for each input to timeout
  • It doesn't work in a dev environment that doesn't have network access to all the targets

Expected behavior

..

Actual behavior

..

Additional info

No response

@llamafilm llamafilm added the feature request Requests for new plugin and for new features to existing plugins label Aug 9, 2024
@srebhan
Copy link
Member

srebhan commented Aug 12, 2024

@llamafilm please check the binary in PR #15732 available once CI finished the tests. Please run telegraf with the config check subcommand and let me know if this fixes the issue!

@srebhan srebhan self-assigned this Aug 12, 2024
@srebhan srebhan added the waiting for response waiting for response from contributor label Aug 13, 2024
@llamafilm
Copy link
Contributor Author

Thanks! This works as expected, and takes care of all the issues I was thinking of. It returns 1 on failure, which is actually fine since this command would never be combined with --test.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants