-
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
Add appender support to autodiscover #6469
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Condition *processors.Condition | ||
} | ||
|
||
func NewTokenAppender(cfg *common.Config) (autodiscover.Appender, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function NewTokenAppender should have comment or be unexported
configMaps []configMap | ||
} | ||
|
||
func NewConfigAppender(cfg *common.Config) (autodiscover.Appender, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported function NewConfigAppender should have comment or be unexported
db02db7
to
7f36b15
Compare
jenkins, test it |
I'm wondering if this construct should be moved to the module level instead, for a wider usage. As you could need this exact functionality outside autodiscover. They could add in the same way as processors, where you could define global appenders, scoped to all modules/prospectors, or module specific ones. WDYT? |
I thought of the same as well. Any specific thoughts on how it should look? |
I definitively think the features we brought to k8s so far can also be useful in a more generic way like mentioned above. I'm wondering if we could go forward with the above implementation for now, mark it as beta, learn from it and then extract it to be also reused in other parts? |
The thing is this specific appender would be cool also for some commonly static Metricbeat modules, like kubernetes, prometheus or even http, as it gives them auth inside the cluster. I could also implement that at the http helper level, and expose the settings only on these modules, but appender interface sounds like the right solution to the problem |
@exekias WDYT about moving forward. Getting it in as is and abstract it later or you think that will be tricky? |
@ruflin i have added experimental tag to all the builders/providers and appenders. |
// Merge the template with all the configs | ||
for _, cfg := range cfgs { | ||
cf := common.MapStr{} | ||
err := cfg.Unpack(&cf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is not being checked
Ok, let's get this in, we can make it general later I left just a minor comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks well done. We need to have some level of documentation for this that explains what it does, when/why to use it, and how to configure it.
libbeat/autodiscover/appender.go
Outdated
|
||
appender := r.GetAppender(config.Type) | ||
if appender == nil { | ||
return nil, fmt.Errorf("Unknown autodiscover appender %s", config.Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't capitalize error strings. https://github.com/golang/go/wiki/CodeReviewComments#error-strings
configMaps []configMap | ||
} | ||
|
||
// NewConfigAppender creates a configAppender that can append tempatized configs into built configs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/tempatized/templatized/
cf := common.MapStr{} | ||
err := cfg.Unpack(&cf) | ||
if err != nil { | ||
logp.Debug("config", "unable to unpack config due to error: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these have a higher visibility than Debug
? You would know better than me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be left as is.
var appenders autodiscover.Appenders | ||
for _, acfg := range config.Builders { | ||
if appender, err := autodiscover.Registry.BuildAppender(acfg); err != nil { | ||
logp.Debug("docker", "failed to construct autodiscover appender due to error: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, should this be at the Info or Warn levels?
94845c2
to
3df6aae
Compare
@andrewkroh i have incorporated review comments. |
Thanks. Looks like we still need documentation on Appenders. And since there is config associated with appenders we should have it in the reference config. @exekias How come |
@andrewkroh we talked about the documentation and some consensus needs to be arrived at for the structuring of autodiscover documentation as there are providers, templates, builders and appenders that needs documentation at the moment. i would reserve that for a separate PR. |
I think we could at least document the basics of what it does, when/why to use it, and how to configure it without knowing what the exact final structure will be by adding a new "Appenders" section to the autodiscover topic. If we produce the content our talented technical writers can later shape it and give it more structure. Basically I dislike adding new features without docs. Sometimes writing the docs even leads you to re-think how something you wrote should work or be configured. |
Sure thing. Let me add a documentation commit. |
f315f95
to
46a670f
Compare
jenkins, test it |
46a670f
to
65383a8
Compare
Appenders have the ability to append additional info into the configuration. There are two appenders that are part of this PR:
config
appender: This appender can append a templatized config into all of the generated configs by either templates or builders and can be used by any Beat.Sample config:
kubernetes.token
appender: There are endpoints in kubernetes that require bearer token authentication. This appender can addheaders.Authorization
to a metricset configuration. This can be used to collect metrics from Kube API server.