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

[Discover] Format JSON messages in Observability Logs profile #205666

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

davismcphee
Copy link
Contributor

@davismcphee davismcphee commented Jan 7, 2025

Summary

This PR updates the Observability Logs profile to detect and auto format JSON message values within both the Log overview doc viewer tab and the Summary cell popover. Additionally, it enables CTRL/CMD + F find functionality within the doc viewer JSON tab for all contexts to make it easier for users to search the JSON output.

JSON message formatting:
json

JSON tab find functionality:
find

Checklist

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

@davismcphee davismcphee added release_note:enhancement Feature:Discover Discover Application Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Team:obs-ux-logs Observability Logs User Experience Team labels Jan 7, 2025
@davismcphee davismcphee self-assigned this Jan 7, 2025
@davismcphee davismcphee marked this pull request as ready for review January 7, 2025 03:59
@davismcphee davismcphee requested review from a team as code owners January 7, 2025 03:59
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-logs-team (Team:obs-ux-logs)

Copy link
Contributor

@tonyghiani tonyghiani left a comment

Choose a reason for hiding this comment

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

LGTM, I left a suggestion to avoid props overlapping but nothing blocking this to get merged

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/discover-contextual-components 34 36 +2
@kbn/discover-utils 226 228 +2
total +4

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 785.0KB 785.4KB +318.0B
unifiedDocViewer 115.8KB 116.2KB +439.0B
total +757.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
unifiedDocViewer 11.3KB 11.3KB -18.0B
Unknown metric groups

API count

id before after diff
@kbn/discover-contextual-components 37 39 +2
@kbn/discover-utils 276 278 +2
total +4

History

cc @davismcphee


if (includeFormattedValue) {
try {
formattedValue = JSON.stringify(JSON.parse(unescape(value)), null, 2);
Copy link
Member

Choose a reason for hiding this comment

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

Just wanted to clarify here: This will return a formattedValue for things that are not JSON objects (such as true or null or "hello"). In my testing this seemed to work fine, but I just wanted to clarify that this is the desired behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm good point... It wasn't intentional but I think it's ok since at worst they get some highlighting in the code block. If there's a concern about this we can update it to add an additional check that the parsed value is an object or array.

@davismcphee davismcphee merged commit 518e0af into elastic:main Jan 10, 2025
8 checks passed
@davismcphee davismcphee deleted the format-log-overview-message branch January 10, 2025 00:05
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12700614916

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 10, 2025
…c#205666)

## Summary

This PR updates the Observability Logs profile to detect and auto format
JSON message values within both the Log overview doc viewer tab and the
Summary cell popover. Additionally, it enables CTRL/CMD + F find
functionality within the doc viewer JSON tab for all contexts to make it
easier for users to search the JSON output.

JSON message formatting:

![json](https://github.com/user-attachments/assets/a7c63afd-bef7-4050-b8cf-08e4f469ffa9)

JSON tab find functionality:

![find](https://github.com/user-attachments/assets/aac51e05-6126-4770-8976-0d9057bad557)

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

(cherry picked from commit 518e0af)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jan 10, 2025
…205666) (#206153)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Discover] Format JSON messages in Observability Logs profile
(#205666)](#205666)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Davis
McPhee","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-10T00:05:18Z","message":"[Discover]
Format JSON messages in Observability Logs profile (#205666)\n\n##
Summary\r\n\r\nThis PR updates the Observability Logs profile to detect
and auto format\r\nJSON message values within both the Log overview doc
viewer tab and the\r\nSummary cell popover. Additionally, it enables
CTRL/CMD + F find\r\nfunctionality within the doc viewer JSON tab for
all contexts to make it\r\neasier for users to search the JSON
output.\r\n\r\nJSON message
formatting:\r\n\r\n![json](https://github.com/user-attachments/assets/a7c63afd-bef7-4050-b8cf-08e4f469ffa9)\r\n\r\nJSON
tab find
functionality:\r\n\r\n![find](https://github.com/user-attachments/assets/aac51e05-6126-4770-8976-0d9057bad557)\r\n\r\n###
Checklist\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [x] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"518e0afbde3f0391d7c99bfbb1ef6252a2623d12","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Feature:Discover","v9.0.0","Team:DataDiscovery","backport:prev-minor","Team:obs-ux-logs"],"title":"[Discover]
Format JSON messages in Observability Logs
profile","number":205666,"url":"https://github.com/elastic/kibana/pull/205666","mergeCommit":{"message":"[Discover]
Format JSON messages in Observability Logs profile (#205666)\n\n##
Summary\r\n\r\nThis PR updates the Observability Logs profile to detect
and auto format\r\nJSON message values within both the Log overview doc
viewer tab and the\r\nSummary cell popover. Additionally, it enables
CTRL/CMD + F find\r\nfunctionality within the doc viewer JSON tab for
all contexts to make it\r\neasier for users to search the JSON
output.\r\n\r\nJSON message
formatting:\r\n\r\n![json](https://github.com/user-attachments/assets/a7c63afd-bef7-4050-b8cf-08e4f469ffa9)\r\n\r\nJSON
tab find
functionality:\r\n\r\n![find](https://github.com/user-attachments/assets/aac51e05-6126-4770-8976-0d9057bad557)\r\n\r\n###
Checklist\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [x] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"518e0afbde3f0391d7c99bfbb1ef6252a2623d12"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205666","number":205666,"mergeCommit":{"message":"[Discover]
Format JSON messages in Observability Logs profile (#205666)\n\n##
Summary\r\n\r\nThis PR updates the Observability Logs profile to detect
and auto format\r\nJSON message values within both the Log overview doc
viewer tab and the\r\nSummary cell popover. Additionally, it enables
CTRL/CMD + F find\r\nfunctionality within the doc viewer JSON tab for
all contexts to make it\r\neasier for users to search the JSON
output.\r\n\r\nJSON message
formatting:\r\n\r\n![json](https://github.com/user-attachments/assets/a7c63afd-bef7-4050-b8cf-08e4f469ffa9)\r\n\r\nJSON
tab find
functionality:\r\n\r\n![find](https://github.com/user-attachments/assets/aac51e05-6126-4770-8976-0d9057bad557)\r\n\r\n###
Checklist\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [x] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] If a plugin
configuration key changed, check if it needs to be\r\nallowlisted in the
cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\r\nchanges have been approved by the breaking-change committee.
The\r\n`release_note:breaking` label should be applied in these
situations.\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] The PR description includes
the appropriate Release Notes section,\r\nand the correct
`release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"518e0afbde3f0391d7c99bfbb1ef6252a2623d12"}}]}]
BACKPORT-->

Co-authored-by: Davis McPhee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Discover Discover Application release_note:enhancement Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Team:obs-ux-logs Observability Logs User Experience Team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants