Skip to content

[Lens as code] Merge metrics into a single property for Metric chart#249533

Merged
dej611 merged 9 commits intoelastic:mainfrom
dej611:fix/metric-schema-2
Jan 29, 2026
Merged

[Lens as code] Merge metrics into a single property for Metric chart#249533
dej611 merged 9 commits intoelastic:mainfrom
dej611:fix/metric-schema-2

Conversation

@dej611
Copy link
Copy Markdown
Contributor

@dej611 dej611 commented Jan 19, 2026

Summary

Fix #244506

This PR fixes few Metric chart API shortcomings:

  • Breakdown dimension can be ranked by secondary metric now
    • due to schema library lack of tuple support, while the metrics property can be an array, the introduction of the type discrimination property had to be done to avoid random default injections.
  • Fixed background chart schema for ES|QL version
  • Added more E2E tests (both from SO and API versions)

Checklist

@dej611 dej611 requested a review from a team as a code owner January 19, 2026 11:35
@dej611 dej611 added Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// Feature:Lens backport:version Backport to applied version labels v9.3.0 v9.4.0 labels Jan 19, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@dej611 dej611 added the release_note:skip Skip the PR/issue when compiling release notes label Jan 19, 2026
dej611 and others added 2 commits January 19, 2026 12:52
Co-authored-by: Andreana Malama <andreana.malama@elastic.co>
@andrimal andrimal self-requested a review January 19, 2026 16:46
addLayerColumn(trendLineLayer, `${ACCESSOR}_trendline`, columns);
addLayerColumn(trendLineLayer, HISTOGRAM_COLUMN_NAME, columns);
addLayerColumn(trendLineLayer, `${ACCESSOR}_trendline`, newPrimaryColumns);
addLayerColumn(trendLineLayer, HISTOGRAM_COLUMN_NAME, newPrimaryColumns);
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.

I think here we have an issue that pre-existed and we should pass a date histogram column instead of the newPrimaryColumns here.

addLayerColumn(defaultLayer, columnName, newSecondaryColumns);
if (trendLineLayer) {
addLayerColumn(trendLineLayer, `${columnName}_trendline`, newColumn, false, 'X0');
addLayerColumn(trendLineLayer, `${columnName}_trendline`, newSecondaryColumns, false, 'X0');
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.

Similar pre-existing issue, in line 191 we set
trendlineSecondaryMetricAccessor: '${ACCESSOR}_secondary_trendline', but here we are adding the 'X0' suffix to the layer name. I think we should remove the suffix.

Copy link
Copy Markdown
Contributor

@andrimal andrimal left a comment

Choose a reason for hiding this comment

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

Approving to unblock, as the trendline issue was not caused by this PR.

@dej611 dej611 removed the v9.3.0 label Jan 23, 2026
@dej611 dej611 enabled auto-merge (squash) January 23, 2026 18:08
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
agentBuilder 542.1KB 543.0KB +946.0B
dashboard 809.6KB 810.5KB +944.0B
discover 1.4MB 1.4MB +940.0B
infra 1.2MB 1.2MB +943.0B
lens 2.0MB 2.0MB +1.5KB
observability 1.8MB 1.8MB +943.0B
observabilityAIAssistantApp 277.5KB 278.4KB +944.0B
unifiedDocViewer 381.5KB 382.5KB +943.0B
total +8.0KB

Page load bundle

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

id before after diff
dashboard 17.7KB 17.7KB +14.0B
observabilityAIAssistantApp 17.4KB 17.4KB +1.0B
total +15.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/lens-embeddable-utils 7 5 -2

Total ESLint disabled count

id before after diff
@kbn/lens-embeddable-utils 7 5 -2

History

@dej611 dej611 merged commit 5b8231c into elastic:main Jan 29, 2026
16 checks passed
@kibanamachine kibanamachine added backport:skip This PR does not require backporting and removed backport:version Backport to applied version labels labels Jan 29, 2026
hannahbrooks pushed a commit to hannahbrooks/kibana that referenced this pull request Jan 30, 2026
…lastic#249533)

## Summary

Fix elastic#244506

This PR fixes few Metric chart API shortcomings:

* Breakdown dimension can be ranked by secondary metric now
* due to `schema` library lack of tuple support, while the `metrics`
property can be an array, the introduction of the `type` discrimination
property had to be done to avoid random default injections.
* Fixed background chart schema for ES|QL version
* Added more E2E tests (both from SO and API versions)


### Checklist

- [x]
[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

---------

Co-authored-by: Andreana Malama <andreana.malama@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Lens as code] Revisit Metric chart schema

4 participants