## Summary
How to test this performance issue? Ensure that you add extra mappings of mapping-test-1k-block-1, 2, 3,4, etc.. that I have included within your advanced settings like below to a Kibana space:
```ts
apm-*-transaction*, auditbeat-*, endgame-*, filebeat-*, logs-*, packetbeat-*, winlogbeat-*, mapping-test-1k-block-1, mapping-test-1k-block-2, mapping-test-1k-block-3, mapping-test-1k-block-4
```
<img width="1331" alt="Screen Shot 2020-10-26 at 11 35 12 AM" src="https://user-images.githubusercontent.com/1151048/97224071-3a904a00-1796-11eb-8870-6de35fc2f115.png">
Modify these lines to add manual perf lines like so for the before numbers:
file: x-pack/plugins/security_solution/public/common/containers/source/index.tsx
```ts
export const getBrowserFields = memoizeOne(
(_title: string, fields: IndexField[]): BrowserFields => {
console.time('getBrowserFields'); // Start time
const value =
fields && fields.length > 0
? fields.reduce<BrowserFields>(
(accumulator: BrowserFields, field: IndexField) =>
set([field.category, 'fields', field.name], field, accumulator),
{}
)
: {};
console.timeEnd('getBrowserFields'); // End time
return value;
},
// Update the value only if _title has changed
(newArgs, lastArgs) => newArgs[0] === lastArgs[0]
);
```
Then load any of the SIEM webpages or create a detection engine rule and change around your input indexes.
Perf of this before the fix is going to show up in your dev tools console output like this:
```ts
getBrowserFields: 7875.5009765625 ms
```
Now, checkout this branch and change the code to be like so for the perf test of the mutatious version for after:
file: x-pack/plugins/security_solution/public/common/containers/source/index.tsx
```ts
/**
* HOT Code path where the fields can be 16087 in length or larger. This is
* VERY mutatious on purpose to improve the performance of the transform.
*/
export const getBrowserFields = memoizeOne(
(_title: string, fields: IndexField[]): BrowserFields => {
console.time('getBrowserFields'); // Start time
// Adds two dangerous casts to allow for mutations within this function
type DangerCastForMutation = Record<string, {}>;
type DangerCastForBrowserFieldsMutation = Record<
string,
Omit<BrowserField, 'fields'> & { fields: Record<string, BrowserField> }
>;
// We mutate this instead of using lodash/set to keep this as fast as possible
const value = fields.reduce<DangerCastForBrowserFieldsMutation>((accumulator, field) => {
if (accumulator[field.category] == null) {
(accumulator as DangerCastForMutation)[field.category] = {};
}
if (accumulator[field.category].fields == null) {
accumulator[field.category].fields = {};
}
if (accumulator[field.category].fields[field.name] == null) {
(accumulator[field.category].fields as DangerCastForMutation)[field.name] = {};
}
accumulator[field.category].fields[field.name] = (field as unknown) as BrowserField;
return accumulator;
}, {});
console.timeEnd('getBrowserFields'); // End time
return value;
},
// Update the value only if _title has changed
(newArgs, lastArgs) => newArgs[0] === lastArgs[0]
);
```
Re-load any and all pages and you should see this now:
```ts
getBrowserFields: 11.258056640625 ms
```
### Checklist
Delete any items that are not applicable to this PR.
- [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: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* Change an example in embeddable to use controls instead of knobs
* Add controls to SyncBadge APM story
* Convert both to [CSF](https://storybook.js.org/docs/react/api/csf)
* Remove the Knobs addon from the default Storybook configuration
Do not remove the Knobs addon package, since Canvas is still using it and this does not change anything in Canvas.
This PR adds an an internal monitoring mechanism in Task Manager which keep track of a variety of metrics and a health api endpoint which makes the monitored statistics accessible.
# Conflicts:
# x-pack/test/plugin_api_integration/test_suites/task_manager/index.ts
* Added functional test for alerts list filters by status, alert type and action type. Did a code refactoring and splitting for alerts tests.
* -
* fixed failing tests
* fixed type checks
* minor naming fixes
* Use displayName in field list in visualize editor
* Set key in combo box
* Fix jest tests
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
The query bar originally developed for the transforms wizard didn't work with indices with more than 1024 fields. In that case we disabled the query bar and showed an info-callout. Since we moved on to make use of the KQL query bar, this limitation does no longer exist so this PR removes the limitation.
* fix overview query to be connected to sourcerer
* investigate eql in timeline
* keep timeline indices
* trusting what is coming from timeline saved object for index pattern at initialization
* fix type + initialize old timeline to sourcerer
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* wip
* Adding updateFieldsAndMarkAsFailed function
* Updating UBQ
* Only updating retryAt if marking as claiming
* Updating query
* Updating query to only fail one time tasks that have exceeded max attempts
* Fixing tests
* Fixing tests
* Handling claiming tasks by id
* Removing unused function
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* migrate all fields on warm phase except, data alloc, replicas and shrink
* introduce edit policy context to share original policy and migrate shrink and replicas fields
* Refactored biggest field; data allocation
Copied the entire field for now duplicating all of the components
* remove unused import
* complete migration of new serialization
* Remove last vestiges of legacy warm phase
- also removed policy serialization tests for warm phase
* fix existing test coverage and remove use of "none" for node attribute
* added policy serialization tests
* remove unused translations
* Fix use of useFormData after update
- also minor refactor to use useCallback in policy flyout now
that getFormData changes when the form data changes.
* fix import path
* simplify serialization snapshot tests
* type phases: string -> phases: Phases
* Addressed some PR review items
- refactor toggle click to take a boolean arg
- refactor selection options in data tier component to use a func
to get select options.
* updated data tier callout logic after new changes
* getPolicy -> updatePolicy
Also rather deconstruct the validate fn from the form object
* fix detection of migrate false and refactor serialization to pure function
* fix type issue
* fix for correctly detecting policy data tier type
- with jest tests see origin here:
https://github.com/elastic/kibana/pull/81642
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* Add fullEngineAccessChecked logic
* Add onEngineSelect logic
* [Refactor] DRY out/simplify http mocks
Note: import reorder is required in for mocks to work correctly
* Add onApiTokenChange logic
* Update flyout footer to use onApiTokenChange
* Add new POST/PUT server routes
+ some opinionated comments
* [PR feedback] tests copy, extra data tests
* [PR feedback] Reuse fullEngineAccessChecked, fix fullEngineAccessChecked being undefined vs a bool
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* Fix a couple of issues with the cpu usage alert
* Fix tests
* PR feedback
# Conflicts:
# x-pack/plugins/monitoring/public/components/elasticsearch/node/advanced.js
* wip
* Adding health context provider and option to block waiting for health check
* Adding tests
* Removing forced lag
* Fixing action form not rendering pre selected action
* PR fixes
* Updating i18n ids
Co-authored-by: Mike Côté <mikecote@users.noreply.github.com>
* Applying i18n fix
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Mike Côté <mikecote@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Mike Côté <mikecote@users.noreply.github.com>
* Check mapping version instead of template version and throw useful error messages on failures
* Fix comment
* Move MIN_EQL_RULE_INDEX_VERSION next to mapping version
* [Metrics UI] Fix Metrics Explorer API to return empty results when field is missing from aggregation
* Update x-pack/plugins/infra/server/routes/metrics_explorer/lib/convert_request_to_metrics_api_options.ts
Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>
* Fixing type
Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [Maps] trigger auto fit to bounds on refresh trigger
* default auto fit to data bounds to false
* update jest snapshots
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>