Skip to content
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

Explore/Logs: Escaping of incorrectly escaped log lines #31352

Merged
merged 8 commits into from Mar 3, 2021

Conversation

ivanahuckova
Copy link
Member

@ivanahuckova ivanahuckova commented Feb 19, 2021

Over the time, we've had a decent amount of reported issues related to escaping of newlines. Wast majority of those was due to the fact, that users had incorrectly escaped log lines. In that case, there is not much we can do at client side - at Grafana, as we don't know which characters are actual newlines and which have just the \n pattern.

@ethirolle came up with and documented a good idea to give users a chance to replace their incorrectly escaped newlines and tabs with simply replacing \t, \n, \r, with actual newline or tab.

❗️What is very important - we should communicate to users that the lines aren't correctly escaped and that the first step should be fixing escaping. However, for some logs it is very hard/almost impossible to correctly escape them. And for those cases, we would provide them with a feature that would replace incorrectly escapes newlines with actual newlines. Of course, it might always produce incorrect results, as we don't know which characters are actual newlines and which have just the \n pattern, but I think that if we communicate it clearly, users will understand.

In this PR, I am showing the Escaping button only when we detect \t, \n, \r in any of the log lines. It has also experimental feature tooltip. We are also escaping and re-rendering only those lines, that are incorrectly escaped.

escaping.mov

image

When no incorrectly escaped lines - no button:
image

Which issue(s) this PR fixes:
Fixes #27964

Special notes for your reviewer:

This is the POC/my hack day project.

@aocenas
Copy link
Member

aocenas commented Feb 23, 2021

I like this, seems like a useful thing and I like that it's visible only with needed with good copy explaining why it's there.

@davkal @jessover9000 what do you think?

@ivanahuckova ivanahuckova changed the title Explore: POC - Escaping of incorrectly escaped log lines Explore/Logs: Escaping of incorrectly escaped log lines Feb 26, 2021
@ivanahuckova ivanahuckova marked this pull request as ready for review February 26, 2021 15:19
@ivanahuckova ivanahuckova requested a review from a team February 26, 2021 15:19
@ivanahuckova ivanahuckova requested a review from a team as a code owner February 26, 2021 15:19
@ivanahuckova ivanahuckova requested review from torkelo and dprokop and removed request for a team, torkelo and dprokop February 26, 2021 15:19
Elfo404
Elfo404 previously approved these changes Mar 3, 2021
Copy link
Member

@Elfo404 Elfo404 left a comment

Choose a reason for hiding this comment

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

I played with it a bit and seems to work like a charm! 🚀 🔥

I only have some doubts regarding some phrasing/naming for which I added a few comments.

I also couldn't see any major perf issue, did you run some tests as well?

EDIT: Also, I'm not sure if the button can be instead a switch placed beside all the other options, it would make things a bit more consistent but it's starting to get crowded in there, so I'd wait for more UI/UX feedback.

