Commit graph

285 commits

Author SHA1 Message Date
Jiawei Wu
ea407983bb
[RAM][Maintenance Window][8.8]Fix window maintenance workflow (#156427)
## Summary

The way that we canceled every notification for our alert life cycle
during an active maintenance window was not close enough to what our
customers were expecting. For our persisted security solution alerts, we
did not have to change the logic because it will always be a new alert.
Therefore, @shanisagiv1, @mdefazio, @JiaweiWu, and @XavierM had a
discussion about this problem and we decided this:

To summarize, we will only keep the notification during a maintenance
window if an alert has been created/active outside of window
maintenance. We created three different scenarios to explain the new
logic and we will make the assumption that our alert has an action per
status change. For you to understand the different scenarios, I created
this legend below:
<img width="223" alt="image"
src="https://user-images.githubusercontent.com/189600/236045974-f4fa379b-db5e-41f8-91a8-2689b9f24dab.png">

### Scenario I
If an alert is active/created before a maintenance window and recovered
inside of the maintenance window then we will send notifications
<img width="463" alt="image"
src="https://user-images.githubusercontent.com/189600/236046473-d04df836-d3e6-42d8-97be-8b4f1544cc1a.png">

### Scenario II
If an alert is active/created and recovered inside of window maintenance
then we will NOT send notifications
<img width="407" alt="image"
src="https://user-images.githubusercontent.com/189600/236046913-c2f77131-9ff1-4864-9dab-89c4c429152e.png">

### Scenario III
if an alert is active/created in a maintenance window and recovered
outside of the maintenance window then we will not send notifications
<img width="496" alt="image"
src="https://user-images.githubusercontent.com/189600/236047613-e63efe52-87fa-419e-9e0e-965b1d10ae18.png">


### Checklist
- [ ] [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: Xavier Mouligneau <xavier.mouligneau@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-05-04 17:11:26 -07:00
Andrew Macri
3389a2b35b
[Security Solution] fixes Data Quality dashboard errors when a basePath is configured (#156233)
## [Security Solution] fixes Data Quality dashboard errors when a `basePath` is configured

This PR implements a fix for an [issue](https://github.com/elastic/kibana/issues/156231) where the Data Quality dashboard displays errors when  a `basePath` is configured, preventing indices from being checked.

### Desk testing

- Verify the fix per the reporduction steps in <https://github.com/elastic/kibana/issues/156231>
- Also verify the page still behaves correctly when Kibana is started with no base path, via:

```
yarn start --no-base-path
```

### Before / after screenshots

**Before:**

![before](https://user-images.githubusercontent.com/4459398/235273609-952fd7e4-0a22-4344-b1e4-48411c6d0e33.png)

_Above: Before the fix, errors occur when a `basePath` is configured_

**After:**

![after](https://user-images.githubusercontent.com/4459398/235276257-c62feb05-699a-418c-8da2-b90b6683e5b4.png)

_Above: After the fix, errors do NOT occur_
2023-05-04 12:24:39 -07:00
Dima Arnautov
a3fad62c34
[ML] AIOps: Change point detection fixes (#156481) 2023-05-03 18:31:03 +02:00
Konrad Szwarc
d8fe39c18d
[Defend Workflows][Bug] Case flyout z-index (#153219)
Fixes https://github.com/elastic/security-team/issues/6228

5000 `z-index` set in `create-case-flyout-mask-overlay` is being
overwritten by `euiOverlayMask-belowHeader` with a value of 1000. This
causes **Case flyout** to be under the already opened **Osquery flyout**

This PR includes cleanup in flyouts renders - we removed unnecessary
`maskProps` as well as z-indexes that were explicitly set even though
flyout component manages them itself.


![test](https://user-images.githubusercontent.com/29123534/225292177-a08d3fb8-aad3-487b-a054-6cde6aec94d7.gif)

---------

Co-authored-by: Tomasz Ciecierski <ciecierskitomek@gmail.com>
Co-authored-by: Tomasz Ciecierski <tomasz.ciecierski@elastic.co>
Co-authored-by: Patryk Kopyciński <contact@patrykkopycinski.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-05-03 12:30:13 +02:00
Walter Rafelsberger
385d0dc84a
[ML] Package @kbn/ml-anomaly-utils (#155697)
Creates Package `@kbn/ml-anomaly-utils`.

- This moves some of the utility functions, constants and types related
to Anomaly Detection we previously exposed from the `ml` plugin itself
to a package `@kbn/ml-anomaly-utils`, resulting in ~5.9KB reduction of
the plugin's page load bundle size.
- To reduce increases in async bundle size for consuming plugins the
utils have been refactored into individual files to allow deep imports
and get some optimization through that. Some previously duplicated code
in consuming plugins has been deleted and replaced with deep imports of
the corresponding original code in the package.
- Types have been prefixed with `Ml`.
- Constants have been prefixed with `ML_`.

Created package via `node scripts/generate package @kbn/ml-anomaly-utils
--web --dir ./x-pack/packages/ml/anomaly_utils`.
2023-05-03 08:46:27 +02:00
Dima Arnautov
3cd35494ab
[ML] Rename ELSER model id (#156382) 2023-05-02 09:09:46 -07:00
Marco Liberati
ca780c526a
[Lens] New random sampling shared plugin (#155068)
## Summary

A new plugin to share the Random sampling logic across Kibana apps.
As starting point it contains the Random Sampling Icon + the setting
slider.

<img width="788" alt="Screenshot 2023-04-18 at 11 03 36"
src="https://user-images.githubusercontent.com/924948/232743718-9fad0308-9c21-4bd7-901f-9634ac3486ad.png">

### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] 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>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
2023-05-02 10:30:46 +02:00
Dima Arnautov
bf64874b4c
[ML] ELSER config in the Trained Models UI (#155867) 2023-04-27 08:16:17 +02:00
Sergi Massaneda
202f13f7be
[SecuritySolution] Refactor security packages (#155365)
## Summary

closes: https://github.com/elastic/kibana/issues/155301

Moves _packages/security-solution/_ to
_x-pack/packages/security-solution/_
Moves _x-pack/packages/kbn-securitysolution-*_ into the new
_x-pack/packages/security-solution/_

It contains 3 packages now:
- data_view/
- ecs_data_quality_dashboard/
- side_nav/

Package names and ids have not changed.

## Other

- eslint configured for all the packages in the directory
- i18n prefix `securitySolutionPackages` configured for all packages in
the directory
- generic storybook configuration, run with: `yarn storybook
security_solution_packages`

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-04-26 05:05:36 -07:00
Karl Godard
672e9925b0
[Session View] Fixes to slow process event queries + xterm.js updated. (#155326)
## Summary

Issue: https://github.com/elastic/kibana/issues/155183

This PR improves the process_events_route and io_event_route queries. We
now pass in the index and **process.entry_leader.start** time to greatly
improve the loading time of session view. Prior to this change, we were
doing a cross cluster search across the entire
logs-endpoint.events.process datastream. Session view will now use the
index from the entry leader event to limit the scope of the query. It
also ensures a range query is added with the entry leader start time, to
prevent data prior to the session from being hit.

I've also updated the npm package for xterm.js which addresses this
renovate ticket: https://github.com/elastic/kibana/pull/147815

### 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] [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
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-04-25 09:25:01 -07:00
Andrew Macri
67322fe2a7
[Security Solution] Data Quality dashboard storage metrics (#155581)
# [Security Solution] Data Quality dashboard storage metrics

![storage_metrics_animated](https://user-images.githubusercontent.com/4459398/233871314-6894b380-63ac-4622-b64f-965752a96019.gif)

_Above: The new storage metrics treemap updates as indices are checked_

![storage_metrics](https://user-images.githubusercontent.com/4459398/233880225-8242733a-4bd6-40b3-bffa-e283ce0d77cd.png)

_Above: Storage metrics in the Data Quality dashboard_

## Summary

This PR introduces [storage metrics](https://github.com/elastic/security-team/issues/6047) to the _Data Quality_ dashboard

- Multiple views are enhanced to display the size of indices

- A new interactive treemap visualizes the relative sizes of indices

- Markdown reports include the size of indices

- The Data Quality dashboard `Beta` tag is removed

- Inline action buttons replace the `Take action` popover

- The Global stats panel remains visible when the `Select one or more ILM phases` help is displayed

- Code coverage is improved throughout the dashboard

## Details

### Multiple views enhanced to display the size of indices

The following views have been enhanced to display the `Size` of indices, per the screenshots below:

- The pattern table's `Size` column displays the size of a single index

![04_size_column](https://user-images.githubusercontent.com/4459398/233870161-d86eadbd-9f01-4ed6-aa6f-98f6044a4f57.png)

- The pattern table's `Size` tooltip

![05_size_column_tooltip](https://user-images.githubusercontent.com/4459398/233868732-08059ba9-5e4b-4f68-a152-eb4b41db6f96.png)

- The pattern rollup's `Size` stat displays the total size of indices in a pattern

![06_pattern_rollups_size](https://user-images.githubusercontent.com/4459398/233868817-babc96eb-c0aa-4b7f-bb45-54e3039d06f2.png)

- The pattern rollup's `Size` stat tooltip

![07_pattern_rollups_size_tooltip](https://user-images.githubusercontent.com/4459398/233868858-14a43aa2-324f-40bd-a185-1cb7ac15c81b.png)

- The global stats rollup `Size` stat displays the total size of all the patterns

![08_global_stats_rollup_size](https://user-images.githubusercontent.com/4459398/233868900-e3cbc00b-3b5a-4756-8246-cb31a1b8bac8.png)

- The global stats rollup `Size` stat tooltip

![09_global_stats_rollup_size_tooltip](https://user-images.githubusercontent.com/4459398/233868952-b9c27432-c8a4-4ad5-9dda-5e1aa903758c.png)

### New interactive treemap

A new interactive treemap visualizes the relative sizes of indices:

- The color of indices in the treemap and its legend update as the data is checked

![storage_metrics_animated](https://user-images.githubusercontent.com/4459398/233871314-6894b380-63ac-4622-b64f-965752a96019.gif)

- Clicking on an index in the treemap or the legend expands (and scrolls to) the index

### Markdown reports include the `Size` of indices

Markdown reports are enhanced to include the new `Size` statistic in:

- Pattern markdown tables

| Result | Index | Docs | Incompatible fields | ILM Phase | Size |
|--------|-------|------|---------------------|-----------|------|
|  | auditbeat-7.14.2-2023.04.09-000001 | 48,077 (4.3%) | 12 | `hot` | 41.3MB |
|  | auditbeat-7.3.2-2023.04.09-000001 | 48,068 (4.3%) | 8 | `hot` | 31MB |
|  | auditbeat-7.11.2-2023.04.09-000001 | 48,064 (4.3%) | 12 | `hot` | 40.8MB |

- Pattern rollup markdown tables

| Incompatible fields | Indices checked | Indices | Size | Docs |
|---------------------|-----------------|---------|------|------|
| 164 | 26 | 26 | 899.3MB | 1,118,155 |

- The global stats markdown table

| Incompatible fields | Indices checked | Indices | Size | Docs |
|---------------------|-----------------|---------|------|------|
| 166 | 32 | 32 | 9.2GB | 20,779,245 |

### Data Quality dashboard `Beta` tag removed

The Data Quality dashboard `Beta` tag is removed from the following views:

- The `Dashboards` page

**Before:**

![11_dashboards_before](https://user-images.githubusercontent.com/4459398/233869434-d4d2ed14-4e6f-4eab-bae6-a9c9b976e20f.png)

**After:**

![12_dashboards_after](https://user-images.githubusercontent.com/4459398/233869088-9dc62d7d-44cb-46cb-8880-976a7b7e9c56.png)

- Security Solution side navigation

**Before:**

![13_side_navigation_before](https://user-images.githubusercontent.com/4459398/233869467-e7725285-1199-40e1-ac65-054bea8b02f6.png)

**After:**

![14_side_navigation_after](https://user-images.githubusercontent.com/4459398/233869146-7b89cb47-3509-478e-8675-9f1653749b18.png)

- The Data Quality dashboard page header

**Before:**

![15_page_header_before](https://user-images.githubusercontent.com/4459398/233869404-0b04c2ec-3d2e-4ba8-9520-68013f80e43a.png)

**After:**

![16_page_header_after](https://user-images.githubusercontent.com/4459398/233869219-b54ee61e-07b7-470d-a668-b4f5ed4327e6.png)

### Inline action buttons replace the `Take action` popover

Inline `Add to new case` and `Copy to clipboard` action buttons replace the `Take action` popover, the previous home of these actions:

**Before:**

![17_actions_before](https://user-images.githubusercontent.com/4459398/233869306-0182145f-affc-4ad1-b63f-72e43d34234c.png)

**After:**

![18_actions_after](https://user-images.githubusercontent.com/4459398/233869345-754b7448-9d28-4253-9186-5b2389acf4ff.png)

### Global stats panel remains visible when the `Select one or more ILM phases` help is displayed

The Global stats panel now remains visible when the `Select one or more ILM phases` help is displayed:

**Before:**

![19_select_ilm_phases_before](https://user-images.githubusercontent.com/4459398/233869754-2067fa5d-7153-407b-aa45-65332b16bc7a.png)

**After:**

![20_select_ilm_phases_after](https://user-images.githubusercontent.com/4459398/233869762-38d069de-3191-4e28-8692-df42ab3b21a5.png)

### Code coverage improvements

Code coverage is improved throughout the dashboard, as measured by running the following command:

```sh
node scripts/jest --watch x-pack/packages/kbn-ecs-data-quality-dashboard --coverage
```
2023-04-24 19:27:58 -07:00
Walter Rafelsberger
d6d933a2af
[ML] Moves shared code to @kbn/ml-error-utils. (#155372)
- Moves code from `x-pack/plugins/ml/common/util/errors` that was shared
via `x-pack/plugins/ml/public/shared.ts` to `@kbn/ml-error-utils`.
- `data_visualizer` and `aiops` plugins now use that package instead of
code duplication.
2023-04-22 09:25:37 +02:00
Walter Rafelsberger
0283b7abd3
[ML] AIOps: Adds execution context to client side data.search requests (#154891)
Part of https://github.com/elastic/kibana/issues/147378. This PR adds
context information to data.search requests so that they appear in the
search slow log.
2023-04-19 15:51:31 +02:00
Walter Rafelsberger
47f0eb8803
[ML] @kbn/ml-random-sampler-utils: Fix random sampler threshold (#154803)
Fixes the check `isValidProbability` to include `0.5`.
2023-04-18 17:01:36 +02:00
Walter Rafelsberger
5b1b15af7a
[ML] AIOps: Fix race condition where stale url state would reset search bar. (#154885)
Fixes an issue there the global state `_g` and app state `_a` would get
out of sync and overwrite each other. For example, a click on Refresh in
the date picker (global state) could reset the search bar (app state) to
empty.

The issue was that in `x-pack/packages/ml/url_state/src/url_state.tsx`
the `searchString` could become a stale value in `setUrlState`. This PR
fixes it by using the approach already used in `usePageUrlState`: The
`searchString` is passed on to be stored via `useRef` so that the
`setUrlState` setter can always access the most recent value.
2023-04-18 15:17:49 +02:00
Coen Warmer
c75863385d
Use Observability Page Template from Observability Shared in APM and Profiling (#154776)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-04-18 11:03:44 +02:00
Luke
153994d810
[Security Solution] Move datatable to package (#150899)
## Summary

[Related issue](https://github.com/elastic/kibana/issues/150603)

This PR extracts the DataTableComponent, related redux infrastructure
and some helpers into standalone package.

### Checklist

Delete any items that are not applicable to this PR.

- [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: Sergi Massaneda <sergi.massaneda@elastic.co>
2023-04-17 21:02:28 +02:00
James Gowdy
c34dae2a0e
[ML] Creating number utils package for roundToDecimalPlace function (#154910)
`roundToDecimalPlace` is used in ML and data visualiser packages and
soon aiops, so this PR moves it to a shared package.
2023-04-13 10:53:37 -07:00
Walter Rafelsberger
eb7db09da8
[ML] Explain Log Rate Spikes: Adds table action to copy filter to clipboard (#154311)
- Adds an action to the analysis results filter to copy a KUERY filter
for each row to the clipboard.
- Consolidates duplicate code for the Discover action into a custom
hook.
2023-04-13 17:27:21 +02:00
Walter Rafelsberger
ab277e4cb4
[ML] Explain Log Rate Spikes: Support to filter fields from grouping (#153864)
- Adds a `Filter fields` popover selector inspired by EUI's data grid
column picker to toggle inclusion of fields into grouping.
- Moves the `Group results` switch and the `Filter fields` popover on
the same level as the progress controls.
- Adapts the `explain_log_rate_spikes` API endpoint to support
retrieving a grouping update only.
- Hides the pagination footer for the results tables if there's less
results than the current page size.
2023-04-11 20:24:27 +02:00
Walter Rafelsberger
239a981a10
[ML] Random sampler utils package (#154520)
- Refactors individual helpers to manage the `random_sampler`
aggregation into a single reusable wrapper. The helper's factory can be
supplied with either a sample probability right away or a document count
to generate a dynamic sample probability based on it.
- Applies random sampling to the main date histogram chart.
2023-04-11 17:50:06 +02:00
Maryam Saeidi
7dba0145ac
[AO] Add alert time range annotation for metric threshold (#154440)
Resolves #153851

## Summary

This PR adds alert time range annotation for the metric threshold rule
details page.


![image](https://user-images.githubusercontent.com/12370520/230080136-434bb586-c00e-4f36-aa11-525a38f8a650.png)
**Note**
I changed the rule criteria to stop the alert, hence the weird graph!

## 🧪 How to test
1. Add `xpack.observability.unsafe.alertDetails.metrics.enabled: true`
to the Kibana config
2. Generate a metric threshold alert
3. Go to the related alert details page and check the annotation
2023-04-06 00:33:53 +02:00
Quynh Nguyen (Quinn)
ab1ac1b25d
[ML] Enhance support for counter fields in data visualizer / field statistics (#153893)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-04-04 17:14:25 -05:00
Quynh Nguyen (Quinn)
234d92df97
[ML] Add better support for counter fields in Transform (#154171)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-04-04 10:36:40 -07:00
Maryam Saeidi
6350e146fa
[AO] Metric threshold alert details - custom time range and alert start annotation (#153954)
Closes #153202, closes #153850

## Summary

This PR adds alert start annotation and also uses a custom time range
for the alert details' charts depending on the alert duration. The logic
to calculate the time range was added in a separate package to be used
in other use cases as well.


![image](https://user-images.githubusercontent.com/12370520/228583927-bf90cc13-53d5-4824-9b3b-ed6e6ffd06f5.png)

## 🧪 How to test

Create a metric threshold alert and go to the related alert details
page, verify:
- Alert start annotation
- The time range of the charts should be before the alert was started
(1/8 of the duration was added to each side)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-04-04 09:08:27 -07:00
James Gowdy
30dbbd05f8
[ML] Adding trained models utils package (#154046)
Creates a package for sharing general trained model util code.
Initially only contains the constants which had been copied in the
enterprise search plugin.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-04-03 08:15:42 -07:00
Patrick Mueller
cd727fa190
[ResponseOps] move alert UUID generation from rule registry to the alerting framework (#143489)
resolves https://github.com/elastic/kibana/issues/142874

The alerting framework now generates an alert UUID for every alert it
creates. The UUID will be reused for alerts which continue to be active
on subsequent runs, until the alert recovers. When the same alert (alert
instance id) becomes active again, a new UUID will be generated. These
UUIDs then identify a "span" of events for a single alert.

The rule registry plugin was already adding these UUIDs to it's own
alerts-as-data indices, and that code has now been changed to make use
of the new UUID the alerting framework generates.

- adds property in the rule task state
`alertInstances[alertInstanceId].meta.uuid`; this is where the alert
UUID is persisted across runs
- adds a new `Alert` method getUuid(): string` that can be used by rule
executors to obtain the UUID of the alert they just retrieved from the
factory; the rule registry uses this to get the UUID generated by the
alerting framework
- for the event log, adds the property `kibana.alert.uuid` to
`*-instance` event log events; this is the same field the rule registry
writes into the alerts-as-data indices
- various changes to tests to accommodate new UUID data / methods
- migrates the UUID previous stored with lifecycle alerts in the alert
state, via the rule registry *INTO* the new `meta.uuid` field in the
existing alert state.
2023-04-03 09:19:48 -04:00
Walter Rafelsberger
33599ad414
[ML] Transforms: Adding execution context to ES requests. (#153649)
Part of https://github.com/elastic/kibana/issues/147378

- Similar to #148746, adds execution context to transform API endpoints.
- Moves `createExecutionContext` to package `@kbn/ml-route-utils`.
2023-03-31 17:19:18 +02:00
renovate[bot]
005ba61af6
Update dependency @elastic/charts to v54 (main) (#151759)
Closes https://github.com/elastic/kibana/issues/149681

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@elastic/charts](https://togithub.com/elastic/elastic-charts) |
[`53.1.0` ->
`54.0.0`](https://renovatebot.com/diffs/npm/@elastic%2fcharts/53.1.0/54.0.0)
|
[![age](https://badges.renovateapi.com/packages/npm/@elastic%2fcharts/54.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/@elastic%2fcharts/54.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/@elastic%2fcharts/54.0.0/compatibility-slim/53.1.0)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/@elastic%2fcharts/54.0.0/confidence-slim/53.1.0)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>elastic/elastic-charts</summary>

###
[`v54.0.0`](https://togithub.com/elastic/elastic-charts/blob/HEAD/CHANGELOG.md#&#8203;5400-httpsgithubcomelasticelastic-chartscomparev5311v5400-2023-03-09)

[Compare
Source](https://togithub.com/elastic/elastic-charts/compare/v53.1.1...v54.0.0)

##### Bug Fixes

- **annotation:** render annotations correctly based on passed handlers
([#&#8203;1971](https://togithub.com/elastic/elastic-charts/issues/1971))
([4bdedff](4bdedff5a9))
- **deps:** update dependency
[@&#8203;elastic/eui](https://togithub.com/elastic/eui) to v75
([#&#8203;1964](https://togithub.com/elastic/elastic-charts/issues/1964))
([cf886f5](cf886f5278))
- **deps:** update dependency
[@&#8203;elastic/eui](https://togithub.com/elastic/eui) to v76
([#&#8203;1987](https://togithub.com/elastic/elastic-charts/issues/1987))
([89dc8a1](89dc8a1cd9))
- **flamegraph:** show tooltip prompt only if pinnable
([#&#8203;1967](https://togithub.com/elastic/elastic-charts/issues/1967))
([1a13d80](1a13d80af7))
- **heatmap:** Expose axis title as debug data
([#&#8203;1970](https://togithub.com/elastic/elastic-charts/issues/1970))
([0a998a5](0a998a55fb))
- **partition:** allow custom sorting for the legend items
([#&#8203;1959](https://togithub.com/elastic/elastic-charts/issues/1959))
([1afa2c4](1afa2c401f))
- **partition:** render legend items with zero values
([#&#8203;1956](https://togithub.com/elastic/elastic-charts/issues/1956))
([a85d1ae](a85d1ae4c0))
- **xy:** respect `integersOnly` prop on axis component
([#&#8203;1958](https://togithub.com/elastic/elastic-charts/issues/1958))
([93f5497](93f549728e))

##### BREAKING CHANGES

- **partition:** The `Layer.fillColor` function now accepts the
following signature: `(key: Key, sortIndex: number, node: ArrayNode,
tree: HierarchyOfArrays) => string;` This exposes a similar set of
information but allows us more control over the internals to
define/generate the legend. The legend for pie/donut/mosaic/treemap
charts is sorted in a hierarchical way even if the legend is flat.
The default highlight strategy used to highlight partition elements when
hovering over the legend item has been changed to `LegendStrategy.Path`.

####
[53.1.1](https://togithub.com/elastic/elastic-charts/compare/v53.1.0...v53.1.1)
(2023-02-10)

##### Bug Fixes

- **partition:** tooltip item series identifier
([#&#8203;1957](https://togithub.com/elastic/elastic-charts/issues/1957))
([06d8b5d](06d8b5dc0c))

###
[`v53.1.1`](https://togithub.com/elastic/elastic-charts/blob/HEAD/CHANGELOG.md#&#8203;5311-httpsgithubcomelasticelastic-chartscomparev5310v5311-2023-02-10)

[Compare
Source](https://togithub.com/elastic/elastic-charts/compare/v53.1.0...v53.1.1)

##### Bug Fixes

- **partition:** tooltip item series identifier
([#&#8203;1957](https://togithub.com/elastic/elastic-charts/issues/1957))
([06d8b5d](06d8b5dc0c))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/elastic/kibana).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNDguMCIsInVwZGF0ZWRJblZlciI6IjM1LjkuMCJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Marco Vettorello <marco.vettorello@elastic.co>
2023-03-28 12:48:54 -04:00
Walter Rafelsberger
04c4c0632b
[ML] Explain Log Rate Spikes: Improve grouping using the include option of the frequent_item_sets agg. (#153091)
- Makes use of the `filter` option for the `frequent_item_sets`
aggregation introduced in `8.7.0`
(https://github.com/elastic/elasticsearch/pull/92414).
- Several fixes to grouping code, esp. around detection of multiple
non-overlapping groups.
- Improved which items of a group to display in the summary. Previously,
up to 15 items that were unique to a group were displayed. Related to
the above mentioned improvement it would mean that for groups that had
no unique items then no items would show up in the summary. Now we sort
items by duplicates and doc count ascending (a sort of "uniqueness"
score) and show up to 5 items of those.
- The Group button code has been simplified.
2023-03-23 10:58:19 +01:00
Jason Stoltzfus
c339ca8394
Upgraded EUI to v76.0.0 (#152506)
👋 Hi all - the biggest breaking change of this PR is around two icon
type changes/renames.

1. ⚠️ **The  `alert` icon is now named `warning`**
- <img width="103" alt=""
src="https://user-images.githubusercontent.com/549407/223561599-8913e88c-676f-47cd-aaed-81b64783bd81.png"
align="middle">
- This change should have been automatically converted on your behalf by
the EUI team, **but if for some reason** we missed making this
conversion in this PR and your icon(s) are now broken, please ping us or
let us know in this PR (or fix yourself after this PR merges).
- In some cases, teams were using this icon for error messages,
alongside the `danger` color. In those cases, we opinionatedly changed
those icon usages to the new `error` icon instead of using the old
alert/warning icon.

2. 🛑 **The `crossInACircleFilled` icon has been removed, and a new
`error` icon added**
- <img width="84" alt=""
src="https://user-images.githubusercontent.com/549407/223561892-4406bdf6-1a55-49ac-85ad-3a11eb7c090d.png"
align="middle">
- The conversion for this breaking change was not straightforward. This
was the path we used to determine what to change `crossInACircleFilled`
usages to:
- If the icon was associated with errors or error messages, we changed
it to the new `error` icon.
- If a "delete" action was associated with this icon, we changed it to
the `trash` icon instead.
- If a "clear" action was associated with this icon, we changed it to
just the `cross` icon, or in some cases `minusInCircleFilled` (if used
alongside `plusInCircleFilled`).
- Again, if we made a mistake during this conversion or missed your
plugin, please feel free to ping us.

## Summary

`eui@75.1.2`  `eui@76.0.2`

## [`76.0.2`](https://github.com/elastic/eui/tree/v76.0.2)

**Bug fixes**

- Added a legacy `alert` alias for the `warning` `EuiIcon` type
([#6640](https://github.com/elastic/eui/pull/6640))

## [`76.0.1`](https://github.com/elastic/eui/tree/v76.0.1)

**Bug fixes**

- Fixed broken icons on all `isInvalid` form controls
([#6629](https://github.com/elastic/eui/pull/6629))

## [`76.0.0`](https://github.com/elastic/eui/tree/v76.0.0)

- Added `pivot` glyph to `EuiIcon`
([#6605](https://github.com/elastic/eui/pull/6605))
- Added the `displayHeaderCellProps` API to `EuiDataGrid`'s columns,
which allows passing custom props directly to column header cells
([#6609](https://github.com/elastic/eui/pull/6609))
- Added the new `headerCellProps`/`footerCellProps` APIs to
`EuiDataGrid`'s control columns, which allows passing custom props
directly to control column header or footer cells
([#6609](https://github.com/elastic/eui/pull/6609))
- Added a new `footerCellRender` API to `EuiDataGrid`'s control columns,
which allows completely customizing control column rendering (previously
rendered an empty cell)
([#6609](https://github.com/elastic/eui/pull/6609))
- Updated the styling of nested ordered lists in `EuiText` to align with
GitHub's list style, which is a popular format used in Markdown or MDX
formatting ([#6615](https://github.com/elastic/eui/pull/6615))
- Added a margin-bottom property exclusively to the direct child `ul`
and `ol` elements of the `EuiText` component
([#6615](https://github.com/elastic/eui/pull/6615))
- Fix issue with badges appearing within an `EuiBadgeGroup`, where the
CSS rule to override the `margin-inline-start` was not being applied
correctly due to the order of appearance in the CSS rules
([#6618](https://github.com/elastic/eui/pull/6618))

**Bug fixes**

- Fixed `EuiDataGrid` footer control columns rendering with cell
expansion popovers when they should not have been
([#6609](https://github.com/elastic/eui/pull/6609))
- Fixed an `EuiSkipLink` bug where main content loading in
progressively/dynamically after the skip link rendered was not being
correctly focused ([#6613](https://github.com/elastic/eui/pull/6613))

**Breaking changes**

- Renamed `EuiIcon`'s `alert` to `warning`
([#6608](https://github.com/elastic/eui/pull/6608))
- Removed `EuiIcon`'s `crossInACircleFilled` in favor of `error`
([#6608](https://github.com/elastic/eui/pull/6608))

---------

Co-authored-by: Davey Holler <daveyholler@hey.com>
Co-authored-by: Constance Chen <constance.chen@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Jon <jon@elastic.co>
2023-03-14 14:27:40 -05:00
Walter Rafelsberger
74fb6b0928
[ML] AIOps: Fix use full data button when time range returns null. (#152889)
In certain cases the endpoint to get the full date range may return `{
start: null, end: null }`, for example when querying against a
frozen-only index but with the option enabled to exclude the frozen
tier. In AIOps we added a callback to push that information to the URL's
global state but that would corrupt then the global state with the page
crashing.

This PR fixes it with an update to `setFullTimeRange`. The function will
now only return the time range if it's fully populated. After that, the
`FullTimeRangeSelector` component will only call the callback if it
receives such a time range and will skip the callback if
`setFullTimeRange` returned `undefined`.

Jest unit tests for `setFullTimeRange` and `FullTimeRangeSelector` have
been updated/created to cover both cases with populated time ranges and
without.
2023-03-10 16:58:05 +01:00
Walter Rafelsberger
e70c4f97f4
[ML] AIOps: Rename change point references in Explain Log Rate Spikes to significant term (#152597)
Quite some code and comments referred to `change points` in the Explain
Log Rate Spikes code. However, the underlying aggregation to get the
corresponding data is based on the `significant_terms` aggregation. The
naming mismatch was originally introduced when porting code from Python
prototypes that included this naming.

To avoid confusion with the recently introduced actual "Change Point
Detection" feature, this PR renames references to changes points in the
Explain Log Rate Spikes code to refer to significant terms.

Note this was only referenced like this in code and comments, no wording
in the UI was used that referred to "Change Points" in the Explain Log
Rate Spikes feature.
2023-03-08 10:35:58 +01:00
Walter Rafelsberger
1b9b77fd12
[ML] Fix regression to skip considering future data on use full data button in ML plugin. (#152435)
Fixes a regression where the "Use full data" button in the ML plugin
would no longer avoid considering future data.
2023-03-02 11:47:24 +01:00
Andrew Macri
c71860000d
[Security Solution] Data Quality: Updates the presentation of incompatible fields in the same family / custom fields (#151571)
## [Security Solution] Data Quality: Updates the presentation of incompatible fields in the same family / custom fields

This PR updates the presentation of incompatible fields in the same family, and the presentation of custom fields, as detailed in <https://github.com/elastic/security-team/issues/6046>

### Updates to the presentation of incompatible fields in the same family

Indices created by older versions of integrations or Beats may have mappings flagged as incompatible with the latest version of ECS, because their types don't exactly match, but their mappings are in the same _type family_.

The `Field data types` documentation <https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html> introduces the concept of type families:

> Field types are grouped by _family_. Types in the same family have exactly the same search behavior but may have different space usage or performance characteristics.

In this PR, the Data Quality dashboard:

- Still flags a field as incompatible when the `ECS mapping type (expected)` doesn't exactly match the `Index mapping type (actual)`
- Applies a different visual treatment to incompatible fields in the same family (in the table of results, and in markdown)
- Has revised content in the `Incompatible fields` tab's callout (and exported markdown), to include the concept of families

### Updates to the presentation of custom fields

It's perfectly OK to add custom fields to an index. This PR updates the presentation of the `Custom fields` tab callout to remove potentially confusing descriptions.

The official `ECS Reference Overview` documentation <https://www.elastic.co/guide/en/ecs/current/ecs-reference.html> states:

> ECS is a permissive schema. If your events have additional data that cannot be mapped to ECS, you can simply add them to your events, using custom field names.

In this PR, the Data Quality dashboard:

- Has revised content in the `Custom fields` tab's callout (and exported markdown), to remove potentially confusing descriptions, and convey the permissive nature of ECS.

## Visual guide to the changes

### Visual Guide: Updates to the presentation of incompatible fields in the same family

The following screenshot illustrates the OLD behavior of the `Incompatable fields` tab:

![exact_matching](https://user-images.githubusercontent.com/4459398/219443483-03b891ae-aad0-4098-b88e-229725e65604.png)

In the screenshot of the OLD behavior above:

- When the `ECS mapping type (expected)` doesn't exactly match the `Index mapping type (actual)`, the field is counted as incompatible
- All results in the expanded index are styled with red ("eui danger") styles

The following new screenshot is marked up to show things that are (still) the SAME in the new behavior:

![things_that_stayed_the_same_20230217](https://user-images.githubusercontent.com/4459398/219804049-c18bcf8e-0b9a-4b9f-aed8-268b417e4aa8.png)

The screenshot of the NEW behavior above illustrates what remains the SAME:

- When the `ECS mapping type (expected)` doesn't exactly match the `Index mapping type (actual)`, the field is **still** flagged as incompatible
- The total counts of `Incompatible fields` in the pattern summary, table, and tabs are still the same
- The `Incompatible fields` callout has the same `Fields are incompatible with ECS when...` description, and items with an 
- The same fields in the OLD behavior that were flagged as incompatible are still being flagged

The following new screenshot is marked up to show things that are DIFFERENT:

![things_that_are_different_20230217](https://user-images.githubusercontent.com/4459398/219805550-193074d2-155c-4bae-822c-ae41f9571a39.png)

The screenshot of the NEW behavior above illustrates what's DIFFERENT:

- The title of the `Incompatible fields` callout has been updated to include a count of fields with mappings in the same family, e.g. `12 incompatible fields, 11 fields with mappings in the same family`
- The callout as been updated to include new content, which incorporates families
- The results in the expanded index are styled with yellow ("eui warning") styles, when the index type is in the same family
- The results in the expanded index also have a new `same family` badge, when the index type is in the same family

The following new screenshot illustrates that fields in the `Index mapping type (actual)` column still have the same red / "eui danger" styling, (and no badge), when they are not in the same family as the `ECS mapping type (expected)`:

![no_mappings_in_the_same_family_2023_0217](https://user-images.githubusercontent.com/4459398/219808700-40ea3b77-ce41-477c-a326-b4e90d8365ee.png)

This following screenshot is a side-by-side comparison between the Data Quality dashboard and the markdown created by the `Add to new case` and `Copy to clipboard` actions, to illustrate that it includes the changes made to the dashboard itself:

![incompatible_fields_markdown_updated_20230217](https://user-images.githubusercontent.com/4459398/219811354-f64515a0-01cd-48ce-99b0-d62a757006b4.png)

### Visual Guide: Updates to the presentation of custom fields

The following screenshot illustrates the OLD content of the `Custom fields` tab's callout:

![custom_fields_before](https://user-images.githubusercontent.com/4459398/219501783-297ec50c-627b-4c85-8aad-78ee46497143.png)

The following screenshot illustrates the NEW content of the `Custom fields` tab's callout:

![custom_fields_after](https://user-images.githubusercontent.com/4459398/219503486-f7938e72-1570-4b5c-8fc6-3b5fa3e141cd.png)

This following screenshot is a side-by-side comparison between the Data Quality dashboard and the markdown created by the  `Copy to clipboard` action, to illustrate that it includes the changes made to the dashboard itself:

![custom_fields_markdown_updated_20230217](https://user-images.githubusercontent.com/4459398/219815766-40743c80-c51f-4498-b87a-b80d5646926c.png)
2023-02-21 12:33:51 -07:00
Walter Rafelsberger
07d1adfb14
[ML] Date Picker: Fix to not trigger use full data button when changing frozen setting. (#151673)
Previously, when changing the frozen tier settings in the popover menu
of the date picker, this would also trigger an action like you were
clicking on the "Use full data" button at the same time. This PR fixes
the behavior and only updates the frozen tier settings, to update the
time range you now have to click "Use full data" separately.
2023-02-21 16:59:23 +01:00
Andrew Macri
49d7a2540d
[Security Solution] Fixes Data Quality dashboard integration issues (#151071)
## [Security Solution] Fixes Data Quality dashboard integration issues

This PR implements fixes for the following issues observed during integration testing:

- [[Security Solution] Data Quality dashboard: read Docs count from primaries.docs.count](https://github.com/elastic/kibana/issues/151061) `issue 151061`
- [[Security Solution] Display a Remote clusters won't be checked message, and remove the text read_cross_cluster from error messages](https://github.com/elastic/kibana/issues/151063) `issue 151063`
- This PR also updates the `getFieldTypes` function to fix an issue where, (for example), a field named `some.field.keyword` would be expanded as `some.field.fields.keyword`.

### Desk testing

- See the details of the issues above for reproduction / desk testing steps
2023-02-14 08:41:07 -05:00
Spencer
1b85815402
[packages] migrate all plugins to packages (#148130)
Fixes https://github.com/elastic/kibana/issues/149344

This PR migrates all plugins to packages automatically. It does this
using `node scripts/lint_packages` to automatically migrate
`kibana.json` files to `kibana.jsonc` files. By doing this automatically
we can simplify many build and testing procedures to only support
packages, and not both "packages" and "synthetic packages" (basically
pointers to plugins).

The majority of changes are in operations related code, so we'll be
having operations review this before marking it ready for review. The
vast majority of the code owners are simply pinged because we deleted
all `kibana.json` files and replaced them with `kibana.jsonc` files, so
we plan on leaving the PR ready-for-review for about 24 hours before
merging (after feature freeze), assuming we don't have any blockers
(especially from @elastic/kibana-core since there are a few core
specific changes, though the majority were handled in #149370).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-02-08 21:06:50 -06:00
Dima Arnautov
c8b75b3b72
[ML] Adds change point detection feature (#150308)
## Summary

Part of #145703, adding enhancements to the new Change Point Detection
page for technical preview under the AIOps Labs section in the ML
plugin.

<img width="1406" alt="image"
src="https://user-images.githubusercontent.com/5236598/217035513-86325cd9-17a9-46ed-8aea-77585038a427.png">

- Use the data bounds mode for the Y-axis 
- Add a cardinality check for the split field with a hard limit of
10,000
-  Show series labels above charts 
- Replace fields `select` controls with the `EuiComboBox`
- Add a filter for change point type 
- Display aggregation interval 
- Add a docs link to the Change Point Aggregation 
- Make split field optional 

### Checklist


- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
2023-02-07 12:51:02 -07:00
Andrew Macri
1d0b90bd12
[Security Solution] Data Quality dashboard (#150063)
# [Security Solution] Data Quality dashboard

## Check ECS compatibility with just one click

With just one click, the _Data Quality dashboard_ checks all the indices used by the Security Solution, (or anything else), for compatibility with the [Elastic Common Schema (ECS)](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html)

![checking_data_quality](https://user-images.githubusercontent.com/4459398/215989195-2f5e2126-9ece-4df6-9742-284c73442962.gif)

## Create cases from results

Create a single case containing all the results, or create cases for specific indices

![create_case_from_take_action](https://user-images.githubusercontent.com/4459398/215989342-4489cf68-69d1-4ac4-859c-d849c4778d68.gif)

## Interactive tabs put results in context

Expand any index to reveal interactive tabs

- Summary
- Incompatible fields
- Custom fields
- ECS complaint fields
- All fields

![tabs](https://user-images.githubusercontent.com/4459398/215989435-a363a9e5-8635-42d1-a0f7-5e0ddc6f9515.gif)

## Share comprehensive markdown reports

Share markdown reports containing the same content as the dashboard

![markdown_report](https://user-images.githubusercontent.com/4459398/215989555-72c53ed8-99f9-4be7-9181-6b9f365a8f6e.gif)

### On page load

When the Data Quality dashboard page loads, the alerts index, and any indices matching the selected `Data view` are displayed

![page_load](https://user-images.githubusercontent.com/4459398/215989957-3b4d52f1-eaa4-4d42-9e40-d556602b006b.png)

Only `hot`, `warm`, or `unmanaged` indices are displayed by default

Indices are not checked automatically when the dashboard loads

Click either :

- `Check all` to check all the indices on the page
- The expand button to automatically check (just) one index, and instantly view results

### Check all

When the `Check all` button is clicked

- The `Check all` button changes to a `Cancel` button
- The `Last checked: n <time unit> ago` text is replaced with a progress bar indicating how many Indices are left to check
- The `Checking <index name>` text will update as each index is checked. Text will wrap if necessary
- The results tables begin updating with results
- Pattern stats update to summarize each table
- Rolled up results for the entire page update after every index is checked

![running_before_errors](https://user-images.githubusercontent.com/4459398/215990059-43efd573-217f-47e8-8ed2-1b1de4766834.png)

<https://user-images.githubusercontent.com/4459398/216007795-2ebbc0c6-8c7a-49c7-a22c-b97d2a58dddd.mov>

When Check all, is running, the Data Quality dashboard adds a three second delay after every check completes, before beginning the next check.

Check all will keep checking indexes until the user cancels, or all indexes have (attempted to be) checked.

While Check all is running, users may simultaneously click on any index to check it on demand. The results are instantly rolled up when this happens.

When all checks complete, the page looks like this:

![all_results_no_errors](https://user-images.githubusercontent.com/4459398/215990208-b28e1ad4-d8fd-453b-a037-1123c4352469.png)

### Take action

Click the `Take action` popover to share the entire page of results via one of the following actions:

- Add to new case
- Copy to clipboard

![take_action_popover](https://user-images.githubusercontent.com/4459398/215990971-fff06bf3-cac5-418f-83fc-556caa4b9413.png)

![create_case_from_take_action](https://user-images.githubusercontent.com/4459398/216012412-812f7b84-94a7-462a-8574-2e05afa35efd.gif)

![copy_toast](https://user-images.githubusercontent.com/4459398/215992498-c83b9191-8226-4ab1-8170-1bc953083f5c.png)

### Expanding results

The `Incompatible fields` tab is always displayed by default when a result is expanded

The `Incompatible fields` tab shows a success message when a successful result is expanded

![incompatible_fields_zero](https://user-images.githubusercontent.com/4459398/215991201-2ff7158e-1787-4221-b2de-d7e5ee49c412.png)

The `Incompatible fields` tab shows, side by side, expected ECS mapping types vs the actual mapping types when they are different

![mapping_differences](https://user-images.githubusercontent.com/4459398/215990436-82bb969e-fab7-4f2b-97f1-f21fd5bc3641.png)

The `Incompatible fields` tab also compares field values expected by ECS vs the actual values in an index, when they are different

![expect_vs_actual_value](https://user-images.githubusercontent.com/4459398/215990341-2c5ce75b-03cc-4b72-9431-282dfd032844.png)

The `Incompatible fields` tab displays a callout that explains the consequences of having incompatible fields. The content is based on the following illustration, created by @MikePaquette

<img width="1264" alt="ecs_meter" src="https://user-images.githubusercontent.com/4459398/216016124-6fe89ab4-c364-40ec-8a6f-99349e6d583c.png">

The calllout has a call to action to create a case or copy a markdown report for just the expanded result

- Add to new case
- Copy to clipboard

![create_case_from_incompatable_fields_tab](https://user-images.githubusercontent.com/4459398/215990827-57506e26-06e3-4704-afb4-4bd8308b217a.png)

### Tabs

The Summary tab displays a call to action when incompatible fields are found

Click on any part of the Summary tab chart or legend to navigate to the corresponding tab

![summary_tab](https://user-images.githubusercontent.com/4459398/215990517-41e96cab-558a-4461-a34a-e149873841a4.png)

Clicking on the `Copy to clipboard` call to action in the Custom fields tab copies a markdown version of the table to the clipboard

![custom_fields_tab](https://user-images.githubusercontent.com/4459398/215990623-8c787d11-cf93-4321-a803-2133c81fcd1b.png)

The search feature of the ECS complaint fields tab may, for example, be used to verify a specific ECS complaint mapping exists

![ecs_complaint_fields_tab](https://user-images.githubusercontent.com/4459398/215990703-dc0b93b3-a3ed-447b-96c5-714d71f4177d.png)

The All fields tab displays the union of all other tabs

![all_fields_tab](https://user-images.githubusercontent.com/4459398/215990746-88eb8812-7a00-47f4-94fc-5105aad024c1.png)

### Data view selection

The `Data view` dropdown defaults to the `Security Default Data View`

![data_view_selection](https://user-images.githubusercontent.com/4459398/216020987-d710aa85-5ddc-4fa1-9a3f-c131e656da56.png)

The alerts index is always checked and included in the results, even when another Data View is selected

![alerts_index_always_included](https://user-images.githubusercontent.com/4459398/216022004-4a6adb46-5bc1-4619-ad46-7364d7565e3a.png)

### ILM phase options

![ilm_selection](https://user-images.githubusercontent.com/4459398/216023010-c3bb9e3e-9aec-487b-8757-e4736c06de7e.png)

Only `hot`, `warm`, or `unmanaged` indices may be selected for checking.

The `cold` and `frozen` options are disabled.

When all options in the `ILM phase` box are cleared, an informative empty prompt is displayed

![ilm_empty_prompt](https://user-images.githubusercontent.com/4459398/216029584-659fafda-92fb-4607-b61e-87aa3f0b45e8.png)

### Errors

Errors may occur for some (or all) indices. The `View errors` button appears when the first error occurs

![running_with_errors](https://user-images.githubusercontent.com/4459398/216024230-609ec815-e2e4-408f-b9a5-d12aad9f83c5.png)

Users may click the `View errors` button to view them, even while a check is in progress

![error_popover](https://user-images.githubusercontent.com/4459398/216755446-210996d8-605b-4d6b-8c90-cf94dc83a76b.png)

The Copy to clipboard button  in the errors popover copies a markdown version of the errors table to the clipboard

When errors occur, the same content shown in the Errors popover is automatically included in the markdown report created by the `Take action` menu

### Markdown reports

The content of markdown reports (created by the Take action menu) includes most of the content from the Data Quality dashboard that created it

In the screenshot below, the Data Quality dashboard is on the left, and a markdown report (pasted into Github) is on the right

![side_by_side_compare_1](https://user-images.githubusercontent.com/4459398/216026602-7cf7aaaa-b461-44e0-a03e-6690e3d87d3c.png)

Stats rollups and tables are included in markdown reports

![side_by_side_2](https://user-images.githubusercontent.com/4459398/216026872-d5319279-e4b2-4ac0-b291-06dc61ba108c.png)

Markdown reports use the same "expected vs actual" format to display the details of incompatible field mappings

### Navigation

The Data Quality dashboard is grouped with the existing Security Solution dashboards

![dashboards_page](https://user-images.githubusercontent.com/4459398/216057432-0ae99d57-4857-4270-bd7d-07bc96e27cb0.png)

It may also be launched via the side navigation

![side_nav](https://user-images.githubusercontent.com/4459398/216057528-2370b82a-dc92-4ea6-8519-7e8abc61acd0.png)

## Privileges

The privileges in the table below are required to check any pattern of indices, or any specific index:

| Privilege                                         | Required to                                                                                                                       | Required for API |
|-------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|------------------|
| `monitor` or `manage`  (`manage` builds on `monitor`) | List indices that match a pattern, and get document counts for an index  example: `GET logs-*/_stats`                             | `_stats`         |
| `view_index_metadata` or `manage_ilm`                 | List index ILM configs (e.g. hot) that match a pattern  example: `GET logs-*/_ilm/explain`                                        | `_ilm/explain`   |
| `view_index_metadata` or `manage`                     | Get index mappings for a specific index  example:  `GET .ds-logs-endpoint.events.process-default-2023.01.17-000001/_mapping`      | `_mapping`       |
| `read` or `read_cross_cluster`                        | Run aggregations to test for unallowed values  example:  `GET .ds-logs-endpoint.events.process-default-2023.01.17-000001/_search` | `_search`        |

Users may have some of the privileges required to check an index, but not all of them.

The built-in `viewer` role does not have the `monitor` (or `manage`) role. The following screenshot illustrates what a user will see if they login as a user with the `viewer` role:

![login_with_viewer_role](https://user-images.githubusercontent.com/4459398/216755590-b6c01a7b-73b1-4680-8db1-b9d1c0035f06.png)

# An actual markdown report (all content below)

The rest of the content below is pasted from an actual report, created via the `Take action` menu:

# Data quality

| Incompatible fields | Indices checked | Indices | Docs |
|---------------------|-----------------|---------|------|
| 17 | 15 | 17 | 1,404,514 |

## .alerts-security.alerts-default

`hot(1)`

| Incompatible fields | Indices checked | Indices | Docs |
|---------------------|-----------------|---------|------|
| 1 | 1 | 1 | 1,837 |

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .internal.alerts-security.alerts-default-000001 | 1,837 (100.0%) | 1 | `hot` |

### .internal.alerts-security.alerts-default-000001

The `.internal.alerts-security.alerts-default-000001` index has [mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) or field values that are different than the [Elastic Common Schema](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html) (ECS), version `8.6.0` [definitions](https://www.elastic.co/guide/en/ecs/current/ecs-field-reference.html).

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .internal.alerts-security.alerts-default-000001 | 1,837 (100.0%) | 1 | `hot` |

### **Incompatible fields** `1` **Custom fields** `188` **ECS compliant fields** `1219` **All fields** `1408`

#### 1 incompatible field

Fields are incompatible with ECS when index mappings, or the values of the fields in the index, don't conform to the Elastic Common Schema (ECS), version 8.6.0.

 Detection engine rules referencing these fields may not match them correctly
 Pages may not display some events or fields due to unexpected field mappings or values
 Mappings or field values that don't comply with ECS are not supported

#### Incompatible field values - .internal.alerts-security.alerts-default-000001

| Field | ECS values (expected) | Document values (actual) |
|-------|-----------------------|--------------------------|
| event.category | `authentication`, `configuration`, `database`, `driver`, `email`, `file`, `host`, `iam`, `intrusion_detection`, `malware`, `network`, `package`, `process`, `registry`, `session`, `threat`, `vulnerability`, `web` | `behavior` (62) |

## auditbeat-*

`hot(11)`  `unmanaged(1)`

| Incompatible fields | Indices checked | Indices | Docs |
|---------------------|-----------------|---------|------|
| 13 | 10 | 12 | 29,182 |

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-auditbeat-8.6.0-2023.01.17-000001 | 14,409 (49.4%) | 0 | `hot` |
| -- | .ds-auditbeat-8.5.3-2023.01.24-000001 | 2,857 (9.8%) | -- | `hot` |
|  | .ds-auditbeat-8.2.3-2023.01.24-000001 | 2,246 (7.7%) | 0 | `hot` |
|  | .ds-auditbeat-8.4.1-2023.01.24-000001 | 2,179 (7.5%) | 0 | `hot` |
| -- | .ds-auditbeat-8.3.3-2023.01.24-000001 | 1,921 (6.6%) | -- | `hot` |
|  | auditbeat-7.16.0-2023.01.17-000001 | 1,880 (6.4%) | 0 | `hot` |
|  | .ds-auditbeat-8.1.1-2023.01.24-000001 | 1,676 (5.7%) | 0 | `hot` |
|  | .ds-auditbeat-8.2.2-2023.01.24-000001 | 1,578 (5.4%) | 0 | `hot` |
|  | .ds-auditbeat-8.0.0-2023.01.24-000001 | 251 (0.9%) | 0 | `hot` |
|  | auditbeat-7.10.2-2023.01.24-000001 | 111 (0.4%) | 12 | `hot` |
|  | .ds-auditbeat-8.5.0-2023.01.24-000001 | 74 (0.3%) | 0 | `hot` |
|  | auditbeat-custom-empty-index-1 | 0 (0.0%) | 1 | `unmanaged` |

### .ds-auditbeat-8.6.0-2023.01.17-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-auditbeat-8.6.0-2023.01.17-000001 | 14,409 (49.4%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `549` **ECS compliant fields** `1210` **All fields** `1759`

### .ds-auditbeat-8.2.3-2023.01.24-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-auditbeat-8.2.3-2023.01.24-000001 | 2,246 (7.7%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `510` **ECS compliant fields** `1210` **All fields** `1720`

### .ds-auditbeat-8.4.1-2023.01.24-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-auditbeat-8.4.1-2023.01.24-000001 | 2,179 (7.5%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `509` **ECS compliant fields** `1210` **All fields** `1719`

### auditbeat-7.16.0-2023.01.17-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | auditbeat-7.16.0-2023.01.17-000001 | 1,880 (6.4%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `523` **ECS compliant fields** `1111` **All fields** `1634`

### .ds-auditbeat-8.1.1-2023.01.24-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-auditbeat-8.1.1-2023.01.24-000001 | 1,676 (5.7%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `510` **ECS compliant fields** `1204` **All fields** `1714`

### .ds-auditbeat-8.2.2-2023.01.24-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-auditbeat-8.2.2-2023.01.24-000001 | 1,578 (5.4%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `510` **ECS compliant fields** `1210` **All fields** `1720`

### .ds-auditbeat-8.0.0-2023.01.24-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-auditbeat-8.0.0-2023.01.24-000001 | 251 (0.9%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `510` **ECS compliant fields** `1204` **All fields** `1714`

### auditbeat-7.10.2-2023.01.24-000001

The `auditbeat-7.10.2-2023.01.24-000001` index has [mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) or field values that are different than the [Elastic Common Schema](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html) (ECS), version `8.6.0` [definitions](https://www.elastic.co/guide/en/ecs/current/ecs-field-reference.html).

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | auditbeat-7.10.2-2023.01.24-000001 | 111 (0.4%) | 12 | `hot` |

### **Incompatible fields** `12` **Custom fields** `467` **ECS compliant fields** `602` **All fields** `1081`

#### 12 incompatible fields

Fields are incompatible with ECS when index mappings, or the values of the fields in the index, don't conform to the Elastic Common Schema (ECS), version 8.6.0.

 Detection engine rules referencing these fields may not match them correctly
 Pages may not display some events or fields due to unexpected field mappings or values
 Mappings or field values that don't comply with ECS are not supported

#### Incompatible field mappings - auditbeat-7.10.2-2023.01.24-000001

| Field | ECS mapping type (expected) | Index mapping type (actual) |
|-------|-----------------------------|-----------------------------|
| error.message | `match_only_text` | `text` |
| error.stack_trace | `wildcard` | `keyword` |
| http.request.body.content | `wildcard` | `keyword` |
| http.response.body.content | `wildcard` | `keyword` |
| message | `match_only_text` | `text` |
| process.command_line | `wildcard` | `keyword` |
| process.parent.command_line | `wildcard` | `keyword` |
| registry.data.strings | `wildcard` | `keyword` |
| url.full | `wildcard` | `keyword` |
| url.original | `wildcard` | `keyword` |
| url.path | `wildcard` | `keyword` |

#### Incompatible field values - auditbeat-7.10.2-2023.01.24-000001

| Field | ECS values (expected) | Document values (actual) |
|-------|-----------------------|--------------------------|
| event.kind | `alert`, `enrichment`, `event`, `metric`, `state`, `pipeline_error`, `signal` | `error` (1) |

### .ds-auditbeat-8.5.0-2023.01.24-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-auditbeat-8.5.0-2023.01.24-000001 | 74 (0.3%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `509` **ECS compliant fields** `1210` **All fields** `1719`

### auditbeat-custom-empty-index-1

The `auditbeat-custom-empty-index-1` index has [mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) or field values that are different than the [Elastic Common Schema](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html) (ECS), version `8.6.0` [definitions](https://www.elastic.co/guide/en/ecs/current/ecs-field-reference.html).

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | auditbeat-custom-empty-index-1 | 0 (0.0%) | 1 | `unmanaged` |

### **Incompatible fields** `1` **Custom fields** `0` **ECS compliant fields** `0` **All fields** `0`

#### 1 incompatible field

Fields are incompatible with ECS when index mappings, or the values of the fields in the index, don't conform to the Elastic Common Schema (ECS), version 8.6.0.

 Detection engine rules referencing these fields may not match them correctly
 Pages may not display some events or fields due to unexpected field mappings or values
 Mappings or field values that don't comply with ECS are not supported

#### Incompatible field mappings - auditbeat-custom-empty-index-1

| Field | ECS mapping type (expected) | Index mapping type (actual) |
|-------|-----------------------------|-----------------------------|
| @timestamp | `date` | `-` |

## logs-*

`hot(2)`

| Incompatible fields | Indices checked | Indices | Docs |
|---------------------|-----------------|---------|------|
| 3 | 2 | 2 | 602 |

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-logs-endpoint.alerts-default-2023.01.17-000001 | 342 (56.8%) | 2 | `hot` |
|  | .ds-logs-endpoint.events.process-default-2023.01.17-000001 | 260 (43.2%) | 1 | `hot` |

### .ds-logs-endpoint.alerts-default-2023.01.17-000001

The `.ds-logs-endpoint.alerts-default-2023.01.17-000001` index has [mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) or field values that are different than the [Elastic Common Schema](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html) (ECS), version `8.6.0` [definitions](https://www.elastic.co/guide/en/ecs/current/ecs-field-reference.html).

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-logs-endpoint.alerts-default-2023.01.17-000001 | 342 (56.8%) | 2 | `hot` |

### **Incompatible fields** `2` **Custom fields** `857` **ECS compliant fields** `675` **All fields** `1534`

#### 2 incompatible fields

Fields are incompatible with ECS when index mappings, or the values of the fields in the index, don't conform to the Elastic Common Schema (ECS), version 8.6.0.

 Detection engine rules referencing these fields may not match them correctly
 Pages may not display some events or fields due to unexpected field mappings or values
 Mappings or field values that don't comply with ECS are not supported

#### Incompatible field mappings - .ds-logs-endpoint.alerts-default-2023.01.17-000001

| Field | ECS mapping type (expected) | Index mapping type (actual) |
|-------|-----------------------------|-----------------------------|
| process.env_vars | `keyword` | `object` |

#### Incompatible field values - .ds-logs-endpoint.alerts-default-2023.01.17-000001

| Field | ECS values (expected) | Document values (actual) |
|-------|-----------------------|--------------------------|
| event.category | `authentication`, `configuration`, `database`, `driver`, `email`, `file`, `host`, `iam`, `intrusion_detection`, `malware`, `network`, `package`, `process`, `registry`, `session`, `threat`, `vulnerability`, `web` | `behavior` (45) |

### .ds-logs-endpoint.events.process-default-2023.01.17-000001

The `.ds-logs-endpoint.events.process-default-2023.01.17-000001` index has [mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) or field values that are different than the [Elastic Common Schema](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html) (ECS), version `8.6.0` [definitions](https://www.elastic.co/guide/en/ecs/current/ecs-field-reference.html).

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-logs-endpoint.events.process-default-2023.01.17-000001 | 260 (43.2%) | 1 | `hot` |

### **Incompatible fields** `1` **Custom fields** `130` **ECS compliant fields** `304` **All fields** `435`

#### 1 incompatible field

Fields are incompatible with ECS when index mappings, or the values of the fields in the index, don't conform to the Elastic Common Schema (ECS), version 8.6.0.

 Detection engine rules referencing these fields may not match them correctly
 Pages may not display some events or fields due to unexpected field mappings or values
 Mappings or field values that don't comply with ECS are not supported

#### Incompatible field mappings - .ds-logs-endpoint.events.process-default-2023.01.17-000001

| Field | ECS mapping type (expected) | Index mapping type (actual) |
|-------|-----------------------------|-----------------------------|
| process.env_vars | `keyword` | `object` |

## packetbeat-*

`hot(2)`

| Incompatible fields | Indices checked | Indices | Docs |
|---------------------|-----------------|---------|------|
| 0 | 2 | 2 | 1,372,893 |

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-packetbeat-8.6.0-2023.01.17-000001 | 704,062 (51.3%) | 0 | `hot` |
|  | .ds-packetbeat-8.4.1-2023.01.24-000001 | 668,831 (48.7%) | 0 | `hot` |

### .ds-packetbeat-8.6.0-2023.01.17-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-packetbeat-8.6.0-2023.01.17-000001 | 704,062 (51.3%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `604` **ECS compliant fields** `1209` **All fields** `1813`

### .ds-packetbeat-8.4.1-2023.01.24-000001

| Result | Index | Docs | Incompatible fields | ILM Phase |
|--------|-------|------|---------------------|-----------|
|  | .ds-packetbeat-8.4.1-2023.01.24-000001 | 668,831 (48.7%) | 0 | `hot` |

### **Incompatible fields** `0` **Custom fields** `604` **ECS compliant fields** `1209` **All fields** `1813`

## Errors

Some indices were not checked for Data Quality

Errors may occur when pattern or index metadata is temporarily unavailable, or because you don't have the privileges required for access

The following privileges are required to check an index:
- `monitor` or `manage`
- `view_index_metadata`
- `read` or `read_cross_cluster`


| Pattern | Index | Error | 
|---------|-------|-------|
| .alerts-security.alerts-default | -- | `Error loading stats: Error: Forbidden` |
| auditbeat-* | -- | `Error loading stats: Error: Forbidden` |
| logs-* | -- | `Error loading stats: Error: Forbidden` |
| packetbeat-* | -- | `Error loading stats: Error: Forbidden` |

See also: https://github.com/elastic/security-team/issues/4559
2023-02-06 21:10:43 -07:00
Walter Rafelsberger
05d04ce1e0
[ML] Consolidate query_utils into package @kbn/ml-query-utils (#149224)
Consolidates more `query_utils` into package `@kbn/ml-query-utils`.
2023-01-24 13:07:43 +01:00
Walter Rafelsberger
2a57862668
[ML] Fix responsive behaviour of page header with date picker (#149073)
Improve responsive behaviour of page header with date picker.
- Removes custom breakpoint based code to determine date picker width
and instead use it's native `width` option.
- Adds a `flexGroup` boolean toggle to be able to get back the flex
items only without the flex group if you want to embed the date picker
in an already existing flex group to avoid additional nesting.
- Sets the `fill` option of the refresh button to `false` to avoid the
dark blue "primary".
- In the `aiops` plugin and the `ml_page.tsx` component, migrates away
from EUI's deprecated components for the page layout.
- Adds a `min-width` to page titles to avoid narrow wrapping (e.g.
wrapping after each character on narrow screens).
2023-01-23 13:55:29 +01:00
Melissa Alvarez
16d69653a0
[ML] AIOps: highlight pairs unique to groups in expanded row (#148601)
## Summary

Related meta issue: https://github.com/elastic/kibana/issues/146162

For grouped results, indicate in the expanded table row field / value
pairs that appear in other groups. In expanded row - adds an asterisk
column to highlight unique pairs among groups.

<img width="1384" alt="image"
src="https://user-images.githubusercontent.com/6446462/211634826-b7b88542-07c6-4c22-8bcc-3dec37cf90eb.png">

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-01-12 11:07:28 -07:00
Walter Rafelsberger
ae5594849c
[ML] Move DatePickerWrapper and related code to package (#148063)
- Moves duplicates of `DatePickerWrapper` and related code to package
`@kbn/ml-date-picker`. The duplicated components across the code base
have been consolidated and diverging features combined. Each duplicate
has been checked with a diff against the package before deletion.
- Moves duplicates of `query_utils.ts` to a package
`@kbn/ml-query_utils`.
- Some jest test were migrated from enzyme to react-testing-lib.
- `i18n` strings and data-test-subjects have been updated to be prefixes
in line with package names.
- Replaces custom code related to the `compact` flag with EUI's
breakpoints.
2023-01-12 11:04:49 +01:00
Spencer
d6be4a4b06
Implement package linter (#148496)
This PR implements a linter like the TS Project linter, except for
packages in the repo. It does this by extracting the reusable bits from
the TS Project linter and reusing them for the project linter. The only
rule that exists for packages right now is that the "name" in the
package.json file matches the "id" in Kibana.jsonc. The goal is to use a
rule to migrate kibana.json files on the future.

Additionally, a new rule for validating the indentation of tsconfig.json
files was added.

Validating and fixing violations is what has triggered review by so many
teams, but we plan to treat those review requests as notifications of
the changes and not as blockers for merging.

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-01-09 16:49:29 -07:00
Walter Rafelsberger
dc1ae9e06c
[ML] Move local storage utilities to package. (#148049)
Moves multiple copies of `useStorage()` and related code to a package as
a single source. The different copies with hard coded types have been
adapted so `useStorage()` is now based on generics. Also moves
duplicates of `isDefined()` to its own package.
2023-01-05 11:05:07 +01:00
Walter Rafelsberger
8a44ba3158
[ML] Move nested property utilities and url state to packages (#147912)
Effort to deduplicate code. Move nested property utilities and url state
to packages.

Boilerplate for the packages was created likes this:

```
node scripts/generate package @kbn/ml-url-state --web --dir ./x-pack/packages/ml/url_state
node scripts/generate package @kbn/ml-nested-property --web --dir ./x-pack/packages/ml/nested_property
```

I consolidated the different `url_state.ts` files. One thing to note:
Each one had its own definition for `pageKey: AppStateKey`. I changed
that and made it just `pageKey: string`, I suspect it's good enough.
Otherwise we'd have a reverse dependency on all consuming code.
Alternative: We could refactor to require overriding a generic to pass
in allowed values.
2022-12-27 15:59:14 +01:00
Spencer
afb09ccf8a
Transpile packages on demand, validate all TS projects (#146212)
## Dearest Reviewers 👋 

I've been working on this branch with @mistic and @tylersmalley and
we're really confident in these changes. Additionally, this changes code
in nearly every package in the repo so we don't plan to wait for reviews
to get in before merging this. If you'd like to have a concern
addressed, please feel free to leave a review, but assuming that nobody
raises a blocker in the next 24 hours we plan to merge this EOD pacific
tomorrow, 12/22.

We'll be paying close attention to any issues this causes after merging
and work on getting those fixed ASAP. 🚀

---

The operations team is not confident that we'll have the time to achieve
what we originally set out to accomplish by moving to Bazel with the
time and resources we have available. We have also bought ourselves some
headroom with improvements to babel-register, optimizer caching, and
typescript project structure.

In order to make sure we deliver packages as quickly as possible (many
teams really want them), with a usable and familiar developer
experience, this PR removes Bazel for building packages in favor of
using the same JIT transpilation we use for plugins.

Additionally, packages now use `kbn_references` (again, just copying the
dx from plugins to packages).

Because of the complex relationships between packages/plugins and in
order to prepare ourselves for automatic dependency detection tools we
plan to use in the future, this PR also introduces a "TS Project Linter"
which will validate that every tsconfig.json file meets a few
requirements:

1. the chain of base config files extended by each config includes
`tsconfig.base.json` and not `tsconfig.json`
1. the `include` config is used, and not `files`
2. the `exclude` config includes `target/**/*`
3. the `outDir` compiler option is specified as `target/types`
1. none of these compiler options are specified: `declaration`,
`declarationMap`, `emitDeclarationOnly`, `skipLibCheck`, `target`,
`paths`

4. all references to other packages/plugins use their pkg id, ie:
	
	```js
    // valid
    {
      "kbn_references": ["@kbn/core"]
    }
    // not valid
    {
      "kbn_references": [{ "path": "../../../src/core/tsconfig.json" }]
    }
    ```

5. only packages/plugins which are imported somewhere in the ts code are
listed in `kbn_references`

This linter is not only validating all of the tsconfig.json files, but
it also will fix these config files to deal with just about any
violation that can be produced. Just run `node scripts/ts_project_linter
--fix` locally to apply these fixes, or let CI take care of
automatically fixing things and pushing the changes to your PR.

> **Example:** [`64e93e5`
(#146212)](64e93e5806)
When I merged main into my PR it included a change which removed the
`@kbn/core-injected-metadata-browser` package. After resolving the
conflicts I missed a few tsconfig files which included references to the
now removed package. The TS Project Linter identified that these
references were removed from the code and pushed a change to the PR to
remove them from the tsconfig.json files.

## No bazel? Does that mean no packages??
Nope! We're still doing packages but we're pretty sure now that we won't
be using Bazel to accomplish the 'distributed caching' and 'change-based
tasks' portions of the packages project.

This PR actually makes packages much easier to work with and will be
followed up with the bundling benefits described by the original
packages RFC. Then we'll work on documentation and advocacy for using
packages for any and all new code.

We're pretty confident that implementing distributed caching and
change-based tasks will be necessary in the future, but because of
recent improvements in the repo we think we can live without them for
**at least** a year.

## Wait, there are still BUILD.bazel files in the repo
Yes, there are still three webpack bundles which are built by Bazel: the
`@kbn/ui-shared-deps-npm` DLL, `@kbn/ui-shared-deps-src` externals, and
the `@kbn/monaco` workers. These three webpack bundles are still created
during bootstrap and remotely cached using bazel. The next phase of this
project is to figure out how to get the package bundling features
described in the RFC with the current optimizer, and we expect these
bundles to go away then. Until then any package that is used in those
three bundles still needs to have a BUILD.bazel file so that they can be
referenced by the remaining webpack builds.

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-12-22 19:00:29 -06:00
Quynh Nguyen (Quinn)
22d0fa742d
[ML] Switch from normal sampling to random sampler for Index data visualizer table (#144646)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-11-16 08:36:55 -06:00
Walter Rafelsberger
86efac3632
[ML] Explain Log Rate Spikes: Use seed for random sampler agg. (#145088)
- Moves sample probability calculation to util `getSampleProbability()`
- Adds a seed to random sampler aggs to get deterministic results.
2022-11-16 14:33:40 +01:00