|
| 1 | +# Documentation for ML UI developers |
| 2 | + |
| 3 | +This plugin provides access to the machine learning features from Elastic. |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +To use machine learning features, you must have a Platinum or Enterprise license |
| 8 | +or a free 14-day trial. File Data Visualizer requires a Basic license. For more |
| 9 | +info, refer to |
| 10 | +[Set up machine learning features](https://www.elastic.co/guide/en/machine-learning/master/setup.html). |
| 11 | + |
| 12 | +## Setup local environment |
| 13 | + |
| 14 | +### Kibana |
| 15 | + |
| 16 | +1. Fork and clone the [Kibana repo](https://github.com/elastic/kibana). |
| 17 | + |
| 18 | +1. Install `nvm`, `node`, `yarn` (for example, by using Homebrew). See |
| 19 | + [Install dependencies](https://www.elastic.co/guide/en/kibana/master/development-getting-started.html#_install_dependencies). |
| 20 | + |
| 21 | +1. Make sure that Elasticsearch is deployed and running on localhost:9200. |
| 22 | + |
| 23 | +1. Navigate to the directory of the `kibana` repository on your machine. |
| 24 | + |
| 25 | +1. Fetch the latest changes from the repository. |
| 26 | + |
| 27 | +1. Checkout the branch of the version you want to use. For example, if you want |
| 28 | + to use a 7.9 version, run `git checkout 7.9`. |
| 29 | + |
| 30 | +1. Run `nvm use`. The response shows the Node version that the environment uses. |
| 31 | + If you need to update your Node version, the response message contains the |
| 32 | + command you need to run to do it. |
| 33 | + |
| 34 | +1. Run `yarn kbn bootstrap`. It takes all the dependencies in the code and |
| 35 | + installs/checks them. It is recommended to use it every time when you switch |
| 36 | + between branches. |
| 37 | + |
| 38 | +1. Make a copy of `kibana.yml` and save as `kibana.dev.yml`. (Git will not track |
| 39 | + the changes in `kibana.dev.yml` but yarn will use it.) |
| 40 | + |
| 41 | +1. Provide the appropriate password and user name in `kibana.dev.yml`. |
| 42 | + |
| 43 | +1. Run `yarn start` to start Kibana. |
| 44 | + |
| 45 | +1. Go to http://localhost:560x/xxx (check the terminal message for the exact |
| 46 | + path). |
| 47 | + |
| 48 | +For more details, refer to this [getting started](https://www.elastic.co/guide/en/kibana/master/development-getting-started.html) page. |
| 49 | + |
| 50 | +### Adding sample data to Kibana |
| 51 | + |
| 52 | +Kibana has sample data sets that you can add to your setup so that you can test |
| 53 | +different configurations on sample data. |
| 54 | + |
| 55 | +1. Click the Elastic logo in the upper left hand corner of your browser to |
| 56 | + navigate to the Kibana home page. |
| 57 | + |
| 58 | +1. Click *Load a data set and a Kibana dashboard*. |
| 59 | + |
| 60 | +1. Pick a data set or feel free to click *Add* on all of the available sample |
| 61 | + data sets. |
| 62 | + |
| 63 | +These data sets are now ready be analyzed in ML jobs in Kibana. |
| 64 | + |
| 65 | + |
| 66 | +## Running tests |
| 67 | + |
| 68 | +### Jest tests |
| 69 | + |
| 70 | +Run the test following jest tests from `kibana/x-pack`. |
| 71 | + |
| 72 | +New snapshots, all plugins: |
| 73 | + |
| 74 | +``` |
| 75 | +node scripts/jest |
| 76 | +``` |
| 77 | + |
| 78 | +Update snapshots for the ML plugin: |
| 79 | + |
| 80 | +``` |
| 81 | +node scripts/jest plugins/ml -u |
| 82 | +``` |
| 83 | + |
| 84 | +Update snapshots for a specific directory only: |
| 85 | + |
| 86 | +``` |
| 87 | +node scripts/jest plugins/ml/public/application/settings/filter_lists |
| 88 | +``` |
| 89 | + |
| 90 | +Run tests with verbose output: |
| 91 | + |
| 92 | +``` |
| 93 | +node scripts/jest plugins/ml --verbose |
| 94 | +``` |
| 95 | + |
| 96 | +### Functional tests |
| 97 | + |
| 98 | +Before running the test server, make sure to quit all other instances of |
| 99 | +Elasticsearch. |
| 100 | + |
| 101 | +1. From one terminal, in the x-pack directory, run: |
| 102 | + |
| 103 | + node scripts/functional_tests_server.js --config test/functional/config.js |
| 104 | + |
| 105 | + This command starts an Elasticsearch and Kibana instance that the tests will be run against. |
| 106 | + |
| 107 | +1. In another tab, run the following command to perform API integration tests (from the x-pack directory): |
| 108 | + |
| 109 | + node scripts/functional_test_runner.js --include-tag mlqa --config test/api_integration/config |
| 110 | + |
| 111 | + ML API integration tests are located in `x-pack/test/api_integration/apis/ml`. |
| 112 | + |
| 113 | +1. In another tab, run the following command to perform UI functional tests (from the x-pack directory): |
| 114 | + |
| 115 | + node scripts/functional_test_runner.js --include-tag mlqa |
| 116 | + |
| 117 | + ML functional tests are located in `x-pack/test/functional/apps/ml`. |
| 118 | + |
| 119 | +## Shared functions |
| 120 | + |
| 121 | + |
| 122 | +You can find the ML shared functions in the following files in GitHub: |
| 123 | + |
| 124 | +``` |
| 125 | +https://github.com/elastic/kibana/blob/master/x-pack/plugins/ml/public/shared.ts |
| 126 | +``` |
| 127 | + |
| 128 | +``` |
| 129 | +https://github.com/elastic/kibana/blob/master/x-pack/plugins/ml/server/shared.ts |
| 130 | +``` |
| 131 | + |
| 132 | +These functions are shared from the root of the ML plugin, you can import them with an import statement. For example: |
| 133 | + |
| 134 | +``` |
| 135 | +import { MlPluginSetup } from '../../../../ml/server'; |
| 136 | +``` |
| 137 | + |
| 138 | +or |
| 139 | + |
| 140 | +``` |
| 141 | +import { ANOMALY_SEVERITY } from '../../ml/common'; |
| 142 | +``` |
| 143 | + |
| 144 | +Functions are shared from the following directories: |
| 145 | + |
| 146 | +``` |
| 147 | +ml/common |
| 148 | +ml/public |
| 149 | +ml/server |
| 150 | +``` |
0 commit comments