-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Agent] Add templating support inside the Agent configuration. #17340
Comments
Pinging @elastic/ingest-management (Team:Ingest Management) |
@ruflin @michalpristas I think option 1 above is the easiest for the Agent to implement, we just have to implement: a store of values and a resolver for go-ucfg. This is the exact same strategy I've used in the keystore which worked fine. This will also guarantee that only values replacement is available. Also, we could implement it easily on top of our Tree package in the Agent as a visitor. The downside is if we need similar behavior on the Kibana side we would have to have a custom parser. But still, theses are just values replacement and this should not be too hard to add. |
From a package perspective I would prefer to only have 1 template language, otherwise it might become confusing for a package dev on what syntax to use where. One thing I realised reading the issue is that it is important all the fields we use are constant and global. They don't depend on a specific event or the way the Beat was started. There might be chance that some of the values like hostname might change during running the agent but it is rare. I would say we delay the detailed discussion on what template language should be used until we start the implementation. |
Correct hostname could change,
Agree on that, there is only one module that uses it. We can delay that specific package too. |
Closing this in favor of #19225 |
In the current modules today we allow users to reference variable that will be replaced when the modules are loaded into Filebeat. Like this:
In the above example, we have two placeholder values.
In issue #279 we discussed where this replacement could happen and we have decided that it make sense to allow it to be executed in the Agent with a few hard rules in place.
Possible Values
We should keep the list of exposed values short and follow ECS naming here. Here as an early list of values we could expose.
Syntax
The syntax used in the current module definition is the one from the golang template syntax. This means the YAML is read as a Golang template and parsed again as a ucfg configuration. I think we should not go that route:
Instead, I see two possible options:
1. Using the current field reference syntax.
We could use a superset of the field reference syntax in beats, this would mean that we have to implement a custom resolver from go-ucfg. This will effectively limit to only replacing values in the YAML values and nothing else.
Usage:
2. Use a handlebar-like library
Implements or use a golang's Handlebar library with only support variable replacement and no logical operator. From what I see, the majority of the template engine defines more than just values replacement.
Where this is used?
Currently, the only module I see that uses it is the MySQL module in filebeat.
Required decisions
The text was updated successfully, but these errors were encountered: