-
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
[Generator] Fix metricbeat-style custom beats #13293
[Generator] Fix metricbeat-style custom beats #13293
Conversation
Another thing: There's no |
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.
Nice job here, all beats based on Metricbeat should be similar.
return nil, errors.Wrap(err, "initialization error") | ||
} | ||
return modulesManager, nil | ||
} |
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.
Maybe we should move the one in github.com/elastic/beats/metricbeat/cmd
to some reusable place.
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.
Hm, I can try that. Might not be a bad idea.
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.
Thinking about this. We'd need to separate out the ModulesManager and root code in metricbeat, since both the user beats and metricbeat share an init()
that would fight with each other.
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.
Yeah, this is what I meant with moving to some reusable place 😬 But ok, we can leave this for a future change dedicated only to this.
e148f69
to
7e5f211
Compare
Alright, taking this out of draft since I got it working, at least. |
jenkins, test this |
So, there's one ergonomics thing that's bugging me. When you make a new metricset, it starts out as disabled, as well as |
Fixing the behavior of |
Jenkins, test this |
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 good, if it works for you lets ship it so we can continue with other improvements. Thanks for taking care of this!
{{.BeatName}}.config.modules: | ||
path: ${path.config}/modules.d/*.yml | ||
reload.enabled: false | ||
|
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.
It'd be good if metricbeat would use the same files, so we remember to maintain them. Maybe a way to do it is to generate a custom beat called "metricbeat", and check that these files are the same as the ones for the real Metricbeat.
But let's forget about this by now.
mkdir -p vendor/github.com/elastic | ||
cp -R ${GOPATH}/src/github.com/elastic/beats vendor/github.com/elastic/ | ||
mkdir -p vendor/github.com/elastic/beats | ||
git archive --remote ${BEAT_GOPATH}/src/github.com/elastic/beats HEAD | tar -x --exclude=x-pack -C vendor/github.com/elastic/beats |
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.
Thanks!
return nil, errors.Wrap(err, "initialization error") | ||
} | ||
return modulesManager, nil | ||
} |
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.
Yeah, this is what I meant with moving to some reusable place 😬 But ok, we can leave this for a future change dedicated only to this.
Umm, this is weird, I think we should have the metricset with |
jenkins, test this |
1 similar comment
jenkins, test this |
This is a draft for now, as I just hacked it into functionality, and now I need to thoroughly test what I've done and clean it up. Also, the config generation stuff isn't something I have much experience with.
So, I noticed that metricbeat-style custom beats have a lot of issues. A few of the smaller ones are fixed in other PRs. This one addresses three major issues:
The current custom metricbeat setup uses a different bootstrap as nearly every other beat. This changes it to use the
cmd.RootCmd.Execute()
init as everything else.The cmd/instance library wasn't properly picking up the beat name. This meant that when you compiled your beat, it would fallback to a default name of
beat
, meaning that if you followed our instructions, the beat won't run, as it'll look for a config file namedbeat.yml
Modules weren't working properly, as there was no templates in the default config files, leading to a yml block called
metricbeat.config.modules
which obviously wouldn't work.This PR changes the beat init, adds a bunch of tempating, and changes the custom beat to use its own config files.