-
Notifications
You must be signed in to change notification settings - Fork 75
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
logging: use journald logging for all systemd services #2779
Conversation
Jira: This PR is not related to a Jira item. (The PR title does not include a SC-#### reference) GitHub Issues: No GitHub issues are fixed by this PR. (No commits have Fixes: #### references) Launchpad Bugs: No Launchpad bugs are fixed by this PR. (No commits have LP: #### references) Documentation: The changes in this PR do not require documentation changes. 👍 this comment to confirm that this is correct. |
eb05a38
to
5a89094
Compare
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.
LGTM, thanks for the refactors.
@orndorffgrant should we use our JSON format when logging to |
5a89094
to
39bf6d6
Compare
@lucasmoura I think it should use the json logging to be consistent. The |
My rationale is that it shouldn't to be honest, just to align with the other |
I'd rather keep consistency with our own logs than with journald's default formatting. journald's logging itself is structured and can be formatted as json as well, though in that case our json message becomes an escaped json string value in their json and looks like this:
So by formatting our message string in json, we're just adding a nested structure within the journald structure. I don't know if this is widely used practice, but I don't think I'd consider it a bad practice (unless I'm unaware of some downside). A couple things about using our json formatter:
We can talk more about this post-standup tomorrow or next week too |
@sergiodj @athos-ribeiro @lucasmoura After our discussion in Riga, I've updated this to remove the json formatting in journald logs. We still want to include multiple fields with structure, though, so I've introduced a simpler (but more fragile) Taking the example from my last comment here, it would now look like this:
Do you think this is better or worse than the json formatting? |
And I haven't explained yet, we don't want to pull |
8b1d723
to
50101fb
Compare
Thanks, Grant! Would you mind showing what an old (current) log entry would look like compared to the new format? |
Thanks for looking @athos-ribeiro! Prior to this PR, most services logged to /var/log/ubuntu-advantage.log in the JSONArray format. This was not done in a multi-process-safe way. Any messages that ended up in journald were accidental and did not contain any structure, e.g. it would just be the message string like "Failed to fetch ESM Apt Cache item: https://esm.ubuntu.com/apps/ubuntu/dists/xenial-apps-security/InRelease". Two services already logged to journald in the JSONArray format. So there are several changes here from the perspective of someone interested in our logs:
We haven't considered backwards compatibility of our logs very seriously in the past. The biggest breaking change, though, would be moving away from JSONArray formatting for the services that were already using it. Anything else would've been handled as a string, so adding structure wouldn't break it significantly IMO. |
This is quite the breaking change. If I, as a user, would be parsing the logs, I would be very annoyed with such a change in an LTS upgrade. |
Other points:
|
Thank you for taking a look @panlinux - we're in agreement I think. Looking back, my tone was a bit flippant in my last comment, but the intent was to show that I thought it was a bad idea to change the format from JSONArray to something else. My original proposal was to add JSONArray formatting to previously unstructured messages in journald. I would still prefer to only do that, since it would add additional information to the logs and I don't think it should be considered a breaking change (we added the same structured logging to ubuntu-advantage.log in the past). So then the total set of changes in this PR would be:
Then pro logging will be the same format everywhere and we will document the format. With a structured extensible logging format in place everywhere that If you think that is acceptable, then I'd like to avoid a config option for logging formats. |
features/unattached_commands.feature
Outdated
""" | ||
_usr_lib_ubuntu-advantage_esm_cache | ||
WARNING|ubuntupro.apt|fail|\d+|Failed to fetch ESM Apt Cache item: https://esm.ubuntu.com/apps/ubuntu/dists/<release>-apps-security/InRelease|{} |
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.
Just to double check, why is the function name fail
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.
Inside update_esm_caches
, an EsmAcquireProgress
class is defined with a fail
method that is called by the apt
library when an error occurs. That method is where we log this line
50101fb
to
bee04a4
Compare
@panlinux @lucasmoura I've updated this PR so it only does the following:
There are no breaking changes. Is this okay? |
bee04a4
to
6ae730e
Compare
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.
imho this is a good changeset after all the discussion
6ae730e
to
864715c
Compare
864715c
to
4e63039
Compare
4e63039
to
cdded71
Compare
CI fail unrelated |
I'm going ahead and merging the least controversial version of this PR (new logging to journald using JSON format). |
Why is this needed?
This PR brings journald logging to all systemd services, plus a few small related refactors.
Test Steps
Checklist
Does this PR require extra reviews?