Persist state in structured logs page#2161
Conversation
|
|
||
| if (serializable.Filters.Count > 0) | ||
| { | ||
| queryParameters.Add("filters", JsonSerializer.Serialize(serializable.Filters)); |
There was a problem hiding this comment.
Serializing to JSON isn't the right approach here in my opinion. A URL is intended to be human readable. JSON + URL escaping obfuscates what is happening too much.
(btw I also don't like the service instance ID GUID that is added at the moment but haven't found a perfect way to replace it yet)
Maybe we could use GitHub's search format here: https://docs.github.com/en/issues/planning-and-tracking-with-projects/customizing-views-in-your-project/filtering-projects
Message == "test" = message:test
Message == "hello world" = message:"hello world" (double quote when there are spaces)
Message CONTAINS "hello world" = message:*"hello world"* (add stars for contains)
Message != "hello world" = -message:"hello world" (add minus for negation)
Message NOT CONTAINS "hello world" = -message:*"hello world"*
Example:
https://github.com/dotnet/aspire/issues?q=is%3Aopen+is%3Aissue+-author%3A%40me+sort%3Aupdated-desc+
You would be writing a new serializer/deserializer so it would be much more work. Maybe it's a future improvement?
There was a problem hiding this comment.
I'm happy to do either. What do you mean by not liking the service instance id guid?
There was a problem hiding this comment.
For now, I made a simple filter parser
Similar to github, + separates individual filters, and to avoid confusion, there's a second parameter (separated by a colon) signifying the condition. The filter value is url encoded
ie:
filters=Message:contains:app+Application:!equals:frontend
There was a problem hiding this comment.
re: your comment about service instance ID, I see that's used in other pages too. I'll change all of them in a separate PR and request your review
edit: I opened a separate PR for the other pages, but did structured logs page in this PR
#2255
There was a problem hiding this comment.
Have we accounted for when : is present in the string being searched? This is common in log strings where message:*"myApp: Starting up..." maybe searched for
There was a problem hiding this comment.
Yes, colon is url-encoded!
…-stateful' into dev/adamint/make-structured-logs-stateful
# Conflicts: # src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor # src/Aspire.Dashboard/Components/Pages/ConsoleLogs.razor.cs # src/Aspire.Dashboard/Components/Pages/Metrics.razor # src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs # src/Aspire.Dashboard/Components/Pages/StructuredLogs.razor # src/Aspire.Dashboard/Components/Pages/StructuredLogs.razor.cs


Fixes #1694 by persisting all state in the structured logs page.
Level/application are stored as usual (just strings), while log filters are serialized to/deserialized from the following format:
fieldName:condition:value
where value is url-encoded
Microsoft Reviewers: Open in CodeFlow