-
Notifications
You must be signed in to change notification settings - Fork 178
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
overide default logging with filebeat version 7 #223
Conversation
Thanks for the work on this. I've made a few comments, plus we should add some documentation around what's happening. We need to be careful about changing existing installs too much so we don't break backwards compatibility too. While the default behavior might not be intuitive, I'm hesitant to change how the service runs on a minor version upgrade. I'm open to suggestions, but maybe this change should be opt-in? |
Agreed. this totally needs to be opt in. just not sure how to approach this. Also I think the code supplied might fail on an older system or a system that does not have systemd installed. because it will try to install a file into the service drop in location.. if the base directories are not installed it will fail..... sooooooo this also need to test for systemd is part of the system |
create a bolean param $systemd_log_opt_override = false I am terrible at naming things. if $systemd_log_opt_override and version 7+ how does this sound? |
Thinking about this a bit more, we need to cover a few more things. Before doing anything we need to check that systemd is in use (is the The camptocamp/systemd module does a nice job of dropping the files in place and reloading systemd, but I'm not sure it makes sense to force everyone to use the same systemd module either (is that something people feel strongly about?). What if we create a single new string parameter named |
fyi,as of puppet 6.1 with the proposed var String $systemd_beat_log_opts = '-e' the reason I say this is,
I also personally think we should not touch the original systemd service file as this gets replaced on each upgrade (which I just noticed upgrading systems to 7.3) this means we might need to make a params logic that if in the future they change the default, we supply that default I think this logic would be better with the optional camptocamp/systemd module is available. we will also not need to check for systemd systems as the module handles this. # nothing happens if the module is not included
if defined('systemd') {
systemd::dropin_file { 'logging.conf':
unit => 'filebeat.service',
source => template logic here,
}
we would need to add documentation to the $logging and the $systemd_beat_log_opts that the |
I didn't know about the systemd change, but that certainly makes things easier. Fewer dependencies is always a little better too, especially on something like systemd. A note in the docs that you'll need Puppet 6.1 or higher if you're using that parameter is probably enough. I'd rather not manage an override file at all if we're not overriding anything, which is why I'm thinking a default undef value might be easier than having to actively keep up with default value. Maybe a better parameter name is |
the more and more I think about it.. I agree with your last message. here is what I will change with PR.
this will actually simplify future version. |
Changed the pr. I also updated the README for the class information and added to the let me know if you want me to change it and put the override in the service class instead class{'filebeat::service':
systemd_beat_log_opts => ""
} |
manifests/service.pp
Outdated
|
||
$major_version = $filebeat::major_version | ||
|
||
if versioncmp($major_version, '7') >= 0 { |
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.
I'm not sure we should always drop a file in place when Filebeat 7+ is installing without a way to ensure absent. We need to consider someone managing this file outside of this module, or wanting it excluded entirely.
manifests/service.pp
Outdated
|
||
$logging = $filebeat::logging | ||
|
||
ensure_resource('file', |
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.
The ensure_resource approach to avoid duplicate declaration works, but requires a specific execution order that otherwise won't exist.
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.
I think it makes sense to use ensure resources for the directory just in case someone is managing the directory elsewhere.
manifests/service.pp
Outdated
|
||
#make sure puppet client version 6.1+ with filebeat version 7+, running on systemd | ||
if ( versioncmp( $major_version, '7' ) >= 0 and | ||
versioncmp( $::clientversion, '6.1' ) >= 0 and |
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.
We probably should let people override even if they're running a version of Puppet older than 6.1 (maybe print a warning?)
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.
so if puppet is less then 6.1 check to see if systemd class not defined and warn that they will need systemd class and follow the documation ?
manifests/service.pp
Outdated
} | ||
) | ||
|
||
ensure_resource('file', |
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.
We should probably use a regular file resource here instead of using the ensure_resource
function. If someone is managing an override file outside of this module and they also create a file named logging.conf then we should probably throw an 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.
ok that makes sense. I was more worried that some one else would have managed the file resource.. if they had this would not have thrown an error.. just ignored it..
but yes the user should be made aware that this module uses that resource. 👍
manifests/init.pp
Outdated
@@ -97,6 +97,10 @@ | |||
Integer $queue_size = 4096, | |||
String $registry_file = 'filebeat.yml', | |||
|
|||
Optional[String] $systemd_beat_log_opts_override = undef, | |||
String $systemd_beat_log_opts_template = $filebeat::params::systemd_beat_log_opts_template, | |||
String $systemd_drop_in_dir = $filebeat::params::systemd_drop_in_dir, |
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.
Can we rename this to systemd_override_dir
?
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.
agreed
this makes a lot of sense. not many people will under stand what a drop in directory is
I will change it to systemd_override_dir
I will have this pull request updated with the recommendations soon. |
Thanks for all the work on this. I'm not going to be near a computer for the rest of the week so I'm going to cut a new release on Monday in case we missed something. |
Would it be better to use elastic's preferred method rather than overriding the systemd file wholesale? |
I ended up creating file resources like this:
The Exec[systemctl-daemon-reload] is from |
@dforste That's essentially what's been done here, but everything has been scoped to logging for now, and the file values have been setup in a template so you can override things beyond just |
Released as 4.1.0 |
This PR overrides default logging with filebeat version 7 running on systems running systemd
Since filebeat version 7, systemd service file hard codes the flag
-e
. this option sets the logging to syslog and will ignore any logging set by this puppet module.This change creates a systemd drop-in file for filebeat that drops the
-e
flag if a $logging hash is set when using the class