kibana/x-pack/plugins/transform
Jiawei Wu 092cc0d098
[RAM][Maintenance Window] Add maintenance window solution selection. (#166781)
## Summary
Resolves: https://github.com/elastic/kibana/issues/166301

Adds support for solution/category filtering to maintenance windows by
adding a new property: `category_ids`. Selecting one or more solutions
when creating/updating a maintenance window will cause the maintenance
window to only suppress rule types belonging to said solutions. In order
to achieve filtering by solution/category, we are adding a new field to
the rule types schema called `category`. This field should map to the
feature category that the rule type belongs to (`observability`,
`securitySolution` or `management`).

Our initial plan was to use feature IDs or rule type IDs to accomplish
this filtering, we decided against using rule type IDs because if a new
rule type gets added, we need to change the API to support this new rule
type. We decided against feature IDs because it's a very anti-serverless
way of accomplishing this feature, as we don't want to expose feature
IDs to APIs. We decided on app categories because it works well with
serverless and should be much easier to maintain if new rule types are
added in the future.

This means the `rule_types` API has to be changed to include this new
field, although it shouldn't be a breaking change since we're just
adding a new field. No migrations are needed since rule types are in
memory and maintenance windows are backwards compatible.


![image](d07b05cd-ade8-46a4-a4c0-ab623c31c11b)

### Error state:

![image](b61984b4-c1e1-4e9b-98b4-97a681e977a8)

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [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: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Dima Arnautov <arnautov.dima@gmail.com>
2023-10-02 09:20:53 +01:00
..
common [Transform] Improve loading behavior of Transform if stats takes too long or is not available (#166320) 2023-09-25 10:39:15 -05:00
public [ML] Improves display for long descriptions in transforms (#165149) 2023-09-29 08:10:27 +02:00
server [RAM][Maintenance Window] Add maintenance window solution selection. (#166781) 2023-10-02 09:20:53 +01:00
jest.config.js [jest] update config files to get coverage per plugin (#111299) 2021-09-09 08:14:56 +02:00
kibana.jsonc Make SavedObjectFinder backward compatible (#162904) 2023-08-08 13:10:29 +02:00
readme.md [ML] Add functional tests for reauthorizing transforms (#156699) 2023-05-18 13:24:00 -05:00
tsconfig.json [Transform] Improve loading behavior of Transform if stats takes too long or is not available (#166320) 2023-09-25 10:39:15 -05:00

Documentation for Transforms UI developers

This plugin provides access to the transforms features provided by Elastic.

Requirements

To use the transforms feature, you must have at least a Basic license. For more info, refer to Set up transforms.

Setup local environment

Kibana

  1. Fork and clone the Kibana repo.

  2. Install nvm, node, yarn (for example, by using Homebrew). See Install dependencies.

  3. Make sure that Elasticsearch is deployed and running on localhost:9200.

  4. Navigate to the directory of the kibana repository on your machine.

  5. Fetch the latest changes from the repository.

  6. Checkout the branch of the version you want to use. For example, if you want to use a 7.9 version, run git checkout 7.9. (Your Elasticsearch and Kibana instances need to be the same version.)

  7. Run nvm use. The response shows the Node version that the environment uses. If you need to update your Node version, the response message contains the command you need to run to do it.

  8. Run yarn kbn bootstrap. It takes all the dependencies in the code and installs/checks them. It is recommended to use it every time when you switch between branches.

  9. Make a copy of kibana.yml and save as kibana.dev.yml. (Git will not track the changes in kibana.dev.yml but yarn will use it.)

  10. Provide the appropriate password and user name in kibana.dev.yml.

  11. Run yarn start to start Kibana.

  12. Go to http://localhost:560x/xxx (check the terminal message for the exact path).

For more details, refer to this getting started page.

Adding sample data to Kibana

Kibana has sample data sets that you can add to your setup so that you can test different configurations on sample data.

  1. Click the Elastic logo in the upper left hand corner of your browser to navigate to the Kibana home page.

  2. Click Load a data set and a Kibana dashboard.

  3. Pick a data set or feel free to click Add on all of the available sample data sets.

These data sets are now ready to be used for creating transforms in Kibana.

Running tests

Jest tests

Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing

Run the test following jest tests from `kibana/x-pack/plugins/transform.

New snapshots, all plugins:

yarn test:jest

Update snapshots for the transform plugin:

yarn test:jest -u

Update snapshots for a specific directory only:

yarn test:jest public/app/sections

Run tests with verbose output:

yarn test:jest --verbose

Functional tests

Before running the test server, make sure to quit all other instances of Elasticsearch.

Run the following commands from the x-pack directory and use separate terminals for test server and test runner. The test server command starts an Elasticsearch and Kibana instance that the tests will be run against.

Functional tests are broken up into independent groups with their own configuration. Test server and runner need to be pointed to the configuration to run. The basic commands are

node scripts/functional_tests_server.js --config PATH_TO_CONFIG
node scripts/functional_test_runner.js --config PATH_TO_CONFIG

With PATH_TO_CONFIG and other options as follows.

  1. Functional UI tests with Trial license:

    Group PATH_TO_CONFIG
    creation - index pattern test/functional/apps/transform/creation/index_pattern/config.ts
    creation - runtime mappings, saved searches test/functional/apps/transform/creation/runtime_mappings_saved_search/config.ts
    edit, clone test/functional/apps/transform/edit_clone/config.ts
    feature controls test/functional/apps/transform/feature_controls/config.ts
    permissions test/functional/apps/transform/permissions/config.ts
    actions test/functional/apps/transform/actions/config.ts
  2. Functional UI tests with Basic license:

    Group PATH_TO_CONFIG
    creation - index pattern test/functional_basic/apps/transform/creation/index_pattern/config.ts
    creation - runtime mappings, saved searches test/functional_basic/apps/transform/creation/runtime_mappings_saved_search/config.ts
    edit, clone test/functional_basic/apps/transform/edit_clone/config.ts
    feature controls test/functional_basic/apps/transform/feature_controls/config.ts
    permissions test/functional_basic/apps/transform/permissions/config.ts
    actions test/functional_basic/apps/transform/actions/config.ts
  3. API integration tests with Trial license:

    • PATH_TO_CONFIG: test/api_integration/apis/transform/config.ts
  4. API integration tests with Basic license:

    • PATH_TO_CONFIG: test/api_integration_basic/config.ts
    • Add --include-tag transform to the test runner command
  5. Accessibility tests:

    We maintain a suite of accessibility tests (you may see them referred to elsewhere as a11y tests). These tests render each of our pages and ensure that the inputs and other elements contain the attributes necessary to ensure all users are able to make use of Transforms (for example, users relying on screen readers).

     node scripts/functional_tests_server --config test/accessibility/config.ts
     node scripts/functional_test_runner.js --config test/accessibility/config.ts --grep=transform
    

    Transform accessibility tests are located in x-pack/test/accessibility/apps.