kibana/x-pack
Drew Tate 315e9b19ca
[8.x] [ES|QL] Remove command option definitions (#215425) (#215542)
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] Remove command option definitions
(#215425)](https://github.com/elastic/kibana/pull/215425)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Drew
Tate","email":"drew.tate@elastic.co"},"sourceCommit":{"committedDate":"2025-03-21T11:04:33Z","message":"[ES|QL]
Remove command option definitions (#215425)\n\n## Summary\n\nThis PR
removes the declarative objects that were meant to describe
the\nbehavior of \"options\" (see details section below if you don't
know what\nI'm talking about). **It does not remove \"options\" as a
concept from our\nAST.** \"Option\" is probably the wrong name for the
subcommands in the\nAST but, at the moment, it is working fine how it
is.\n\nHere is a list of what these definitions were being used for and
where I\nended up.\n\n| Use | How it worked | What I did
|\n\n|---------------------------------------------------------------------|---------------|------------|\n|
To generate command declarations for display in suggestions menu |
It\nhad some complex logic to try to construct a declaration string from
the\ninformation in the `signature` property | I replaced this
with\nstatically declared declaration strings on the command
definitions. I\ntook most of them directly from our docs. They are a
better result than\nthe autogenerated stuff |\n| To build the `METADATA`
suggestion | the definition was passed into\n`buildOptionDefinition` | I
declared the `METADATA` suggestion\nstatically in the `FROM`
autocomplete code. |\n| To check for field correctness in `METADATA` |
This logic lived in the\noption definition's `validate` method | I moved
it to the `FROM`\ncommand's validate method |\n| To validate the type of
the value assigned to `APPEND_SEPARATOR` in\n`DISSECT` | This logic
lived in the option definition's `validate`\nmethod | I moved it to the
`DISSECT` command's validate method |\n| To check if the left side of
the equals sign in `DISSECT` is\n\"APPEND_SEPARATOR | In most cases, the
parser catches stuff like this,\nbut for some reason `DISSECT`'s grammar
is very loose so we have been\nstepping in with our own validation
(maybe we should suggest changing\nthis). This was the only case that
was triggering the \"Unknown option\"\nmessage. | I moved it to the
`DISSECT` command's validate method |\n| To prevent default column
validation for `METADATA` | This was the\nonly true use of the
`skipCommonValidation` property which would prevent\nthe validator
trying to find metadata fields in the standard field list\n| I inserted
an option name check directly into the validation code.\nIt's not a good
long-term solution, but it is actually an improvement\nsince the former
code pretended to be general but was actually just for\n`METADATA`. At
least now it is clear what the exception is for. |\n| To filter
functions and operators that are available after `BY` |\nFunction
definitions sometimes declare that they are supported in a
`by`\nstatement. The validator checks if the function does. | This
didn't\nchange. The option nodes in the AST are still there and we are
still\nrelying on the `supportedCommands` and `supportedOptions`
properties in\nthe function definitions. |\n\n#### Pictures\n\n<img
width=\"859\" alt=\"Screenshot 2025-03-20 at 1 47
36 PM\"\nsrc=\"https://github.com/user-attachments/assets/3bd3c3c6-6066-466e-b33b-9444ab58670a\"\n/>\n\n_New,
statically-defined declarations_\n\n<img width=\"783\" alt=\"Screenshot
2025-03-20 at 2 12
28 PM\"\nsrc=\"https://github.com/user-attachments/assets/94550b25-5da9-4c82-9586-11b3515debd7\"\n/>\n\n_In
cases besides `APPEND_SEPARATOR`, incorrect keywords produce
syntax\nerrors._\n\n<img width=\"700\" alt=\"Screenshot 2025-03-20 at 2
09
05 PM\"\nsrc=\"https://github.com/user-attachments/assets/de1a23f4-2509-4c6e-84ec-a807e96b65a5\"\n/>\n\n_Didn't
break the `APPEND_SEPARATOR` datatype validation_\n\n<img width=\"791\"
alt=\"Screenshot 2025-03-20 at 2 03
28 PM\"\nsrc=\"https://github.com/user-attachments/assets/169aaa15-52f3-4d22-ab77-26a560cd9359\"\n/>\n\n_Didn't
break `METADATA` fields validation_\n\n### Checklist\n\nCheck the PR
satisfies following conditions. \n\nReviewers should verify this PR
satisfies this list as well.\n\n- [x] Any text added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n###
Background/details\n\nTill now, \"options\" have been a concept in our
code. Their definition\nisn't clear, but it essentially comes down to
any capitalized keyword\nafter the command name. For example `STATS...
>BY<`, `DISSECT...\n>APPEND_SEPARATOR<`. You could think of them as
roughly subcommands or\nsubstatements.\n\nThere was a hope that commands
would be uniform enough that these\n\"options\" would deserve to be
their own special first-class citizen. But\nthey break
conceptually...\n\nFor example `APPEND_SEPARATOR` is not a keyword with
an expression after\nit... it is a variable `APPEND_SEPARATOR=\":\"`...
or filtering in\nstats.... `STATS AVG(bytes) >WHERE<` .... so is WHERE
an option now?\n\n`FORK` will break this even further.\n\nSo, we are
moving the architecture to allow for complexity and variance\namong the
commands. Command-specific logic will have the final say in\nhow
autocomplete and validation work for anything with that
command.","sha":"b7854a8759ca91255fe318c8d7a33b91996bf990","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0"],"title":"[ES|QL]
Remove command option
definitions","number":215425,"url":"https://github.com/elastic/kibana/pull/215425","mergeCommit":{"message":"[ES|QL]
Remove command option definitions (#215425)\n\n## Summary\n\nThis PR
removes the declarative objects that were meant to describe
the\nbehavior of \"options\" (see details section below if you don't
know what\nI'm talking about). **It does not remove \"options\" as a
concept from our\nAST.** \"Option\" is probably the wrong name for the
subcommands in the\nAST but, at the moment, it is working fine how it
is.\n\nHere is a list of what these definitions were being used for and
where I\nended up.\n\n| Use | How it worked | What I did
|\n\n|---------------------------------------------------------------------|---------------|------------|\n|
To generate command declarations for display in suggestions menu |
It\nhad some complex logic to try to construct a declaration string from
the\ninformation in the `signature` property | I replaced this
with\nstatically declared declaration strings on the command
definitions. I\ntook most of them directly from our docs. They are a
better result than\nthe autogenerated stuff |\n| To build the `METADATA`
suggestion | the definition was passed into\n`buildOptionDefinition` | I
declared the `METADATA` suggestion\nstatically in the `FROM`
autocomplete code. |\n| To check for field correctness in `METADATA` |
This logic lived in the\noption definition's `validate` method | I moved
it to the `FROM`\ncommand's validate method |\n| To validate the type of
the value assigned to `APPEND_SEPARATOR` in\n`DISSECT` | This logic
lived in the option definition's `validate`\nmethod | I moved it to the
`DISSECT` command's validate method |\n| To check if the left side of
the equals sign in `DISSECT` is\n\"APPEND_SEPARATOR | In most cases, the
parser catches stuff like this,\nbut for some reason `DISSECT`'s grammar
is very loose so we have been\nstepping in with our own validation
(maybe we should suggest changing\nthis). This was the only case that
was triggering the \"Unknown option\"\nmessage. | I moved it to the
`DISSECT` command's validate method |\n| To prevent default column
validation for `METADATA` | This was the\nonly true use of the
`skipCommonValidation` property which would prevent\nthe validator
trying to find metadata fields in the standard field list\n| I inserted
an option name check directly into the validation code.\nIt's not a good
long-term solution, but it is actually an improvement\nsince the former
code pretended to be general but was actually just for\n`METADATA`. At
least now it is clear what the exception is for. |\n| To filter
functions and operators that are available after `BY` |\nFunction
definitions sometimes declare that they are supported in a
`by`\nstatement. The validator checks if the function does. | This
didn't\nchange. The option nodes in the AST are still there and we are
still\nrelying on the `supportedCommands` and `supportedOptions`
properties in\nthe function definitions. |\n\n#### Pictures\n\n<img
width=\"859\" alt=\"Screenshot 2025-03-20 at 1 47
36 PM\"\nsrc=\"https://github.com/user-attachments/assets/3bd3c3c6-6066-466e-b33b-9444ab58670a\"\n/>\n\n_New,
statically-defined declarations_\n\n<img width=\"783\" alt=\"Screenshot
2025-03-20 at 2 12
28 PM\"\nsrc=\"https://github.com/user-attachments/assets/94550b25-5da9-4c82-9586-11b3515debd7\"\n/>\n\n_In
cases besides `APPEND_SEPARATOR`, incorrect keywords produce
syntax\nerrors._\n\n<img width=\"700\" alt=\"Screenshot 2025-03-20 at 2
09
05 PM\"\nsrc=\"https://github.com/user-attachments/assets/de1a23f4-2509-4c6e-84ec-a807e96b65a5\"\n/>\n\n_Didn't
break the `APPEND_SEPARATOR` datatype validation_\n\n<img width=\"791\"
alt=\"Screenshot 2025-03-20 at 2 03
28 PM\"\nsrc=\"https://github.com/user-attachments/assets/169aaa15-52f3-4d22-ab77-26a560cd9359\"\n/>\n\n_Didn't
break `METADATA` fields validation_\n\n### Checklist\n\nCheck the PR
satisfies following conditions. \n\nReviewers should verify this PR
satisfies this list as well.\n\n- [x] Any text added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n###
Background/details\n\nTill now, \"options\" have been a concept in our
code. Their definition\nisn't clear, but it essentially comes down to
any capitalized keyword\nafter the command name. For example `STATS...
>BY<`, `DISSECT...\n>APPEND_SEPARATOR<`. You could think of them as
roughly subcommands or\nsubstatements.\n\nThere was a hope that commands
would be uniform enough that these\n\"options\" would deserve to be
their own special first-class citizen. But\nthey break
conceptually...\n\nFor example `APPEND_SEPARATOR` is not a keyword with
an expression after\nit... it is a variable `APPEND_SEPARATOR=\":\"`...
or filtering in\nstats.... `STATS AVG(bytes) >WHERE<` .... so is WHERE
an option now?\n\n`FORK` will break this even further.\n\nSo, we are
moving the architecture to allow for complexity and variance\namong the
commands. Command-specific logic will have the final say in\nhow
autocomplete and validation work for anything with that
command.","sha":"b7854a8759ca91255fe318c8d7a33b91996bf990"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215425","number":215425,"mergeCommit":{"message":"[ES|QL]
Remove command option definitions (#215425)\n\n## Summary\n\nThis PR
removes the declarative objects that were meant to describe
the\nbehavior of \"options\" (see details section below if you don't
know what\nI'm talking about). **It does not remove \"options\" as a
concept from our\nAST.** \"Option\" is probably the wrong name for the
subcommands in the\nAST but, at the moment, it is working fine how it
is.\n\nHere is a list of what these definitions were being used for and
where I\nended up.\n\n| Use | How it worked | What I did
|\n\n|---------------------------------------------------------------------|---------------|------------|\n|
To generate command declarations for display in suggestions menu |
It\nhad some complex logic to try to construct a declaration string from
the\ninformation in the `signature` property | I replaced this
with\nstatically declared declaration strings on the command
definitions. I\ntook most of them directly from our docs. They are a
better result than\nthe autogenerated stuff |\n| To build the `METADATA`
suggestion | the definition was passed into\n`buildOptionDefinition` | I
declared the `METADATA` suggestion\nstatically in the `FROM`
autocomplete code. |\n| To check for field correctness in `METADATA` |
This logic lived in the\noption definition's `validate` method | I moved
it to the `FROM`\ncommand's validate method |\n| To validate the type of
the value assigned to `APPEND_SEPARATOR` in\n`DISSECT` | This logic
lived in the option definition's `validate`\nmethod | I moved it to the
`DISSECT` command's validate method |\n| To check if the left side of
the equals sign in `DISSECT` is\n\"APPEND_SEPARATOR | In most cases, the
parser catches stuff like this,\nbut for some reason `DISSECT`'s grammar
is very loose so we have been\nstepping in with our own validation
(maybe we should suggest changing\nthis). This was the only case that
was triggering the \"Unknown option\"\nmessage. | I moved it to the
`DISSECT` command's validate method |\n| To prevent default column
validation for `METADATA` | This was the\nonly true use of the
`skipCommonValidation` property which would prevent\nthe validator
trying to find metadata fields in the standard field list\n| I inserted
an option name check directly into the validation code.\nIt's not a good
long-term solution, but it is actually an improvement\nsince the former
code pretended to be general but was actually just for\n`METADATA`. At
least now it is clear what the exception is for. |\n| To filter
functions and operators that are available after `BY` |\nFunction
definitions sometimes declare that they are supported in a
`by`\nstatement. The validator checks if the function does. | This
didn't\nchange. The option nodes in the AST are still there and we are
still\nrelying on the `supportedCommands` and `supportedOptions`
properties in\nthe function definitions. |\n\n#### Pictures\n\n<img
width=\"859\" alt=\"Screenshot 2025-03-20 at 1 47
36 PM\"\nsrc=\"https://github.com/user-attachments/assets/3bd3c3c6-6066-466e-b33b-9444ab58670a\"\n/>\n\n_New,
statically-defined declarations_\n\n<img width=\"783\" alt=\"Screenshot
2025-03-20 at 2 12
28 PM\"\nsrc=\"https://github.com/user-attachments/assets/94550b25-5da9-4c82-9586-11b3515debd7\"\n/>\n\n_In
cases besides `APPEND_SEPARATOR`, incorrect keywords produce
syntax\nerrors._\n\n<img width=\"700\" alt=\"Screenshot 2025-03-20 at 2
09
05 PM\"\nsrc=\"https://github.com/user-attachments/assets/de1a23f4-2509-4c6e-84ec-a807e96b65a5\"\n/>\n\n_Didn't
break the `APPEND_SEPARATOR` datatype validation_\n\n<img width=\"791\"
alt=\"Screenshot 2025-03-20 at 2 03
28 PM\"\nsrc=\"https://github.com/user-attachments/assets/169aaa15-52f3-4d22-ab77-26a560cd9359\"\n/>\n\n_Didn't
break `METADATA` fields validation_\n\n### Checklist\n\nCheck the PR
satisfies following conditions. \n\nReviewers should verify this PR
satisfies this list as well.\n\n- [x] Any text added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n\n###
Background/details\n\nTill now, \"options\" have been a concept in our
code. Their definition\nisn't clear, but it essentially comes down to
any capitalized keyword\nafter the command name. For example `STATS...
>BY<`, `DISSECT...\n>APPEND_SEPARATOR<`. You could think of them as
roughly subcommands or\nsubstatements.\n\nThere was a hope that commands
would be uniform enough that these\n\"options\" would deserve to be
their own special first-class citizen. But\nthey break
conceptually...\n\nFor example `APPEND_SEPARATOR` is not a keyword with
an expression after\nit... it is a variable `APPEND_SEPARATOR=\":\"`...
or filtering in\nstats.... `STATS AVG(bytes) >WHERE<` .... so is WHERE
an option now?\n\n`FORK` will break this even further.\n\nSo, we are
moving the architecture to allow for complexity and variance\namong the
commands. Command-specific logic will have the final say in\nhow
autocomplete and validation work for anything with that
command.","sha":"b7854a8759ca91255fe318c8d7a33b91996bf990"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
2025-03-24 09:29:55 +01:00
..
build_chromium [8.x] Sustainable Kibana Architecture: Move plugins owned by @elastic/appex-sharedux (#204959) (#205508) 2025-01-05 19:48:48 +00:00
dev-tools [8.x] SKA: Update broken references and URLs (#206836) (#208479) 2025-01-28 10:09:09 +01:00
examples [8.x] [dashboard] clean up dashboard setup and start contracts (#212968) (#214233) 2025-03-13 16:50:15 +00:00
packages [8.x] SKA: Relocate remaining modules (#206103) (#206471) 2025-01-14 08:56:57 +01:00
performance [8.x] SKA: Relocate /test to /src/platform/test (#210956) (#214791) 2025-03-18 14:48:04 +01:00
platform [8.x] [ES|QL] Remove command option definitions (#215425) (#215542) 2025-03-24 09:29:55 +01:00
plugins/fleet [8.x] chore(NA): upgrade to webpack 5 (#191106) (#211146) 2025-02-14 13:36:07 +00:00
scripts [8.x] [Streams] Replay loghub data with synthtrace (#212120) (#214916) 2025-03-19 10:57:02 +01:00
solutions [8.x] initial @kbn/scout-security plugin (#210433) (#215527) 2025-03-23 20:53:00 +02:00
test [8.x] [Lens] fix drag and drop ghost after Chrome update to 134 (#213928) (#214126) 2025-03-22 03:28:56 +02:00
test_serverless [8.x] [Dashboards] Add event-annotation-group to saved object privileges (#212926) (#214877) 2025-03-18 17:17:21 +02:00
.gitignore [8.x] Sustainable Kibana Architecture: Move plugins owned by @elastic/appex-sharedux (#204959) (#205508) 2025-01-05 19:48:48 +00:00
.i18nrc.json [8.x] [Streams 🌊] Remove enablement check in PUT /api/streams/{id} for classic streams (#212289) (#212779) 2025-03-03 09:30:31 +01:00
.telemetryrc.json [8.x] [Core] [Telemetry] Update file references (#205603) (#205752) 2025-01-07 09:47:08 -07:00
package.json chore(NA): bump version to 8.19.0 (#208993) 2025-01-30 22:23:01 +00:00
README.md [8.x] SKA: Relocate "platform" packages that remain on /packages (#208704) (#212474) 2025-02-28 10:12:01 +00:00

Elastic License Functionality

This directory tree contains files subject to the Elastic License 2.0. The files subject to the Elastic License 2.0 are grouped in this directory to clearly separate them from files licensed otherwise.

Alert Details page feature flags (feature-flag-per-App)

If you have:

xpack.observability.unsafe.alertDetails.uptime.enabled: true

[For Uptime rule type] In Kibana configuration, will allow the user to navigate to the new Alert Details page, instead of the Alert Flyout when clicking on View alert details in the Alert table

Development

By default, Kibana will run with X-Pack installed as mentioned in the contributing guide.

Elasticsearch will run with a basic license. To run with a trial license, including security, you can specifying that with the yarn es command.

Example: yarn es snapshot --license trial --password changeme

By default, this will also set the password for native realm accounts to the password provided (changeme by default). This includes that of the kibana_system user which elasticsearch.username defaults to in development. If you wish to specify a password for a given native realm account, you can do that like so: --password.kibana_system=notsecure

Testing

For information on testing, see the Elastic functional test development guide.

Running functional tests

The functional UI tests, the API integration tests, and the SAML API integration tests are all run against a live browser, Kibana, and Elasticsearch install. Each set of tests is specified with a unique config that describes how to start the Elasticsearch server, the Kibana server, and what tests to run against them. The sets of tests that exist today are functional UI tests (specified by this config), API integration tests (specified by this config), and SAML API integration tests (specified by this config).

The script runs all sets of tests sequentially like so:

  • builds Elasticsearch and X-Pack
  • runs Elasticsearch with X-Pack
  • starts up the Kibana server with X-Pack
  • runs the functional UI tests against those servers
  • tears down the servers
  • repeats the same process for the API and SAML API integration test configs.

To do all of this in a single command run:

node scripts/functional_tests

Developing functional UI tests

If you are developing functional tests then you probably don't want to rebuild Elasticsearch and wait for all that setup on every test run, so instead use this command to build and start just the Elasticsearch and Kibana servers:

node scripts/functional_tests_server

After the servers are started, open a new terminal and run this command to run just the tests (without tearing down Elasticsearch or Kibana):

node scripts/functional_test_runner

For both of the above commands, it's crucial that you pass in --config to specify the same config file to both commands. This makes sure that the right tests will run against the right servers. Typically a set of tests and server configuration go together.

Read more about how the scripts work here.

For a deeper dive, read more about the way functional tests and servers work here.

Running API integration tests

API integration tests are run with a unique setup usually without UI assets built for the Kibana server.

API integration tests are intended to test only programmatic API exposed by Kibana. There is no need to run browser and simulate user actions, which significantly reduces execution time. In addition, the configuration for API integration tests typically sets optimize.enabled=false for Kibana because UI assets are usually not needed for these tests.

To run only the API integration tests:

node scripts/functional_tests --config test/api_integration/config

Running SAML API integration tests

We also have SAML API integration tests which set up Elasticsearch and Kibana with SAML support. Run only API integration tests with SAML enabled like so:

node scripts/functional_tests --config test/security_api_integration/saml.config

Running Jest integration tests

Jest integration tests can be used to test behavior with Elasticsearch and the Kibana server.

yarn test:jest_integration

Running Reporting functional tests

See here for more information on running reporting tests.

Running Security Solution Cypress E2E/integration tests

See here for information on running this test suite.