Skip to content

[9.3] [Metrics] [Lens] Replace custom header with lens highlight implementation (#249450)#250281

Merged
justinkambic merged 8 commits intoelastic:9.3from
justinkambic:backport/9.3/pr-249450
Jan 30, 2026
Merged

[9.3] [Metrics] [Lens] Replace custom header with lens highlight implementation (#249450)#250281
justinkambic merged 8 commits intoelastic:9.3from
justinkambic:backport/9.3/pr-249450

Conversation

@justinkambic
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.3:

Questions ?

Please refer to the Backport tool documentation

…tion (elastic#249450)

## Summary

Related to elastic#241152.

~This PoC would replace the metrics panel custom header components with
a native Lens implementation of the highlighting functionality.~

Previously, the Metrics UI team implemented a custom header component to
use for the Metrics embeddables shown in Discover. This allowed for a
highlight mechanic that was not present in lens, shown below:

![Untitled](https://github.com/user-attachments/assets/4ec8eacc-3537-4127-8910-a1c06ce283af)

Unfortunately, with the custom implementation they also had to cancel
interaction events related to selecting/copying the text contents of the
header, because of unwanted UI side effects. As noted in the linked
issue, rather than adding additional CSS hacks, the desire was instead
to have Lens support the highlight feature, and remove the custom
implementation altogether.

**The goal of this patch is to allow Metrics UI to use the default
embeddable title component, while keeping the highlight feature.**

This is achieved by adding a `titleHighlight` prop to the embeddable
component. When this prop is defined, the embeddable will wrap the title
content in an `EuiHighlight` as the custom component was doing. In the
case of Metrics UI, which passes the highlight, the embeddable's title
will wrap the intended content in a highlight. Otherwise, the new code
is skipped, and the embeddable component should behave exactly as it
normally would.

## Testing

### Getting data

Testing this PR will require metrics data indexed at a path like
`metrics*`.

There are a bunch of ways to do this, but a simple way is to clone
Simian Forge:

```bash
git clone https://github.com/simianhacker/simian-forge.git
```

Perform an install + build:

```bash
npm i && npm run build
```

Then, create an Elasticsearch API key. This is easily achieved in Kibana
by going to the API key management page and creating a new key. Copy the
key Kibana created for you and use it in your command, like below:

<img width="1146" height="465" alt="API key management page"
src="https://github.com/user-attachments/assets/a19639af-7642-4d02-b32d-6d6413676b9d"
/>

```bash
./forge --backfill now-1h --interval 10s --count 100 --dataset hosts --purge --elasticsearch-url {ES_URL} --elasticsearch-api-key  {API_KEY}
```

If you're running Elasticsearch locally, you can simply specify
`--elasticsearch-url http://localhost:9200`.

### Querying data

Perform a metrics ES|QL query like:

```
TS metrics*
```

When the metrics visualizations appear, make sure you're able to select
the text with your mouse pointer and copy the contents.

Both the highlight functionality, and text selection, are shown in the
image below:

![20260121160019](https://github.com/user-attachments/assets/3fb50eec-1298-4bef-b050-1e728dd3caeb)

_Additional note:_ because this change makes the Metrics component
`ChartTitle` obsolete, it removes the component's file/tests as well.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 15610b7)

# Conflicts:
#	src/platform/packages/shared/kbn-unified-metrics-grid/moon.yml
#	src/platform/packages/shared/kbn-unified-metrics-grid/tsconfig.json
#	src/platform/plugins/private/presentation_panel/public/panel_component/types.ts
@justinkambic justinkambic added the backport This PR is a backport of another PR label Jan 23, 2026
@justinkambic justinkambic enabled auto-merge (squash) January 23, 2026 21:35
@justinkambic justinkambic added the backport This PR is a backport of another PR label Jan 23, 2026
@justinkambic justinkambic force-pushed the backport/9.3/pr-249450 branch from 49e5ce5 to 2adbc00 Compare January 27, 2026 19:15
@justinkambic
Copy link
Copy Markdown
Contributor Author

Note to reviewers: this patch introduced two minor regressions. They have been fixed in #250619 and #250963. Both of those changes are already backported to 9.3. I've merged the latest commits into this backport, so you should be able to test and see correct filtering/reordering behavior, and the mark color in the search highlight should match Discover's style.

@weltenwort weltenwort self-requested a review January 30, 2026 16:02
Copy link
Copy Markdown
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

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

LGTM and seems to work as expected

@justinkambic justinkambic merged commit 42a8b9b into elastic:9.3 Jan 30, 2026
13 checks passed
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #83 / integrations For each artifact list under management "after all" hook in "For each artifact list under management"
  • [job] [logs] FTR Configs #83 / integrations For each artifact list under management "before all" hook in "For each artifact list under management"

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 1890 1889 -1

Async chunks

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

id before after diff
discover 1.3MB 1.3MB -1.5KB
presentationPanel 43.1KB 43.3KB +172.0B
total -1.3KB

Page load bundle

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

id before after diff
lens 64.5KB 64.6KB +36.0B

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants