Skip to content

[ES|QL] METRICS_INFO support: columns_after & summary#256758

Merged
momovdg merged 12 commits intoelastic:mainfrom
momovdg:esql-metrics-info
Mar 11, 2026
Merged

[ES|QL] METRICS_INFO support: columns_after & summary#256758
momovdg merged 12 commits intoelastic:mainfrom
momovdg:esql-metrics-info

Conversation

@momovdg
Copy link
Copy Markdown
Contributor

@momovdg momovdg commented Mar 9, 2026

part of #255433

Summary

Adds support for METRICS_INFO command.

  • implements columns_after and summary
  • should only be available for TS
  • should not be suggested after STATS

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

@momovdg momovdg self-assigned this Mar 9, 2026
@momovdg momovdg added Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana t// v9.4.0 release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Mar 9, 2026
@momovdg momovdg force-pushed the esql-metrics-info branch from 57c343e to 4154010 Compare March 10, 2026 11:20
@momovdg momovdg marked this pull request as ready for review March 10, 2026 13:28
@momovdg momovdg requested review from a team as code owners March 10, 2026 13:28
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-esql (Team:ESQL)

Copy link
Copy Markdown
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Looks nice! some comments from the review!

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.

Can we keep the same logic as in src/platform/packages/shared/kbn-esql-language/src/commands/registry/registered_domain/columns_after.ts ?

Mostly for consistency (plus you dont need to add the userDefined: false everywhere)

type?: 'source' | 'header' | 'processing'; // Optional property to classify the command type
isTimeseries?: boolean; // Optional property to indicate if the command is a timeseries source command
requiresTimeseriesSource?: boolean; // Optional property to indicate the command is only available when the source command is TS
notAfterCommands?: string[]; // Optional list of command names after which this command should not be suggested (e.g. METRICS_INFO not after STATS)
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.

Suggested change
notAfterCommands?: string[]; // Optional list of command names after which this command should not be suggested (e.g. METRICS_INFO not after STATS)
hiddenAfterCommands?: string[]; // Optional list of command names after which this command should not be suggested (e.g. METRICS_INFO not after STATS)

}
return true;
})
.filter((command) => {
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.

You only check the last command, this means that

TS kibana_sample_data_logstsdb  | STATS x = count( event.dataset) | 

will suggest metrics info while it should not

This should make it work as we want

.filter((command) => {
  const hiddenAfter = command.metadata?.hiddenAfterCommands;
  if (hiddenAfter?.length) {
    return !astContext.astForContext.commands.some(
      (cmd) => hiddenAfter.includes(cmd.name)
    );
  }
  return true;
})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed in 5c889c9

}),
declaration: 'METRICS_INFO',
examples: ['TS index | METRICS_INFO'],
preview: false,
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.

Suggested change
preview: false,
preview: true,

_command: ESQLCommand,
previousColumns: ESQLColumnData[],
_query: string
) => {
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.

Suggested change
) => {
) : ESQLColumnData[] => {

it('returns exactly the fixed set of metrics info columns', () => {
const result = summary(mockCommand);

expect(result.newColumns).toEqual(
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.

Dont hardcode them, we have them in a constant, no?

declaration: 'METRICS_INFO',
examples: ['TS index | METRICS_INFO'],
preview: false,
hidden: false,
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.

Suggested change
hidden: false,

@momovdg momovdg requested a review from stratoula March 10, 2026 18:29
Copy link
Copy Markdown
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

This looks great now! Thanks

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Scout: [ security / entity_store ] plugin / local-stateful-classic - Entity Store History Snapshot - history snapshot: copies latest to history index and resets behaviors on latest

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
esql 954 957 +3

Page load bundle

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

id before after diff
kbnUiSharedDeps-npmDll 7.1MB 7.1MB +2.2KB
kbnUiSharedDeps-srcJs 4.1MB 4.1MB +1.4KB
total +3.6KB

History

cc @momovdg

@momovdg momovdg merged commit 55705dd into elastic:main Mar 11, 2026
19 checks passed
@momovdg momovdg deleted the esql-metrics-info branch March 11, 2026 08:05
mbondyra added a commit to mbondyra/kibana that referenced this pull request Mar 11, 2026
…e_fix

* commit '565f7545c422192218b803874fbdf93e8d8f08ee': (27 commits)
  [Lens API] ESQL schema for XY separately for Agent and some small token optimizations (elastic#256885)
  Fix "Accessing resource attributes before async attributes settled" telemetry error (elastic#256880)
  [Security Solution][Attacks/Alerts][Attacks page][Table section] Preserver "Sort by" state on Attacks page (elastic#256717) (elastic#256795)
  [APM] Improve redirect with default date range guard (elastic#256887)
  [Security Solution][Attacks/Alerts][Attacks page][Table section] Add assignees avatars to the group component (elastic#250126) (elastic#256901)
  [Docs] add xpack.alerting.rules.maxScheduledPerMinute setting description (elastic#257041)
  [SO] Fix non-deterministic ordering in nested find API integration tests (elastic#256447)
  [Write-restricted dashboards] Update user profile retrieval for getShouldAddAccessControl (elastic#255065)
  [One Workflow] Add Scout API test scaffold and execution tests (elastic#256300)
  [Fleet] add use_apm if dynamic_signal_types are enabled (elastic#256429)
  [Fleet] ignore data streams starting with `.` in Fleet API (elastic#256625)
  [ES|QL] METRICS_INFO support: columns_after & summary (elastic#256758)
  [Agent Builder] Agent plugins: initial installation support (elastic#256478)
  [Streams] Add field descriptions and documentation-only field overrides (elastic#255136)
  [api-docs] 2026-03-11 Daily api_docs build (elastic#257023)
  [Security Solution] fix alerts page infinite loading state due to data view error (elastic#256983)
  [Logging] Add `service.*` global fields (elastic#256878)
  [Canvas] Apply embeddable transforms to embeddable elements (elastic#252191)
  [table_list_view_table] stabilize jest test (elastic#254991)
  [Obs AI] get_index_info: add unit tests (elastic#256802)
  ...
sorenlouv pushed a commit that referenced this pull request Mar 17, 2026
part of #255433

## Summary

Adds support for METRICS_INFO command.
- implements
[columns_after](src/platform/packages/shared/kbn-esql-language/src/commands/registry/metrics_info/columns_after.ts)
and
[summary](src/platform/packages/shared/kbn-esql-language/src/commands/registry/metrics_info/summary.ts)
- should only be available for TS
- should not be suggested after STATS

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [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
- [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)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Stratou <efstratia.kalafateli@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:ES|QL ES|QL related features in Kibana release_note:skip Skip the PR/issue when compiling release notes Team:ESQL ES|QL related features in Kibana t// v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants