-
Notifications
You must be signed in to change notification settings - Fork 204
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
Add support for logging to Loki (and others) #1401
Conversation
…oggers and simplify prepend with timestamp
I should also mention that I've replaced the |
Replace wrapper and directly instance object
# Conflicts: # requirements.txt
…on options for loki servers
It should be noted that I cannot re-produce the error in the "Python Unit Tests (CY2023)" locally (in the docker container). |
# Conflicts: # rqd/rqd/rqcore.py
Signed-off-by: Jimmy Christensen <[email protected]>
I'm afraid I had to undo the changes from #1335 since this changes how things are logged. Hopefully it should be easier to re-implement again. |
Hi @lithorus Ok, I see. How does your solution with Loki handle non-ASCII characters in the logs? What happens with RQD when logs contain characters like these: Does RQD crash with non-ASCII characters in the logs? Additionally, I think it would be beneficial to provide a logging solution using Loki that can be enabled or disabled. This way, we can revert to the previous default logging methods if Loki logs are disabled. So for me, this current solution should be kept if the Loki logs are disabled. |
…ting out log in RQLogger
You're right, it would crash if it got non-ascii characters. I tested it out with I will wrote the details on how Loki is enabled/disabled in the summary of this PR. |
Great, thanks @lithorus ! |
Have added some more details on it now. |
while True: | ||
output = frameInfo.forkedCommand.stdout.readline() | ||
if not output and frameInfo.forkedCommand.poll() is not None: | ||
break | ||
if output: | ||
self.rqlog.write(output, prependTimestamp=rqd.rqconstants.RQD_PREPEND_TIMESTAMP) |
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 logic doesn't seem to have the same problems of the previous logic when RQD_PREPEND_TIMESTAMP=False
(See #1426 ) but one think I'm not quite sure I understand is how stderr is being parsed.
The logic from pipe_to_file
that got removed allows parsing both stdout and stderr into a single output without blocking on waiting on one of the pipes. Probably something similar will be required if we want both stdout and stderr content to be sent to Loki.
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.
From what I remember both STDOUT and STDERR is being piped and thus end out the same way. I'm almost certain I tested exactly for that. Let me double check it.
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.
Yes, both STDOUT and STDERR works (tested it with the file output, but should be the same for loki)
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.
Btw, will it be ok to have the loki part still being beta/experimental? This PR changes alot more than just adding support for loki.
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.
Now I remember how it was done. stderr is sent to stdout, of course there won't be any distinguish between the 2, which might be good to have in loki as seperate tags.
stderr=subprocess.STDOUT,
@DiegoTavares I've created another PR with only the log abstraction and without the Loki part. There was still missing a few bits and pieces on that part before it was ready for production and would like to explore a few ideas on how to make it more modular. |
Great, I have it on my list to be reviewed soon. As this change adds a new feature, it will require changes to the documentation on opencue.io's Other Guides section. This website is maintained in this repo. |
Will re-do the implementation. |
**Link the Issue(s) this Pull Request is related to.** #1401 #1427 **Summarize your change.** This abstracts the reading of logs and writing log files. This makes it simpler to do things like supporting other logging types and conversions (eg. make sure things are ASCII) in a single class across all platforms. This is a smaller version of #1401 with just the file logging abstracted. It also implements the changes from #1427 Co-authored by @ramonfigueiredo and @lithorus --------- Signed-off-by: Jimmy Christensen <[email protected]> Co-authored-by: Ramon Figueiredo <[email protected]>
…demySoftwareFoundation#1429) **Link the Issue(s) this Pull Request is related to.** AcademySoftwareFoundation#1401 AcademySoftwareFoundation#1427 **Summarize your change.** This abstracts the reading of logs and writing log files. This makes it simpler to do things like supporting other logging types and conversions (eg. make sure things are ASCII) in a single class across all platforms. This is a smaller version of AcademySoftwareFoundation#1401 with just the file logging abstracted. It also implements the changes from AcademySoftwareFoundation#1427 Co-authored by @ramonfigueiredo and @lithorus --------- Signed-off-by: Jimmy Christensen <[email protected]> Co-authored-by: Ramon Figueiredo <[email protected]>
…demySoftwareFoundation#1429) **Link the Issue(s) this Pull Request is related to.** AcademySoftwareFoundation#1401 AcademySoftwareFoundation#1427 **Summarize your change.** This abstracts the reading of logs and writing log files. This makes it simpler to do things like supporting other logging types and conversions (eg. make sure things are ASCII) in a single class across all platforms. This is a smaller version of AcademySoftwareFoundation#1401 with just the file logging abstracted. It also implements the changes from AcademySoftwareFoundation#1427 Co-authored by @ramonfigueiredo and @lithorus --------- Signed-off-by: Jimmy Christensen <[email protected]> Co-authored-by: Ramon Figueiredo <[email protected]>
Summarize your change.
Have introduces a new module and class for RQD which deals with writing the process log file.
This is to abstract file writing which gives the ability to support non-file based logging (eg. loki, elasticsearch)
I have not been able to test the code changes on Windows and Mac
It depends on #1416 since the loki python module is not compaible with python 2.x
Still work-in-progress and comments on the implementation are welcome...
RQDLogger
A new python module (
rqlogging
) with the new classRQDLogger
has been added to RQD to abstract any process logging. It's supposed to be a drop in replacement for a file object with some extra functions (like waiting for the file to be created). It also checks if it's using a "protocol" and will instantiate a sub-class for the appropriate protocol.This makes it easy to centralize the logging logic and also adds the ability to extend with more logging backends.
How to use it
---- Cuebot configuraton ----
Cuebot provides the path to the root of logs, so this is where RQD is configured for logging.
It can either be configured using the environment variable
CUE_FRAME_LOG_DIR
or using thelog.frame-log-root.default_os
propterty in the config file.This is also what's used to determine whether or not to use loki (at job submission time) instead of plain file logging. Only if the "protocol" is defined, it will not log straight to files. (however still using the wrapper)
To confgure for loki, a path like this can be used :
loki://internal/shows
loki
being the protocolinternal
is refering to the server instance/shows
is refering to prefixed path on the serverThe server instance variable is not the actual address. but a reference to a server definition in RQD's config
---- RQD configuration ----
in
rqd.conf
:internal
is the server reference namehttp://127.0.0.1:3100/loki
is the actual address used for submitting logs to the server---- Cuegui configuration ----
in
cuegui.yaml
:internal
is the server reference namehttp://127.0.0.1:3100/loki
is the actual address used for pulling logs from the serverWhen reading a log file in cuegui it looks like this :
---- Limitation ----
Currently it does not support multiple logs from the same frame in CueGui. (for non-file based logging)
Does not yet support authentication and "X-Scope-OrgID" is hardcoded to "1" (when using Loki)