Go to file
Frank Hassanabad 12e7fe50bb
[Security Solutions][Detection Engine] Adds a merge strategy key to kibana.yml and updates docker to have missing keys from security solutions (#103800)
## Summary

This is a follow up considered critical addition to:
https://github.com/elastic/kibana/pull/102280

This adds a key of `xpack.securitySolution.alertMergeStrategy` to `kibana.yml` which allows users to change their merge strategy between their raw events and the signals/alerts that are generated. This also adds additional security keys to the docker container that were overlooked in the past from security solutions.

The values you can use and add to to `xpack.securitySolution.alertMergeStrategy` are:
* missingFields (The default)
* allFields
* noFields

## missingFields

The default merge strategy we are using starting with 7.14 which will merge any primitive data types from the [fields API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#search-fields-param) into the resulting signal/alert. This will copy over fields such as `constant_keyword`, `copy_to`, `runtime fields`, `field aliases` which previously were not copied over as long as they are primitive data types such as `keyword`, `text`, `numeric` and are not found in your original `_source` document. This will not copy copy `geo points`, `nested objects`, and in some cases if your `_source` contains arrays or top level objects or conflicts/ambiguities it will not merge them. This will _not_ merge existing values between `_source` and `fields` for `runtime fields` as well. It only merges missing primitive data types.

## allFields
A very aggressive merge strategy which should be considered experimental. It will do everything `missingFields` does but in addition to that it will merge existing values between `_source` and `fields` which means if you change values or override values with `runtime fields` this strategy will attempt to merge those values. This will also merge in most instances your nested fields but it will not merge `geo` data types due to ambiguities. If you have multi-fields this will choose your default field and merge that into `_source`. This can change a lot your data between your original `_source` and `fields` when the data is copied into an alert/signal which is why it is considered an aggressive merge strategy.

Both these strategies attempts to unbox single array elements when it makes sense and assumes you only want values in an array when it sees them in `_source` or if it sees multiple elements within an array.

## noFields

The behavior before https://github.com/elastic/kibana/pull/102280 was introduced and is a do nothing strategy. This should only be used if you are seeing problems with alerts/signals being inserted due to conflicts and/or bugs for some reason with `missingFields`. We are not anticipating this, but if you are setting `noFields` please reach out to our [forums](https://discuss.elastic.co/c/security/83) and let us know we have a bug so we can fix it. If you are encountering undesired merge behaviors or have other strategies you want us to implement let us know on the forums as well.

The missing keys added for docker are:

*  xpack.securitySolution.alertMergeStrategy
*  xpack.securitySolution.alertResultListDefaultDateRange
*  xpack.securitySolution.endpointResultListDefaultFirstPageIndex
*  xpack.securitySolution.endpointResultListDefaultPageSize
*  xpack.securitySolution.maxRuleImportExportSize
*  xpack.securitySolution.maxRuleImportPayloadBytes
*  xpack.securitySolution.maxTimelineImportExportSize
*  xpack.securitySolution.maxTimelineImportPayloadBytes
*  xpack.securitySolution.packagerTaskInterval
*  xpack.securitySolution.validateArtifactDownloads

I intentionally skipped adding the other `kibana.yml` keys which are considered either experimental flags or are for internal developers and are not documented and not supported in production by us. 

## Manual testing of the different strategies 

First add this mapping and document in the dev tools for basic tests
```json
# Mapping with two constant_keywords and a runtime field
DELETE frank-test-delme-17
PUT frank-test-delme-17
{
  "mappings": {
    "dynamic": "strict",
    "runtime": {
      "host.name": {
        "type": "keyword",
        "script": {
          "source": "emit('changed_hostname')"
        }
      }
    },
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "host": {
        "properties": {
          "name": {
            "type": "keyword"
          }
        }
      },
      "data_stream": {
        "properties": {
          "dataset": {
            "type": "constant_keyword",
            "value": "datastream_dataset_name_1"
          },
          "module": {
            "type": "constant_keyword",
            "value": "datastream_module_name_1"
          }
        }
      },
      "event": {
        "properties": {
          "dataset": {
            "type": "constant_keyword",
            "value": "event_dataset_name_1"
          },
          "module": {
            "type": "constant_keyword",
            "value": "event_module_name_1"
          }
        }
      }
    }
  }
}

# Document without an existing host.name 
PUT frank-test-delme-17/_doc/1
{
  "@timestamp": "2021-06-30T15:46:31.800Z"
}

# Document with an existing host.name
PUT frank-test-delme-17/_doc/2
{
  "@timestamp": "2021-06-30T15:46:31.800Z",
  "host": {
    "name": "host_name"
  }
}

# Query it to ensure the fields is returned with data that does not exist in _soruce
GET frank-test-delme-17/_search
{
  "fields": [
    {
      "field": "*"
    }
  ]
}
```

For all the different key combinations do the following:

Run a single detection rule against the index:
<img width="1139" alt="Screen Shot 2021-06-30 at 9 49 12 AM" src="https://user-images.githubusercontent.com/1151048/123997522-b8dc6600-d98d-11eb-9407-5480d5b2cc8a.png">

Ensure two signals are created:
<img width="1376" alt="Screen Shot 2021-06-30 at 10 26 03 AM" src="https://user-images.githubusercontent.com/1151048/123997739-f17c3f80-d98d-11eb-9eb9-90e9410f0cde.png">

If your `kibana.yml` or `kibana.dev.yml` you set this key (or omit it as it is the default):

```yml
xpack.securitySolution.alertMergeStrategy: 'missingFields'
```

When you click on each signal you should see that `event.module` and `event.dataset` were copied over as well as `data_stream.dataset` and `data_stream.module` since they're `constant_keyword`:
<img width="877" alt="Screen Shot 2021-06-30 at 10 20 44 AM" src="https://user-images.githubusercontent.com/1151048/123997961-31432700-d98e-11eb-96ee-06524f21e2d6.png">

However since this only merges missing fields, you should see that in the first record the `host.name` is the runtime field defined since `host.name` does not exist in `_source` and that in the second record it still shows up as `host_name` since we do not override merges right now:
First:
<img width="887" alt="Screen Shot 2021-06-30 at 10 03 31 AM" src="https://user-images.githubusercontent.com/1151048/123998398-b2022300-d98e-11eb-87be-aa5a153a91bc.png">

Second:
<img width="838" alt="Screen Shot 2021-06-30 at 10 03 44 AM" src="https://user-images.githubusercontent.com/1151048/123998413-b4fd1380-d98e-11eb-9821-d6189190918f.png">

When you set in your `kibana.yml` or `kibana.dev.yml` this key:

```yml
xpack.securitySolution.alertMergeStrategy: 'noFields'
```

Expect that your `event.module`, `event.dataset`, `data_stream.module`, `data_stream.dataset` are all non-existent since we do not copy anything over from `fields` at all and only use things within `_source`:
<img width="804" alt="Screen Shot 2021-06-30 at 9 58 25 AM" src="https://user-images.githubusercontent.com/1151048/123998694-f8578200-d98e-11eb-8d71-a0858d3ed3e7.png">

Expect that `host.name` is missing in the first record and has the default value in the second:

First:
<img width="797" alt="Screen Shot 2021-06-30 at 9 58 37 AM" src="https://user-images.githubusercontent.com/1151048/123998797-10c79c80-d98f-11eb-81b6-5174d8ef14f2.png">

Second:
<img width="806" alt="Screen Shot 2021-06-30 at 9 58 52 AM" src="https://user-images.githubusercontent.com/1151048/123998816-158c5080-d98f-11eb-87a0-0ac2f58793b3.png">

When you set in your `kibana.yml` or `kibana.dev.yml` this key:

```yml
xpack.securitySolution.alertMergeStrategy: 'allFields'
```

Expect that `event.module` and `event.dataset` were copied over as well as `data_stream.dataset` and `data_stream.module` since they're `constant_keyword`:
<img width="864" alt="Screen Shot 2021-06-30 at 10 03 15 AM" src="https://user-images.githubusercontent.com/1151048/123999000-48364900-d98f-11eb-9803-05349744ac10.png">

Expect that both the first and second records contain the runtime field since we merge both of them:
<img width="887" alt="Screen Shot 2021-06-30 at 10 03 31 AM" src="https://user-images.githubusercontent.com/1151048/123999078-58e6bf00-d98f-11eb-83bd-dda6b50fabcd.png">

### Checklist

Delete any items that are not applicable to this PR.

- [x] If a plugin configuration key changed, check if it needs to be allowlisted in the [cloud](https://github.com/elastic/cloud) and added to the [docker list](c29adfef29/src/dev/build/tasks/os_packages/docker_generator/resources/bin/kibana-docker)
2021-06-30 15:50:05 -06:00
.buildkite chore(NA): moving @kbn/ui-shared-deps into bazel (#101669) 2021-06-18 16:09:31 +01:00
.ci [APM-UI][e2e] discard CI builds more often (#102217) 2021-06-16 10:01:43 +01:00
.github Move ES aggregation types to src/core (#102597) 2021-06-21 11:11:15 +01:00
api_docs Update api docs (#103310) 2021-06-29 12:29:58 -04:00
config Add config properties for HTTP security headers (#97158) 2021-04-19 13:12:45 -04:00
dev_docs [dev_docs] add tutorial for setting up a development env (#103566) 2021-06-28 19:44:29 -04:00
docs Update docs to explicitly state supported upgrade version (#103774) 2021-06-30 14:11:59 -07:00
examples Locator docs (#103129) 2021-06-28 21:44:11 +02:00
licenses Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
packages chore(NA): moving @kbn/es-archiver into bazel (#103770) 2021-06-29 23:33:02 -04:00
plugins [dev/cli] ensure plugins/ and all watch source dirs exist (#78973) 2020-09-30 10:20:44 -07:00
rfcs [SoMigV2] Fail fast if unknown document types are present in the source index (#103341) 2021-06-29 20:24:01 +02:00
scripts chore(NA): moving @kbn/spec-to-console into bazel (#103470) 2021-06-28 15:58:41 +01:00
src [Security Solutions][Detection Engine] Adds a merge strategy key to kibana.yml and updates docker to have missing keys from security solutions (#103800) 2021-06-30 15:50:05 -06:00
tasks/config [KQL] Use cache and other performance improvements (#93319) 2021-03-08 10:21:15 -07:00
test [Page layouts] Some light fixes (#103197) 2021-06-29 19:50:15 -05:00
typings Move ES aggregation types to src/core (#102597) 2021-06-21 11:11:15 +01:00
utilities Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
vars [migrations v2] Integration test for multi-node cluster. (#100957) 2021-06-28 12:49:38 -04:00
x-pack [Security Solutions][Detection Engine] Adds a merge strategy key to kibana.yml and updates docker to have missing keys from security solutions (#103800) 2021-06-30 15:50:05 -06:00
.backportrc.json chore(NA): adds 7.14 branch and bumps 7.x on backportrc (#103914) 2021-06-30 18:40:26 +01:00
.bazelignore chore(NA): stop grouping bazel out symlink folders (#96066) 2021-04-01 14:16:14 -05:00
.bazeliskversion chore(NA): bump bazelisk to v1.7.5 (#92905) 2021-02-26 00:48:47 +00:00
.bazelrc chore(NA): manage npm dependencies within bazel (#92864) 2021-03-03 12:37:20 -05:00
.bazelrc.common chore(NA): @kbn/pm new commands to support development on Bazel packages (#96465) 2021-04-12 20:24:19 -04:00
.bazelversion chore(NA): bazel machinery installation on kbn bootstrap (#89469) 2021-01-28 00:51:01 +00:00
.browserslistrc [browserslist] remove unnecessary browsers (#89186) 2021-01-25 16:30:18 -07:00
.editorconfig .editorconfig MDX files should follow the same rules as MD (#96942) 2021-04-13 11:40:42 -04:00
.eslintignore [packages] Move @kbn/interpreter to Bazel (#101089) 2021-06-22 09:59:20 -05:00
.eslintrc.js Add @storybook/testing-react (#103004) 2021-06-28 12:34:43 -05:00
.fossa.yml Adds FOSSA CLI configuration file (#70137) 2020-07-02 08:37:37 -07:00
.gitattributes [canvas] Color fixes + Storybook 5 (#34075) 2019-04-02 11:21:51 -05:00
.gitignore [gitignore] only ignore snapshot.js at the root (#100840) 2021-06-07 13:42:52 -04:00
.i18nrc.json chore(NA): moving @kbn/ui-shared-deps into bazel (#101669) 2021-06-18 16:09:31 +01:00
.node-version Bump Node.js from version 14.16.1 to 14.17.0 (#100314) 2021-05-19 07:36:43 -07:00
.npmrc chore(NA): assure puppeteer_skip_chromium_download is applied across every yarn install situation (#88346) 2021-01-14 18:00:23 +00:00
.nvmrc Bump Node.js from version 14.16.1 to 14.17.0 (#100314) 2021-05-19 07:36:43 -07:00
.prettierignore [dev] Replace sass-lint with stylelint (#86177) 2021-01-15 11:52:29 -06:00
.prettierrc Increase prettier line width to 100 (#20535) 2018-07-09 22:50:37 +02:00
.stylelintignore chore(NA): stop grouping bazel out symlink folders (#96066) 2021-04-01 14:16:14 -05:00
.stylelintrc Amsterdam helpers (#93701) 2021-03-10 10:27:16 -06:00
.telemetryrc.json [Usage collection] Collect non-default kibana configs (#97368) 2021-04-20 11:02:27 -04:00
.yarnrc chore(NA): manage npm dependencies within bazel (#92864) 2021-03-03 12:37:20 -05:00
api-documenter.json
BUILD.bazel chore(NA): moving @kbn/analytics into bazel (#98917) 2021-05-03 22:34:53 +01:00
CODE_OF_CONDUCT.md Add CODE_OF_CONDUCT.md (#87439) 2021-02-23 09:01:51 +01:00
CONTRIBUTING.md Improvements to our developer guide (#67764) 2020-07-13 10:47:01 -04:00
FAQ.md propose language changes (#10709) 2017-03-05 12:10:32 -05:00
github_checks_reporter.json
Gruntfile.js Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
Jenkinsfile [CI] Don't do CI stats reporting/failures for feature branch PRs (#99668) 2021-05-10 16:38:32 -04:00
jest.config.integration.js [packages] Migrate @kbn/test to Bazel (#103122) 2021-06-29 21:16:00 -04:00
jest.config.js Remove /src/legacy (#95510) 2021-04-06 09:25:36 +02:00
kibana.d.ts Remove /src/legacy (#95510) 2021-04-06 09:25:36 +02:00
LICENSE.txt Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
NOTICE.txt [Detections] Adds automatic updating for Prebuilt Security Detection Rules package (#101846) 2021-06-24 15:31:25 -06:00
package.json eui to 34.5.2 (#103896) 2021-06-30 11:33:25 -05:00
preinstall_check.js Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
README.md Fix "Getting started" link in README (#84153) 2020-11-23 15:33:02 -05:00
renovate.json5 Add auto-backport by default to ech renovate bot prs (#102208) 2021-06-16 12:05:56 -05:00
RISK_MATRIX.mdx Add "Risk Matrix" section to the PR template (#100649) 2021-06-02 14:43:47 +02:00
SECURITY.md Add security policy to the Kibana repository (#85407) 2020-12-10 09:26:00 -05:00
STYLEGUIDE.mdx Syntax in styleguide.mdx is breaking docs build (#99840) 2021-05-11 18:06:42 -04:00
tsconfig.base.json fix(NA): windows ts_project outside sandbox compilation (#100947) 2021-06-03 17:53:39 +01:00
tsconfig.browser.json
tsconfig.json [RAC] T-Grid is moving to a new home (#100265) 2021-06-22 18:56:33 -04:00
tsconfig.refs.json [RAC] T-Grid is moving to a new home (#100265) 2021-06-22 18:56:33 -04:00
tsconfig.types.json ui_actions service initial docs (#78902) 2020-09-30 16:44:29 +02:00
TYPESCRIPT.md Fixed grammar (#74725) 2020-08-11 06:40:22 -04:00
WORKSPACE.bazel chore(NA): upgrade bazel rules nodejs to v3.5.1 (#101412) 2021-06-04 19:56:52 +01:00
yarn.lock eui to 34.5.2 (#103896) 2021-06-30 11:33:25 -05:00

Kibana

Kibana is your window into the Elastic Stack. Specifically, it's a browser-based analytics and search dashboard for Elasticsearch.

Getting Started

If you just want to try Kibana out, check out the Elastic Stack Getting Started Page to give it a whirl.

If you're interested in diving a bit deeper and getting a taste of Kibana's capabilities, head over to the Kibana Getting Started Page.

Using a Kibana Release

If you want to use a Kibana release in production, give it a test run, or just play around:

Building and Running Kibana, and/or Contributing Code

You might want to build Kibana locally to contribute some code, test out the latest features, or try out an open PR:

Documentation

Visit Elastic.co for the full Kibana documentation.

For information about building the documentation, see the README in elastic/docs.

Version Compatibility with Elasticsearch

Ideally, you should be running Elasticsearch and Kibana with matching version numbers. If your Elasticsearch has an older version number or a newer major number than Kibana, then Kibana will fail to run. If Elasticsearch has a newer minor or patch number than Kibana, then the Kibana Server will log a warning.

Note: The version numbers below are only examples, meant to illustrate the relationships between different types of version numbers.

Situation Example Kibana version Example ES version Outcome
Versions are the same. 5.1.2 5.1.2 💚 OK
ES patch number is newer. 5.1.2 5.1.5 ⚠️ Logged warning
ES minor number is newer. 5.1.2 5.5.0 ⚠️ Logged warning
ES major number is newer. 5.1.2 6.0.0 🚫 Fatal error
ES patch number is older. 5.1.2 5.1.0 ⚠️ Logged warning
ES minor number is older. 5.1.2 5.0.0 🚫 Fatal error
ES major number is older. 5.1.2 4.0.0 🚫 Fatal error

Questions? Problems? Suggestions?

  • If you've found a bug or want to request a feature, please create a GitHub Issue. Please check to make sure someone else hasn't already created an issue for the same topic.
  • Need help using Kibana? Ask away on our Kibana Discuss Forum and a fellow community member or Elastic engineer will be glad to help you out.