Conversation
|
Speaking of cephadm here. In the new world™ of systemd, daemons are supposed to write to stdout. And stdout is then supposed to end up in journald. For cephadm, I'd like to keep in this way. I mean, to some degree, this PR is a workaround for containers/conmon#242 + https://tracker.ceph.com/issues/49551 . On the other hand, I can see that this log driver might be useful for folks in general. Especially the added metadata looks interesting. Just out of curiosity, where are the benefits for cephadm users? Maybe you want to add this beneath https://docs.ceph.com/en/latest/cephadm/operations/#logging-to-stdout ? |
|
@sebastian-philipp For traditional daemons, they can detect whether the stdout is connected to journald. If yes, then send additional metadata. However, it can be hard for daemons in containers to detect whether they should send additional metadata. Take podman as an example. The stdout of daemons is connected to conmon, the conmon then send the content to log files / journald and the stdout of the podman process (if not detached). For cephadm users, I think we can mount journald socket into the container, then enable the new "logging to journald" feature in this PR. |
|
Apart from the above comments, I also made some other changes:
|
| return LOG_NOTICE; | ||
| if (ceph_prio < 10) | ||
| return LOG_INFO; | ||
| return LOG_DEBUG; |
There was a problem hiding this comment.
I've been undecided on the wisdom of spewing Ceph debug logs to the systemd journal (with cephadm deployed containers or otherwise). Is this really recommended practice?
The mapping you've done is interesting but not necessarily wrong. I think if we have debug_ms=5 you will get some amusing spam in the journal which pretends to be important.
There was a problem hiding this comment.
I've been undecided on the wisdom of spewing Ceph debug logs to the systemd journal
Why not. journald itself can do filtering both on collecting time and viewing time based on its structured metadata. And we are already doing this with the default cephadm deployment.
I think if we have debug_ms=5 you will get some amusing spam in the journal which pretends to be important.
prio=5 is mapped to LOG_INFO, which is the default level if we just connect the stderr to journald. I think it is OK. Anyway, if someone don’t like some logs, they can do the filtering themselves. This can be easier compared with logging to files.
By the way, the journald driver of conmon log everything at LOG_ERROR level. I think this is bad.
There was a problem hiding this comment.
@liewegas and @sebastian-philipp what do you think? i think this change is a nice improvement. but i am not sure regarding @batrick 's question:
Is this really recommended practice?
There was a problem hiding this comment.
As we log to journald instead of a file, we need to be able to write anything (including debugs) to journald that we would write to the files.
Btw we have a similar function in Python already:
ceph/src/pybind/mgr/mgr_module.py
Lines 663 to 679 in 3ba59e9
There was a problem hiding this comment.
As we log to journald instead of a file, we need to be able to write anything (including debugs) to journald that we would write to the files.
This is not necessarily true. We could have a debug log for true "debug" information and a status/error/audit log go to systemd journal. Merging them is convenient for programmers but not necessarily a good thing for users.
There was a problem hiding this comment.
Sending log messages to different targets based on the level is something that none of the logging code currently supports. I'm not sure if it makes sense or not, but I think even if we decide to go down that road it's an orthogonal change to this one
Enable ceph daemons to directly send logs to journald via unix domain socket. While sending logs, metadata like priority, thread, timestamp is sent as structured data. And can be queried by journalctl. Note that I don't use libsystemd because I want the implementation to be as efficient as possible. Signed-off-by: 胡玮文 <[email protected]>
Use the same infrastructure used for local logs. Also with structured metadata. Signed-off-by: 胡玮文 <[email protected]>
Simple program to send a lot log messages to journald. On my PC, it runs at about 35000 log entries per second. Signed-off-by: 胡玮文 <[email protected]>
These tests are skipped if journald is not run. Signed-off-by: 胡玮文 <[email protected]>
|
Hi, what else can I do? As we already sending every log to journald via stderr when deployed with cephadm, I think we don't need to worry about sending too many logs to journald. Besides, this feature is opt-in. If this PR and #40025 get merged, I will plan another PR to enable this by default when deployed with cephadm. (Seems #40025 is nessesary for these logs to be associated with the corresponding systemd unit. |
|
src/common/Journald.h is breaking our Windows builds. For example, see: https://jenkins.ceph.com/job/ceph-dev-new-build/ARCH=x86_64,AVAILABLE_ARCH=x86_64,AVAILABLE_DIST=windows,DIST=windows,MACHINE_SIZE=gigantic/53543/consoleFull#-62692307e4bfde06-44c1-4b3c-8379-d9ee175fb257 . |
|
@ivancich thanks Eric, i am working on a fix to address the FTBFS. |
|
@tchaikov Thanks for the quick fix, Kefu. |
@wjwithagen: Have you seen @tchaikov's Windows fix in PR #40607? I would guess could be adapted for your case. |
|
@ivancich |
Enable ceph daemons to directly send logs to journald via unix domain socket.
While sending logs, metadata like priority, thread, timestamp is sent as structured data. And can be queried by journalctl.
Note that I don't use libsystemd because I want the implementation to be as efficient as possible.
We can work around the issue stated in #39547 if we let daemon talk to journald directly
Checklist
I have used
vstart.shto verify that this works on my PC. Since this depends on external servicejournald, could you comment on whether I need to write tests? If so, how?Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume tox