@@ -42,14 +43,15 @@ interface Props extends Themeable {
timeZone: TimeZone;
allowDetails?: boolean;
logsSortOrder?: LogsSortOrder | null;
escapedNewlines?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

what about forceEscape instead?
or something else in an "active" form, like showEscaped, would it make it clearer?

<MetaInfoText
metaItems={[
{
label: 'Your logs might have incorrectly escaped newlines',
Copy link
Member

Choose a reason for hiding this comment

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

maybe, as it's also about tabs:

Suggested change
label: 'Your logs might have incorrectly escaped newlines',
label: 'Your logs might have incorrectly escaped content',

@@ -62,6 +62,7 @@ export interface LogRowModel {
// Actual log line
entry: string;
hasAnsi: boolean;
hasUnescapedNewlines: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

what about hasUnescapedContent (we are also applying this to \t )

@Elfo404 Elfo404 dismissed their stale review March 3, 2021 14:01

Found some issues

@Elfo404
Copy link
Member

Elfo404 commented Mar 3, 2021

I found an issue when using this log line: "Lorem \u001B[31mipsum \\n et\u001B[0m dolor":

Screen.Recording.2021-03-03.at.14.04.01.mov

which also happens if the unescaped \n is outside of the ANSI codes:

Screenshot 2021-03-03 at 14 06 05

but works fine when there's no ANSI code in the string:

Screen.Recording.2021-03-03.at.14.07.15.mov

Also, which is a minor thing probably, as It's a very super-edge case, if I change the time range to only show a subset of logs that don't need escaping, the button will still be there. the only way to make it go away is to refresh the page. I don't know if this was intended, but it might be confusing:

Screen.Recording.2021-03-03.at.14.10.52.mov

@ivanahuckova ivanahuckova merged commit 4c2e5fc into master Mar 3, 2021
Observability (deprecated, use Observability Squad) automation moved this from Under review to Done Mar 3, 2021
@ivanahuckova ivanahuckova deleted the ivana/escape-incorrectly-escaped-logs branch March 3, 2021 17:32
@ivanahuckova ivanahuckova added this to the 7.5.0-beta1 milestone Mar 3, 2021
ryantxu pushed a commit to dejapong/grafana that referenced this pull request Mar 30, 2021
* POC: Escaping of incorrectly escaped log lines

* Remove unused import

* Fix test, change copy

* Make escapedNewlines optional

* Fix typechecks

* Remove loading state from the escaping button

* Update namings
gguillotte-grafana added a commit to gguillotte-grafana/grafana that referenced this pull request Mar 17, 2022
Rewrite the tooltip for the smart feature in PR grafana#31352 that
replaces incorrectly escaped newlines in log lines.

-   Clarify the functionality of the feature to emphasize its
    interactivity.
-   Remove language suggesting that the feature is experimental,
    when we intended to suggest reviewing the results manually for
    correctness.
gguillotte-grafana added a commit to gguillotte-grafana/grafana that referenced this pull request Mar 17, 2022
Describe and provide steps for using the "Escape newlines" feature
in Explore added in PR grafana#31352.
ivanahuckova pushed a commit that referenced this pull request Apr 12, 2022
…es feature (#46709)

* Explore/Logs: Clarify phrasing of newline escape fix tooltip

Rewrite the tooltip for the smart feature in PR #31352 that
replaces incorrectly escaped newlines in log lines.

-   Clarify the functionality of the feature to emphasize its
    interactivity.
-   Remove language suggesting that the feature is experimental,
    when we intended to suggest reviewing the results manually for
    correctness.

* Docs: Document escape newlines feature

Describe and provide steps for using the "Escape newlines" feature
in Explore added in PR #31352.

* Rewrite topic lead to clarify conditional behavior

* Describe reversion of replacements as a standalone task

Reverting the replacements is a separate action, so it should have
its own task. This also describes the option's transformation and
tightens the task language.

* Remove Grafana 7 version qualifier

* Clarify escape sequence detection lede on task

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>

* Clarify "Remove escaping" state change

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>

* Clarify confidence of tooltip content

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
grafanabot pushed a commit that referenced this pull request Apr 12, 2022
…es feature (#46709)

* Explore/Logs: Clarify phrasing of newline escape fix tooltip

Rewrite the tooltip for the smart feature in PR #31352 that
replaces incorrectly escaped newlines in log lines.

-   Clarify the functionality of the feature to emphasize its
    interactivity.
-   Remove language suggesting that the feature is experimental,
    when we intended to suggest reviewing the results manually for
    correctness.

* Docs: Document escape newlines feature

Describe and provide steps for using the "Escape newlines" feature
in Explore added in PR #31352.

* Rewrite topic lead to clarify conditional behavior

* Describe reversion of replacements as a standalone task

Reverting the replacements is a separate action, so it should have
its own task. This also describes the option's transformation and
tightens the task language.

* Remove Grafana 7 version qualifier

* Clarify escape sequence detection lede on task

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>

* Clarify "Remove escaping" state change

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>

* Clarify confidence of tooltip content

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
(cherry picked from commit 42431e6)
ivanahuckova pushed a commit that referenced this pull request Apr 12, 2022
…es feature (#46709) (#47606)

* Explore/Logs: Clarify phrasing of newline escape fix tooltip

Rewrite the tooltip for the smart feature in PR #31352 that
replaces incorrectly escaped newlines in log lines.

-   Clarify the functionality of the feature to emphasize its
    interactivity.
-   Remove language suggesting that the feature is experimental,
    when we intended to suggest reviewing the results manually for
    correctness.

* Docs: Document escape newlines feature

Describe and provide steps for using the "Escape newlines" feature
in Explore added in PR #31352.

* Rewrite topic lead to clarify conditional behavior

* Describe reversion of replacements as a standalone task

Reverting the replacements is a separate action, so it should have
its own task. This also describes the option's transformation and
tightens the task language.

* Remove Grafana 7 version qualifier

* Clarify escape sequence detection lede on task

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>

* Clarify "Remove escaping" state change

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>

* Clarify confidence of tooltip content

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
(cherry picked from commit 42431e6)

Co-authored-by: Garrett Guillotte <100453168+gguillotte-grafana@users.noreply.github.com>
gillesdemey pushed a commit that referenced this pull request Apr 14, 2022
…es feature (#46709)

* Explore/Logs: Clarify phrasing of newline escape fix tooltip

Rewrite the tooltip for the smart feature in PR #31352 that
replaces incorrectly escaped newlines in log lines.

-   Clarify the functionality of the feature to emphasize its
    interactivity.
-   Remove language suggesting that the feature is experimental,
    when we intended to suggest reviewing the results manually for
    correctness.

* Docs: Document escape newlines feature

Describe and provide steps for using the "Escape newlines" feature
in Explore added in PR #31352.

* Rewrite topic lead to clarify conditional behavior

* Describe reversion of replacements as a standalone task

Reverting the replacements is a separate action, so it should have
its own task. This also describes the option's transformation and
tightens the task language.

* Remove Grafana 7 version qualifier

* Clarify escape sequence detection lede on task

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>

* Clarify "Remove escaping" state change

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>

* Clarify confidence of tooltip content

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Logs: Provide option to toggle \n and \t characters in log messages to literal newlines and tabs
3 participants