Commit graph

63491 commits

Author SHA1 Message Date
Alex Szabo
85e0c8e360
docs(kibana): fix md syntax, first dev login details (#158168)
Fixing very minor issues in the Kibana dev docs that I found as I was
getting bootstrapped:
 - fixing bad markdown syntax
 - adding first startup info (url + credentials)
2023-05-23 17:33:35 +02:00
Rodney Norris
38584b828a
serverless_search: update nav links (#158271)
## Summary

- Updated the "Transforms" side navigation link to go to ingest
pipelines stack management page. This link will eventually be updated to
a new page in June, but this page is closer to whats needed for now.
- Add the Indexing API to the side nav as a placeholder, but it links to
the getting started page for now, this will also be a new page in June.
2023-05-23 08:31:12 -07:00
Victor Martinez
d68317d95b
oblt: support github command for serverless (#158237) 2023-05-23 10:07:03 -05:00
Kerry Gallagher
34f21becf5
[Logs+] Implement Data Source APIs (#156413)
## Summary

Research: https://github.com/elastic/observability-dev/issues/2620
Requirements: https://github.com/elastic/observability-dev/issues/2639
Implementation: https://github.com/elastic/observability-dev/issues/2653

This implements two APIs ("Enumerate integrations" and "Enumerate data
streams") under the Fleet plugin, and specifically the `/epm` namespace
given the input here:
https://github.com/elastic/observability-dev/issues/2639#issuecomment-1521689096

The Enumerate Integrations API can be queried like so (example with all
parameters):

`GET
/api/fleet/epm/packages/installed?nameQuery=system&pageSize=5&type=logs&pageAfter=["system"]&sortDirection=asc`

The Enumerate Data Streams API can be queried like so (example with all
parameters):

`GET
/api/fleet/epm/data_streams?uncategorisedOnly=true&type=logs&sortDirection=desc&datasetQuery=beat`
2023-05-23 15:52:55 +01:00
Dario Gieselaar
1908568693
[APM] Version public APIs (#158233)
Closes #155245

Adds a version to the `endpoint` name for public APIs. It's required for
public APIs and enforced via type checks. Example:
`GET /api/apm/settings/agent-configuration/environments 2023-05-22`. The
reason why it's part of the endpoint is because it's the simplest change
to make, requires very little runtime changes and doesn't dramatically
change the way we handle type-safety for our server routes.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-05-23 16:50:43 +02:00
Tre
c8cd3b59c2
[CI] Drop duplicate lint check (#158259)
## Summary

Noticed a duplicate lint check in a
[pr](https://buildkite.com/elastic/kibana-pull-request/builds/129550#01884877-20a5-4b7d-a395-9bd70bac3f75)
I was working on.
Considering what this check does, we prolly really do not want to run it
twice, unless this was not a mistake.
2023-05-23 15:45:40 +01:00
Shahzad
02dcb336dd
[Synthetics] Update package version in api tests (#158264) 2023-05-23 16:41:18 +02:00
Nathan Reese
bb1cf6609a
[maps] fix Maps don't display darktheme when user has dark theme enabled in profile (#158219)
Fixes https://github.com/elastic/kibana/issues/158050

PR updates `getIsDarkMode` to read value from theme$ instead of
UiSettings, since UiSettings does not contain profile theming. Part of
https://github.com/elastic/kibana/issues/158201

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-05-23 08:33:41 -06:00
Paul Tavares
a7c2d09bca
[Security Solution][Endpoint] Un-skip test and add waitFor to assertion (#158216)
## Summary

- Un-skips unit test suite and add an additional `waitFor` around the
the failing test

Fixes #142584
2023-05-23 10:25:20 -04:00
Gerard Soldevila
70eb9d3ecb
Update saved objects migrations documentation for 8.8.0 (#158241)
Documentation must reflect changes brought by the [dot kibana
split](https://github.com/elastic/kibana/pull/154888).

Our public facing documentation just mentions two indices e.g.

https://www.elastic.co/guide/en/kibana/8.8/saved-object-migrations.html

https://www.elastic.co/guide/en/kibana/8.8/resolve-migrations-failures.html#upgrade-migrations-old-indices
this one in particular mentions that "all other indices are safe to
delete".
2023-05-23 15:53:52 +02:00
Patryk Kopyciński
7a62628bd6
[Osquery] Remove osquery-manager-usage-metric SO type (#154100)
## Summary

Remove unused `osquery-manager-usage-metric` SO type

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-05-23 13:42:11 +02:00
Dima Arnautov
3db3709eb4
[ML] Add functional tests for Change Point Detection UI (#158164)
## Summary

Part of https://github.com/elastic/kibana/issues/157980

Adds functional tests for the Change Point Detection UI.

### Checklist

- [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
2023-05-23 13:26:09 +02:00
Matthias Wilhelm
84d070d2f7
[Discover] Remove kbnUrlStateStorage of Discover main state container (#158225)
The exposed kbnUrlStateStorage property of `DiscoverStateContainer` is removed. It was just used for testing and is replaced with `await new Promise(process.nextTick);`
2023-05-23 11:22:54 +02:00
Thom Heymann
3800ce4c9c
Security tech debt cleanup (#157990)
## Summary

This PR cleans up some outstanding tech debt.

### 1. Remove deprecation warning for `disabled` prop

This property was marked as deprecated the moment it was introduced (See
https://github.com/elastic/kibana/pull/118001/files#r753124740). However
it has been adopted by Fleet and Guided Onboarding plugins so I don't
think there's value in keeping this deprecation warning in place.

As an alternative we could also bump the `@removeBy` version if people
think we should still remove this property.


### ~~2. Remove deprecated property `requiredRoles`~~

~~This property has been deprecated and marked for removal for 8.8. The
property isn't being used anywhere in our codebase and we have reached
feature freeze for 8.8 so looks safe to be removed now.~~

Turns out this property is still used and can't be removed without
breaking existing functionality so reverting that commit.
2023-05-23 09:30:48 +01:00
Pierre Gayvallet
c24dc357fd
[ZDT] DocumentMigrator: support higher version documents (#157895)
## Summary

Part of https://github.com/elastic/kibana/issues/150312
(next steps depend on https://github.com/elastic/kibana/pull/153117)

**This PR does two things:**
- introduce the concept of version persistence schema
- adapt the document migrator to support downward migrations for
documents of an higher version.

In the follow-up, we will then update the calls from the SOR to the
document migrator to allow downward conversions when we're using the ZDT
migration algorithm (which requires
https://github.com/elastic/kibana/pull/153117 to be merged)

### Model version persistence schema.

*(This is what has also been named 'eviction schema' or 'known fields
schema'.)*

A new `SavedObjectsModelVersion.schemas.backwardConversion` property was
added to the model version definition.

This 'schema' can either be an arbitrary function, or a `schema.object`
from `@kbn/config-schema`

```ts
type SavedObjectModelVersionBackwardConversionSchema<
  InAttrs = unknown,
  OutAttrs = unknown
> = ObjectType | SavedObjectModelVersionBackwardConversionFn<InAttrs, OutAttrs>;
```

When specified for a version, the document's attributes will go thought
this schema during down conversions by the document migrator.

### Adapt the document migrator to support downward migrations for
documents of an higher version.

Add an `allowDowngrade` option to `DocumentMigrator.migrate` and
`KibanaMigrator.migrateDocument`. When this option is set to `true`, the
document migration will accept to 'downgrade' the document if necessary,
instead of throwing an error as done when the option is `false` or
unspecified (which was the only behavior prior to this PR's changes)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-05-23 10:15:22 +02:00
Marco Liberati
cc7c2812af
[Lens][Example] Fix CodeEditor issue within Lens example (#158198)
## Summary

Fix #158193

#154710 changed a bit the context type to work with the Monaco
CodeEditor and this example was not updated to use it. This PR should
fix it.


### 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)
2023-05-23 10:13:42 +02:00
Matthias Wilhelm
12da3d0721
[Discover] Remove state persistAdHocDataView (#158227)
Eliminating code that's no longer in use
2023-05-23 10:09:16 +02:00
renovate[bot]
301135bff8
Update dependency elastic-apm-node to ^3.46.0 (main) (#158211)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-23 09:23:20 +02:00
Alexander Wert
f1ea233415
[APM] Added component for rendering dashboard-based service runtime metrics (#157724)
Pitch: https://github.com/elastic/apm-dev/issues/1001 (_internal_)

## Summary

Use portable dashboards for runtime metrics as a fallback.

Example dashboard:
<img width="1588" alt="image"
src="ee46582d-60db-4538-925f-e9729e77e70b">

---------

Signed-off-by: Alexander Wert <AlexanderWert@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-05-23 08:30:13 +02:00
Stratoula Kalafateli
2c1a2ef93a
[Visualizations] Fix user profile dark mode bugs (#158162)
## Summary

Closes https://github.com/elastic/kibana/issues/158154
Closes https://github.com/elastic/kibana/issues/158048
Closes https://github.com/elastic/kibana/issues/158052

This PR fixes the UI bugs that were created when we added the user
profile dark mode settings.

There are many cases in our visualizations where we are checking if the
uiSetting is in dark mode and apply custom colors. This is not the case
anymore. Now we need to check this flag from the theme$.

There is a bug on the user profile service. When the user profile is set
to Light and the advanced setting is set to dark mode, the dark mode is
applied. I have reported this to the security team.

### Checklist
- [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>
2023-05-23 09:04:43 +03:00
Kibana Machine
1ea493a36e
[api-docs] 2023-05-23 Daily api_docs build (#158224)
Generated by
https://buildkite.com/elastic/kibana-api-docs-daily/builds/346
2023-05-23 00:36:53 -04:00
Yan Savitski
1b0a1ec30c
[Search Application] Fix doc link in navigation toolbar (#158203)
- Fix the way of using setActionMenu. According their doc and source
code we need to call it twice, for moun and unmount.
- Fix redirection issue and using reactDom in rendering of action items

<img width="926" alt="image"
src="1e531299-e055-4af1-8ec7-92511e1a6e81">
2023-05-23 03:53:07 +02:00
Sandra G
8e0123e984
[Logs UI] Decouple log view HTTP API schema from saved object schema (#158098)
Resolves https://github.com/elastic/kibana/issues/152278.

Separates out the type for saved object
`infrastructure-monitoring-log-view` so the HTTP API no longer
references the same type.
2023-05-22 20:58:38 -04:00
Rachel Shen
8fcc8aa0c5
[Reporting] Remove ReportingCore from Export Types (#158031)
## Summary

Part of https://github.com/elastic/kibana/issues/158092

Removing calls to `ReportingCore` in export types functions

### Checklist
- [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
2023-05-22 14:44:27 -06:00
Ying Mao
3f333a6582
[Response Ops][Task Manager] Add kibana.yml setting for disabling authentication for background task utilization public API (#158185)
Resolves https://github.com/elastic/kibana/issues/158109

## Summary

Adds
`xpack.task_manager.unsafe.authenticate_background_task_utilization`
that will disable authentication on the public API for accessing
background task utilization.

## To Verify
- Run ES and Kibana, then access
https://localhost:5601/api/task_manager/_background_task_utilization
without logging into Kibana. Verify you get a `401` unauthorized error
- Set
`xpack.task_manager.unsafe.authenticate_background_task_utilization:
false` in your Kibana config and restart Kibana
- Verify you can access
https://localhost:5601/api/task_manager/_background_task_utilization
without logging in
- Verify that you still get a 401 unauthorized error for the internal
API at
https://localhost:5601/internal/task_manager/_background_task_utilization
2023-05-22 15:19:03 -04:00
Kurt
613b2d5034
Fixing User Profiles/Kibana.yml config light mode precedence logic (#158177)
## Summary

After changing the UserSettingService to calculate darkmode and return
`boolean | undefined` , the Rendering service `darkMode` logic needed to
be updated to work when a User chooses 'Light' which provides a 'false'
value to the Rendering service.

## Testing

For Space Setting:

1.  Set Space Adv. Setting to darkMode: true
2. Set User Profile Setting to 'Light'
3. Observe that Light mode takes precedence

For Config setting:

1. Set User Profile Setting to 'Dark'
2. In `kibana.yml` set `uiSettings.overrides.theme:darkMode: false`
3. Observe that Light mode takes precedence
2023-05-22 13:48:22 -04:00
Jonathan Buttner
e1523c1bd7
[Cases] Removing spreads from connector mappings (#156622)
This PR adds the decode within the service layer for the saved object
attributes.
2023-05-22 13:16:00 -04:00
Jonathan Buttner
6af77d6b45
[Cases] Renaming Configure types and explicit mapping (#156444)
This PR renames some of the `CaseConfigure*` types and adds the decoding
to validate the attributes being returned to the client.
2023-05-22 13:14:07 -04:00
Matthias Wilhelm
ef678f3d92
[Discover] Migrate session session initialization to state container (#156957)
## Summary

Migrate `useSearchSession` to state container's `initializeAndSync` function, to remove another `hook`.
2023-05-22 18:33:42 +02:00
Zacqary Adam Xeper
8a9fb98c75
[RAM] Change truncated 'run action every' to visible 'run every' (#156753)
## Summary

#155804 introduced this bug:

<img width="568" alt="Screenshot 2023-05-04 at 3 43 05 PM"
src="https://user-images.githubusercontent.com/1445834/236325207-6ba7ba7d-c056-4444-9cf4-f3e6287c271b.png">


After:

<img width="562" alt="Screenshot 2023-05-04 at 3 45 09 PM"
src="https://user-images.githubusercontent.com/1445834/236325256-34926a1a-8630-469f-8bdc-01f375648779.png">
2023-05-22 11:29:02 -05:00
Tim Sullivan
dba3c03b5d
[Serverless] Changes to TopNavMenu placement for serverless projects. (#158053)
## Summary

Part of https://github.com/elastic/kibana/issues/158034

This PR moves the TopNavMenu placement to below the breadcrumbs bar for
the serverless project chrome layout.

The app toolbar must appear below the breadcrumbs bar in the layout,
when the app has TopNavMenu items registered with the navigation
service.

To prevent the layout from rendering an empty container, I had to create
a new hook, `useHeaderActionMenuMounter`, that extracts the state from
HeaderActionMenu. The state (`mounter: MountPoint | undefined`) is
hoisted above so that the header can check if it is empty before
rendering the container.

_Future work is still needed to achieve the end goal of the design._
Apps must be able to define custom layouts, which commonly require grid
and spacer components. The TopNavMenu needs augmentation to support the
new API. See the project document from the issue.

## Screenshots
**App showing the toolbar, with the container shown below breadcrumbs**

![image](a6f49772-2f0b-4e4a-9a32-7b02398bd0b2)

**App without the toolbar and no empty container**

![image](df361b26-1bb0-430a-98c1-863de4cde2da)
2023-05-22 09:00:04 -07:00
Paul Tavares
344adf2205
[Security Solution + Fleet] Add FleetFilesClient to fleet and refactor endpoint actions to use it (#157658)
## Summary

PR introduces a new Files service client to the Fleet server-side code
that will enable integration to work with Files received/sent to Hosts
without having to access `.fleet-*` indexes directly.

### Fleet changes

- Adds `FleetFilesClient` to Fleet's server-side code. Supports both
files that are received from the host as well as files that can be sent
to the host.
- exposes new `createFilesClient()` method from `FleetStartContract`
that enables fleet dependents to get a files client.


### Security Solution changes

- Refactors API routes to use new `FleetFilesClient`
- Deletes all file related services from server code
2023-05-22 08:40:06 -07:00
Tiago Costa
39dad65e08
skip flaky suite (#155304) 2023-05-22 15:01:44 +01:00
Tiago Costa
73c945022e
skip flaky suite (#139260) 2023-05-22 14:57:41 +01:00
Ashokaditya
9b50ae9546
[Security Solutions][Endpoint][Response Actions] File operations cypress tests (#156604)
## Summary

Adds e2e tests for `get-file` and `execute` response actions.

~- [ ] Test response actions fail without signing~
- [x] Ensure other endpoint tests are not using the same endpoint for
tests
  
### Checklist
- [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
2023-05-22 06:30:40 -07:00
Lola
8a69395d6d
[Cloud Posture] fix name generation sequence (#158039)
## Summary

We now ensure that policy names are unique and sequentially numbered,
using the `getMaxPackageName` utility function. This function retrieves
the highest number appended to existing package policy names for a given
package, and increments it by one to generate a new unique name.

I added back the `usePolicyTemplateInitialName` hook @opauloh created.
The `usePolicyTemplateInitialName` custom hook has been enhanced to
automatically set the initial policy name based on the unique name
generated by getMaxPackageName.



498b6069-4221-4300-b6f4-6125adc524e2
2023-05-22 09:27:44 -04:00
Christos Nasikas
df14a7663d
[Cases] Refactor connectors to use the form lib (#157380)
## Summary

This PR converts all connector forms to use the form lib.

Fixes: https://github.com/elastic/kibana/issues/133467,
https://github.com/elastic/kibana/issues/143408,
https://github.com/elastic/kibana/issues/146394

## Notable changes
- All connector's hooks were converted to use React Query
- All connector's forms were converted to use the Kibana Form Lib
- The form of fields of the connector and the preview of the fields of
the connector got separated
- All connector logic in the case view page moved on its own component
- Improve loading visualization on the first render
- Jira: Issue type is not selected automatically
- Jira: Added validation for the issue type field
- ServiceNow: Subcategory is visible

## Testing scenarios

- Create a case with no connectors. Press "Add connector". The Save
button should be disabled
- Create a case (or edit an existing one) with a connector. Press the
edit pencil. The Save button should be disabled
- Create a case (or edit an existing one) with a connector. Press the
edit pencil. Change a field or a connector. The Save button should not
be disabled
- Change various connectors and their fields on a case. The fields
should be preserved between changes
- Change various connectors and their fields on a case
- Test the forms of all supported connectors in the create case and the
view case page
- Push all supported connectors in the create case and the view case
page and verify it is working as expected
- Optional fields can be pushed correctly
- Check that the fields are being reset when changing connectors of the
same type (Jira for example)
- Test that connectors work in the create case form when attaching
outside of Cases (ML for example)
- Jira: Try to submit without an issue type selected. You should see an
error
- ServiceNow: Test that the subcategory is being reset when you change
the category.

## Flaky tests

The PR fixes the flaky tests in
`x-pack/plugins/cases/public/components/create/form_context.test.tsx`. I
run the test multiple times on CI to ensure that the test is not flaky
anymore: Specifically:
- Test run 50 times in
f220cc30cf
- Test run 55 times in
6221314b2e
- Test run 50 times in
91551631ff

### 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

### For maintainers

- [x] 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: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-05-22 16:25:10 +03:00
Robert Oskamp
4e6067be8e
Adjust serverless test README (#158170)
## Summary

This PR adjusts the serverless test README, which didn't reflect the
existence of the `shared` directory in all places.
2023-05-22 14:52:23 +02:00
Kristie Patterson
0ca99a7258
[APM] Settings template shows description text before title (#157346)
## Summary

Moved description text below the title to for APM settings pages to
improve flow of page

Closes issue #146130

### Checklist

Delete any items that are not applicable to this PR.

- [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)



### 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: Kristie Patterson <kristiepatterson@Kristies-MacBook-Pro.local>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kristie Patterson <kristiepatterson@Kristies-MBP.attlocal.net>
2023-05-22 14:16:01 +02:00
Rudolf Meijering
c79c09c3d0
Make updateAndPickupMappings batch size configurable (#153185)
## Summary

Use migrations.batchSize config for the scroll_size in update_by_query /
updateAndPickupMappings. The default scroll_size=1000 can sometimes
cause Elasticsearch to fail with `RecyclerBytesStreamOutput cannot hold
more than 2GB of data`

On CI our Elasticsearch cluster does not have enough memory to reproduce
`RecyclerBytesStreamOutput` error it OOMs before it's able to load 2GB.

However it's possible to test manually:
1. Start Elasticsearch with 8GB heap `ES_JAVA_OPTS=' -Xms8g -Xmx8g' yarn
es snapshot`
2. Ingest > 2GB of saved objects distributed over batchSize documents (<
1000)
    ```
curl -XPOST "elastic:changeme@localhost:9200/_security/user/superuser"
-H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
      {
        "password" : "changeme",  
        "roles" : [ "superuser", "grant_kibana_system_indices" ]
      }'

curl -XPUT
"superuser:changeme@localhost:9200/.kibana_8.4.0_001/_mappings" -H
"kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
      {
"dynamic": false,
            "properties": {

            }

      }'

      set -B                  # enable brace expansion
      for i in {1..500}; do
curl -k --data-binary "@/Users/rudolf/dev/kibana/body.json" -X PUT
"http://superuser:changeme@localhost:9200/.kibana_8.4.0_001/_doc/cases-comments:"{$i}"?&pretty=true"
-H "Content-Type: application/json"
      done

curl -XPOST "superuser:changeme@localhost:9200/_aliases" -H "kbn-xsrf:
reporting" -H "Content-Type: application/json" -d'
      {
        "actions": [
          {
            "add": {
              "index": ".kibana_8.4.0_001",
              "alias": ".kibana_8.4.0"
            }
          },
          {
            "add": {
              "index": ".kibana_8.4.0_001",
              "alias": ".kibana"
            }
          }
        ]
      }'
    ```
    body.json
    ```
        {
        "cases-comments": {
            "comment": "...put lots of data here...",
            "type": "user",
            "owner": "cases",
            "created_at": "2023-05-09T08:07:50.121Z",
            "created_by": {
                "email": null,
                "full_name": null,
                "username": "elastic"
            },
            "pushed_at": null,
            "pushed_by": null,
            "updated_at": null,
            "updated_by": null
        },
        "type": "cases-comments",
        "references": [
            {
                "type": "cases",
                "name": "associated-cases",
                "id": "9563b290-ee40-11ed-8fcc-e975e7d47f63"
            }
        ],
        "namespaces": [
            "default"
        ],
        "migrationVersion": {
            "cases-comments": "8.6.0"
        },
        "coreMigrationVersion": "8.7.2",
        "updated_at": "2023-05-09T08:07:50.168Z",
        "created_at": "2023-05-09T08:07:50.168Z"
    }
    ```
3.  Run Kibana with default and smaller migrations.batchSize


### Checklist

Delete any items that are not applicable to this PR.

- [ ] [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

### For maintainers

- [x] 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)
2023-05-22 05:08:02 -07:00
GitStart
adcede25e2
[Cases] Show the count of total alerts in a case in the "Alerts" tab (#157983)
## What does this PR do?
* This PR adds a `Badge` beside the "Alerts" tab name to display the
amount of alerts the selected case has.

Fixes: https://github.com/elastic/kibana/issues/156169

## Video/Screenshot Demo 
###### STEPS TO REPRODUCE:

6cd253ad-c6ac-4997-b74b-da317e895cb5

###### FIX:

a607e4b0-0f10-447a-babb-cc9beab23fc8

---
This code was written and reviewed by GitStart Community. Growing great
engineers, one PR at a time.

---------

Co-authored-by: KlingerMatheus <klinger.matheus@gitstart.dev>
Co-authored-by: gitstart_bot <gitstart_bot@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-05-22 14:55:16 +03:00
Pierre Gayvallet
8453fe820a
Cleanup spread operators in reduce calls (#157471)
## Summary

The spread operator is costly and put pressure on GC. It should be
avoided when possible, especially in loops.

This PR adapts a lot of `reduce` calls in the codebase to remove the
usages of the diabolic spread operator, when possible.

Note: the PR is not fully exhaustive. I focused on the server-side, as
we're more directly impacted than on browser-side code regarding
performances.

## Removing `...` usages in `kittens.reduce()`

For `reduce` loops, the spread operator can usually easily be replaced:

#### - setting a value on the accum object and returning it

#### BAD
```ts
  return this.toArray().reduce(
      (acc, renderer) => ({
        ...acc,
        [renderer.name]: renderer,
      }),
      {} as Record<string, ExpressionRenderer>
    );
```

#### GOOD
```ts
  return this.toArray().reduce((acc, renderer) => {
      acc[renderer.name] = renderer;
      return acc;
    }, {} as Record<string, ExpressionRenderer>);
```


#### - assigning values to the accum object and returning it 

#### BAD
```ts
  const allAggs: Record<string, any> = fieldAggRequests.reduce(
      (aggs: Record<string, any>, fieldAggRequest: unknown | null) => {
        return fieldAggRequest ? { ...aggs, ...(fieldAggRequest as Record<string, any>) } : aggs;
      },
      {}
    );
```

#### GOOD
```ts
  const allAggs = fieldAggRequests.reduce<Record<string, any>>(
      (aggs: Record<string, any>, fieldAggRequest: unknown | null) => {
        if (fieldAggRequest) {
          Object.assign(aggs, fieldAggRequest);
        }
        return aggs;
      },
      {}
    );
```

#### - pushing items to the accum list and returning it 

#### BAD
```ts
  const charsFound = charToArray.reduce(
    (acc, char) => (value.includes(char) ? [...acc, char] : acc),
    [] as string[]
  );
```

#### GOOD
```ts
  const charsFound = charToArray.reduce((acc, char) => {
    if (value.includes(char)) {
      acc.push(char);
    }
    return acc;
  }, [] as string[]);
```

## Questions

#### Are you sure all the changes in this are strictly better for
runtime performances?

Yes, yes I am.

#### How much better?

Likely not much.

#### Are you planning on analyzing the perf gain?

Nope.

#### So why did you do it?

I got tired of seeing badly used spread operators in my team's owned
code, and I had some extra time during on-week, so I spent a few hours
adapting the usages in all our runtime/production codebase.

#### Was it fun?

Take your best guess.

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-05-22 04:50:24 -07:00
Giuseppe Santoro
b05ad20cba
Add flags to give permissions to write to any dataset and namespace (#157897)
Add flags to give permissions to reroute events from an input package to
other datastreams with the same type but different dataset and
namespace.

```
elasticsearch.dynamic_dataset: true
elasticsearch.dynamic_namespace: true,
```
2023-05-22 13:49:06 +02:00
Dominique Clarke
8c1624b457
[Synthetics] remove public SO usage from delete params flow (#158046) 2023-05-22 13:44:46 +02:00
Stratoula Kalafateli
0975ebabd1
[Text based languages] Creates editor reusable component (#158008)
## Summary

Closes https://github.com/elastic/kibana/issues/154330

This PR:
- Moves the editor from unified-search to a standalone package
- The editor has now a core ui settings dependency but is going to have
an expressions dependency too when merged with the ESQL branch
- Adds a new plugin (text-based-languages) which is used to pass the
dependencies on the package. The user can either use this plugin without
giving any dependencies or use the package with passing the dependecies
on the KibanaContextProvider.
- Adds storybook for the editor (I used the mdx stories as we did on the
random sampling package)

<img width="1668" alt="image"
src="763a3112-1ae5-49bb-81f3-acd02892e402">


### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-05-22 14:27:38 +03:00
Shahzad
78e9af7644
[Synthetics] Skip flaky test (#157986) 2023-05-22 13:16:41 +02:00
David Sánchez
a811061c8f
[Security Solution][Endpoint] Improve endpoint fleet artifacts FTR tests (#158061)
## Summary

- Adds new test cases for event filters and trusted apps.
- Adds new test case when multiple entries are created with different
policies.
- Test refactor.
- Adds testId generator to effected policies element in event filters
and host isolation exceptions forms.

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-05-22 13:01:56 +02:00
Robert Oskamp
87be4cb678
Initial e2e tests for serverless plugins (#157166)
## Summary

This PR adds boilerplate code and a few initial end-to-end tests to
serverless plugins.

Note that the tests defined in this PR are not part of any CI run yet,
this will be done in a follow-up after this PR is merged.

### Details

The serverless test structure corresponds to what we have in
`x-pack/test` with API tests in `api_integration` and UI tests in
`functional`, each with their set of helper methods and sub-directories
for
- `common` functionality shared across serverless projects (core, shared
UX, ...)
- `observability` project specific functionality
- `search` project specific functionality
- `security` project specific functionality

The `shared` directory contains fixtures, services, ... that are shared
across `api_integration` abd `functional` tests.

```
x-pack/test_serverless/
├─ api_integration
│  ├─ services
│  ├─ test_suites
│  │  ├─ common
│  │  ├─ observability
│  │  ├─ search
│  │  ├─ security
├─ functional
│  ├─ page_objects
│  ├─ services
│  ├─ test_suites
│  │  ├─ common
│  │  ├─ observability
│  │  ├─ search
│  │  ├─ security
├─ shared
│  ├─ services
│  ├─ types
```

See also `x-pack/test_serverless/README.md`

### Run tests

Similar to how functional tests are run in `x-pack/test`, you can point
the functional tests server and test runner to config files in this
`x-pack/test_serverless` directory, e.g. from the `x-pack` directory
run:
```
node scripts/functional_tests_server.js --config test_serverless/api_integration/test_suites/common/config.ts
```
and 
```
node scripts/functional_test_runner.js --config test_serverless/api_integration/test_suites/common/config.ts
```

### Additional changes

- The stateful `common_page` page object used the existence of the
global nav to determine `isChromeVisible` and `isChromeHidden`, which is
not working when the global nav is disabled. To solve this, a
`data-test-subj` that indicates the chrome visible state is added to the
Kibana app wrapper and is used for the checks.
- Add a few `data-test-subj` entries to the Observability overview page.
- Add optional `dataTestSubj` to the `Navigation` component and use that
for the serverless search nav.
- Add optional `titleDataTestSubj` to the `SolutionNav` component and
use it for the serverless security nav.
- Add a data-test-subj entry to the Search overview page.
2023-05-22 12:57:38 +02:00
István Zoltán Szabó
a3c940f0cd
[DOCS] Adds log pattern analysis in Discover docs (#158059)
Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com>
2023-05-22 12:34:15 +02:00
Michael Dokolin
a65cd356aa
[Migrations] Add support of deferred migrations (#153117)
* Add deferred migrations parameter.
* Update outdated documents query to take into account deferred migrations.
* Update outdated documents query to take into account the core migration version.
* Update read operations in the saved objects repository to perform deferred migrations.
2023-05-22 11:17:41 +02:00