-
Notifications
You must be signed in to change notification settings - Fork 271
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
Refs #22559 - Add parameters for structured logging #631
Conversation
This will also need code to install packages if any logger other than |
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.
Issue number must be 22559.
@@ -253,6 +253,8 @@ | |||
|
|||
# Application logging | |||
$logging_level = 'info' | |||
$logging_type = 'file' | |||
$logging_layout = 'pattern' |
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.
Default was multiline_pattern
, but I am fine with switching to pattern
. The difference is that the former adds |
characters at the beginning of each line, which is useful for development but in syslog/journald this might not be the best thing to do. So +1.
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.
Was multiline_pattern
also used before structured logging was introduced? I thought it was pattern
so stayed with it here.
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 was the default, yes. I mean for development setup, not sure about production, but we did not explicitly set it so it was the default (so yes)? I actually like pattern
more than the other one - it's cleaner.
@@ -253,6 +253,8 @@ | |||
|
|||
# Application logging | |||
$logging_level = 'info' | |||
$logging_type = '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.
This is indeed the most sane default - everything stays the same for production instance.
But logging to files is considered bad practice, except some corner cases (e.g. apache httpd access logs) using standard logging mechanisms should be preferred. I was hoping to default to journald (if present), syslog (otherwise) and just dropping /etc/rsyslog.d/foreman.conf
configuration file and alerting daemon to reload (similarly for syslog-ng). If that's too complex in Puppet, we can just leave file logging for now.
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 is indeed the most sane default - everything stays the same for production instance.
That was indeed exactly what I thought, also because I can't quite oversee what else is affected. Start with configuration options and safe defaults.
If journald is just drop in, we could use facts to determine if systemd is used. I'm hesitant to start managing syslog since that can be fairly complex and more up to the admin to set up. That's why I'd fall back to file
if systemd is not used. My plan was to revisit the defaults later.
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 question is how or when do we find out it's now safe to change the default, too bad didn't have this in the beginning of 1.18 dev window. Would it make sense to change the default just after we branch out?
I agree that we shouldn't manage syslog but dropping a oneliner to /etc/rsyslog.d/foreman.conf
would be acceptable I think?
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 question is how or when do we find out it's now safe to change the default, too bad didn't have this in the beginning of 1.18 dev window. Would it make sense to change the default just after we branch out?
For me it depends on whether journald is a drop in replacement:
- Does journald also log to a file?
- Can foreman-debug extract logs from journald?
I agree that we shouldn't manage syslog but dropping a oneliner to /etc/rsyslog.d/foreman.conf would be acceptable I think?
The difficulty is that we can't rely on any syslog implementation. I can imagine users are using syslog-ng
for example. Then we also need to support that. Suddenly we have a few extra parameters for things that IMHO belong in a profile module. Will we manage the syslog daemon as well for example. We've worked hard to keep that out of puppet-foreman. It just doesn't fit the design. I really don't want to touch syslog at all.
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.
Unfortunately, journald main idea is all around binary journal that can be sealed - there is no file logging in journald. It can however forward to syslog and that's what it does by default on most systems these days.
I will create patch for foreman-debug to collect the logs from there for sure.
If we don't want to touch syslog, then another option is to ditch /var/log/foreman/production.log
completely. An installer could archive/rename all files in pattern production*.log*
and drop a dummy file with short explanation that this is not used. I don't think this is a bad experience for users after upgrade at all. Things change.
Structured logging patch is not only about structured logging, but also about collecting things from other parties like backend systems or smart proxy. With files, we can't achieve that, but having things in journald allows us to start working towards this goal.
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.
To me it sounds like we should talk to our users about their expectations because nowadays I'm somewhat removed from actual deployments. Should we open a topic on community.theforeman.org?
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.
b2a8deb
to
09ab49e
Compare
7f1192b
to
d4fbd24
Compare
I've expanded the PR to include acceptance tests. This told me we don't have the |
d4fbd24
to
893d806
Compare
Tests now pass locally:
|
16b7ad3
to
cb6fee8
Compare
With RPMs I have an issue with loading the gem. theforeman/foreman#5421 solves it for me. Split off other commits in separate PRs that can be merged before this: |
cb6fee8
to
64a5686
Compare
Shall I re-review now? 2/3 merged atm. |
64a5686
to
c5ccbdc
Compare
@lzap previously the tests on Debian failed because it wasn't logging in a situation where it first used file logging and then moved to journald. I still want to reproduce this. |
@lzap looks like we have the same issue on CentOS in containers. Going to test it on a VM on my desktop now to see if I can reproduce it. |
Oh interesting, no journald in container? It was designed to be container friendly, let's see. |
@lzap when i manually ran only the journald test it did work for me locally. On Travis it first installs a basic Foreman with file logging. It could be that the upgrade doesn't work. |
@lzap I know what the problem is. For the redirect log line I relied on the apache preloader to do a request but that isn't sent when you reload the app by touching |
5474923
to
08407fa
Compare
Ready for re-review now. |
(Debian tests are now failing because nightly doesn't install). |
this needs a rebase now |
08407fa
to
e10610e
Compare
Tested various combinations of --foreman-logging-layout --foreman-logging-level and --foreman-logging-type on rhel 7.4 based on docs in https://github.com/theforeman/theforeman.org/pull/1053/files -- journald part works all right with all three patterns, foreman fields are logged as expected, filtering and persistent storage works |
Do you mean syslog here?
We don't have that setting, but it should be easy to add. Shall I modify the PR? |
please rebase :) |
e10610e
to
7d8d0fe
Compare
Rebased again :) |
Yes syslog, sorry
To me it makes sense to have yaml-configurable options also as installer parameters, so I'd say yes. |
The current version stays on |
Let's bring this in as-is for now 👍 |
merged, bedankt @ekohl! |
Thanks a bunch @ekohl ! I realized one thing, when journald or syslog is set, we should configure logrotate NOT to poke httpd because it's not necessary anymore. |
No description provided.