Skip to content

Split Container Logs sources for stdout vs stderr - #11

Merged
Tim Mulholland (tlmii) merged 3 commits into
microsoft:mainfrom
tlmii:dev/split-container-logs
Oct 3, 2023
Merged

Tim Mulholland (tlmii) merged 3 commits into
microsoft:mainfrom
tlmii:dev/split-container-logs

Conversation

@tlmii

@tlmii Tim Mulholland (tlmii) commented Oct 2, 2023 •

Copy link
Copy Markdown
Member

The Container logs had stdout/stderr as separate streams, but we were reading them into one channel without differentiation. This PR splits them up so that error log entries can be rendered differently to the page based on their actual source.

As an example, prometheus logs are apparently all stderr at the moment (even though they say "level=info" in them), so they all show up red:

446428414-d9eb6c3d-1cbe-4be2-9d50-c612b359c42b

I also cleaned up the way line numbers were rendered in the logs (doesn't change the display, just how we do the display) and detection of timestamps in the logs (RFC3339Nano only at the moment) so that we don't just render whatever the first non-whitespace characters are as the timestamp.

This issue tracks flaky tests in the repository. It is updated regularly with runs from the Outerloop workflow which runs the Quarantined tests. Also, this tracks any test failures might be potentially flaky tests that haven't been quarantined yet.

@davidfowl

Copy link
Copy Markdown
Collaborator

Image/gif?

@tlmii

Copy link
Copy Markdown
Member Author

Image/gif?

Added an image, though its nothing new - just the same red coloring for error logs, and a little clarification of what changed. I do have concerns about the stdout vs stderr intermingling, though, which I just added in chat.

@tlmii Tim Mulholland (tlmii) changed the title Split Container Logs Split Container Logs sources for stdout vs stderr Oct 2, 2023
@karolz-ms

Copy link
Copy Markdown
Contributor

We should rethink the coloring of logs based on whether they are delivered via stdout vs stderr

The classic Unix design is stdout is for machine-readable DATA vs stderr is for human-readable MESSAGES. So if something shows up on stderr, it does not necessarily mean it is a problem and what Prometheus does is arguably the right thing to do.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, just a couple suggestions/questions--HTH!

Comment thread src/Aspire.Dashboard/Model/LogEntry.cs Outdated
}
}

[GeneratedRegex("^(?:\\d{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3]):(?:[0-5][0-9]):(?:[0-5][0-9])(?:\\.\\d{1,9})(?:Z|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])?$")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where this came from? How do I ensure that this is correct, or update this? I think a comment would be very helpful here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment with details on the parts of this. It's both straightforward (no real regex trickery) and complicated (because its still regex). That also led me to realize part of it was wrong, so good idea there. The source was a combination of things, because no single source seemed to have a complete answer.

@tlmii

Copy link
Copy Markdown
Member Author

We should rethink the coloring of logs based on whether they are delivered via stdout vs stderr

The classic Unix design is stdout is for machine-readable DATA vs stderr is for human-readable MESSAGES. So if something shows up on stderr, it does not necessarily mean it is a problem and what Prometheus does is arguably the right thing to do.

Interesting. I wasn't aware of that. It seems like we have a blend of both though, as postgres is clearly treating stderr as human readable messages (even pointing you to documentation, etc). This is another scenario of how I'm not sure what to do about the stdout vs stderr "how to display issue.

@tlmii

Copy link
Copy Markdown
Member Author

We should rethink the coloring of logs based on whether they are delivered via stdout vs stderr

The classic Unix design is stdout is for machine-readable DATA vs stderr is for human-readable MESSAGES. So if something shows up on stderr, it does not necessarily mean it is a problem and what Prometheus does is arguably the right thing to do.

We discussed this a bit during dashboard triage and we're going to follow up as part of a larger conversation about the log display. Lots of questions (timestamps vs none, timestamps on each row vs on each "log entry", stdout vs std error interleaving and synchronization, stdout vs std error coloring/rendering, etc).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

}
}

// Regular Expression for an RFC3339 timestamp, including RFC3339Nano

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🤗

// $ - Ends the string
//
// Note: (?:) is a non-capturing group, since we don't care about the values, we are just interested in whether or not there is a match
[GeneratedRegex("^(?:\\d{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3]):(?:[0-5][0-9]):(?:[0-5][0-9])(?:\\.\\d{1,9})?(?:Z|(?:[Z+-](?:[01][0-9]|2[0-3]):(?:[0-5][0-9])))?$")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not saying this has to be done now, but for such long regular expressions, I like to define the fragments as C# constant strings, and then interpolate them into the final regex. If you chose the names well (for the fragments), it is self-documenting. IgnorePatternWhitespace option can also help.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Whenever I need to change this (probably whenever we figure out the project timestamps) I'll change it to work that way. Thanks for the suggestion!

@tlmii
Tim Mulholland (tlmii) merged commit d9b098b into microsoft:main Oct 3, 2023
@tlmii
Tim Mulholland (tlmii) deleted the dev/split-container-logs branch October 3, 2023 20:32
@github-actions github-actions Bot locked and limited conversation to collaborators May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants