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

[ES|QL] METRICS command definition and validation #184905

Merged
merged 92 commits into from
Jun 20, 2024

Conversation

vadimkibana
Copy link
Contributor

@vadimkibana vadimkibana commented Jun 6, 2024

Summary

Partially addresses #184498

The main contribution of this PR is the METRICS command validation cases:

image

See own-review below for more comments.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@vadimkibana
Copy link
Contributor Author

I also noticed that METRICS kibana_sample_data_logstsdb avg(to_long(avg(2))) should error because of a nested aggregation function but doesn't

I've added validation to check for agg-in-agg function errors.

@vadimkibana
Copy link
Contributor Author

vadimkibana commented Jun 11, 2024

Gave this a functionality a spin using the TSDB sample web logs. Seems like the validator isn't properly checking for the existence of fields in functions

The validator is actually checking for those fields in functions correctly, but those fields are missing from the reference map. The reference map contains only two fields:

image

To fetch the fields it executes this METRICS ESQL query with | LIMIT 0:

image

I guess, I need to change the way we retrieve the field list. It seems METRICS ... | LIMIT 0 has to be change to something else ...


Limit-0 query, expression data table and fields list for

metrics kibana_sample_data_logstsdb max(bytes) by host
image

Limit-0 query, expression data table and fields list for

FROM kibana_sample_data_logstsdb | stats max(bytes) by host
image

@vadimkibana
Copy link
Contributor Author

@drewdaemon I've solved the missing field error by using FROM ... | LIMIT 0 instead of METRICS ... | LIMIT 0 to load the fields. bc03874

@drewdaemon
Copy link
Contributor

Vadim do you want to do this in this PR or a follow-up? #186005

@drewdaemon
Copy link
Contributor

@drewdaemon I've solved the missing field error by using FROM ... | LIMIT 0 instead of METRICS ... | LIMIT 0 to load the fields. bc03874

Just tried it out. Looks great!

@vadimkibana
Copy link
Contributor Author

Vadim do you want to do this in this PR or a follow-up? #186005

@drewdaemon yes, I'll better to do it as a follow up, this is already too big.

/**
* Looks for first nested aggregate function in an aggregate function, recursively.
*/
const findNestedAggFunctionOfAggFunction = (agg: ESQLFunction): ESQLFunction | undefined => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const findNestedAggFunctionOfAggFunction = (agg: ESQLFunction): ESQLFunction | undefined => {
const findNestedAggFunctionInAggFunction = (agg: ESQLFunction): ESQLFunction | undefined => {

Copy link
Contributor

@drewdaemon drewdaemon left a comment

Choose a reason for hiding this comment

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

Approved with a couple comments. Thanks for all your work on this!

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #85 / console app console autocomplete feature Autocomplete behavior JSON autocompletion with placeholder fields

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/esql-ast 95 96 +1
@kbn/esql-validation-autocomplete 178 181 +3
total +4

Page load bundle

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

id before after diff
kbnUiSharedDeps-srcJs 3.2MB 3.2MB +5.1KB
Unknown metric groups

API count

id before after diff
@kbn/esql-ast 98 99 +1
@kbn/esql-validation-autocomplete 189 192 +3
total +4

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@vadimkibana vadimkibana merged commit d9fc2ca into elastic:main Jun 20, 2024
21 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 20, 2024
seanrathier pushed a commit to seanrathier/kibana that referenced this pull request Jun 21, 2024
## Summary

Partially addresses elastic#184498

The main contribution of this PR is the `METRICS` command validation
cases:

<img width="778" alt="image"
src="https://github.com/elastic/kibana/assets/82822460/3d768952-3fa3-4928-b251-204c30d20c4b">

See own-review below for more comments.


### Checklist

Delete any items that are not applicable to this PR.

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

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
bhapas pushed a commit to bhapas/kibana that referenced this pull request Jun 24, 2024
## Summary

Partially addresses elastic#184498

The main contribution of this PR is the `METRICS` command validation
cases:

<img width="778" alt="image"
src="https://github.com/elastic/kibana/assets/82822460/3d768952-3fa3-4928-b251-204c30d20c4b">

See own-review below for more comments.


### Checklist

Delete any items that are not applicable to this PR.

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

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
umbopepato pushed a commit to umbopepato/kibana that referenced this pull request Jul 5, 2024
## Summary

Partially addresses elastic#184498

The main contribution of this PR is the `METRICS` command validation
cases:

<img width="778" alt="image"
src="https://github.com/elastic/kibana/assets/82822460/3d768952-3fa3-4928-b251-204c30d20c4b">

See own-review below for more comments.


### Checklist

Delete any items that are not applicable to this PR.

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

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:ES|QL release_note:skip Skip the PR/issue when compiling release notes review Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) Team:ESQL ES|QL related features in Kibana v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants