Skip to content

Commit

Permalink
Merge branch 'master' into updateSavedObjectsImportTest
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jun 15, 2021
2 parents 922fe7a + 2cecca3 commit c247917
Show file tree
Hide file tree
Showing 259 changed files with 4,828 additions and 4,202 deletions.
3 changes: 2 additions & 1 deletion .ci/Jenkinsfile_flaky
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ library 'kibana-pipeline-library'
kibanaLibrary.load()

def TASK_PARAM = params.TASK ?: params.CI_GROUP

// Looks like 'oss:ciGroup:1', 'oss:firefoxSmoke'
def JOB_PARTS = TASK_PARAM.split(':')
def IS_XPACK = JOB_PARTS[0] == 'xpack'
Expand Down Expand Up @@ -111,6 +110,8 @@ def getWorkerFromParams(isXpack, job, ciGroup) {
return kibanaPipeline.scriptTaskDocker('Jest Integration Tests', 'test/scripts/test/jest_integration.sh')
} else if (job == 'apiIntegration') {
return kibanaPipeline.scriptTask('API Integration Tests', 'test/scripts/test/api_integration.sh')
} else if (job == 'pluginFunctional') {
return kibanaPipeline.functionalTestProcess('oss-pluginFunctional', './test/scripts/jenkins_plugin_functional.sh')
} else {
return kibanaPipeline.ossCiGroupProcess(ciGroup)
}
Expand Down
16 changes: 16 additions & 0 deletions docs/discover/search-sessions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,19 @@ behaves differently:
* Relative dates are converted to absolute dates.
* Panning and zooming is disabled for maps.
* Changing a filter, query, or drilldown starts a new search session, which can be slow.

[float]
==== Limitations

Certain visualization features do not fully support background search sessions yet. If a dashboard using these features gets restored,
all panels using unsupported features won't load immediately, but instead send out additional data requests which can take a while to complete.
In this case a warning *Your search session is still running* will be shown.

You can either wait for these additional requests to complete or come back to the dashboard later when all data requests have been finished.

A panel on a dashboard can behave like this if one of the following features is used:
* *Lens* - A *top values* dimension with an enabled setting *Group other values as "Other"* (configurable in the *Advanced* section of the dimension)
* *Lens* - An *intervals* dimension is used
* *Aggregation based* visualizations - A *terms* aggregation is used with an enabled setting *Group other values in separate bucket*
* *Aggregation based* visualizations - A *histogram* aggregation is used
* *Maps* - Layers using joins, blended layers or tracks layers are used
20 changes: 0 additions & 20 deletions docs/user/alerting/domain-specific-rules.asciidoc

This file was deleted.

3 changes: 1 addition & 2 deletions docs/user/alerting/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ include::alerting-setup.asciidoc[]
include::create-and-manage-rules.asciidoc[]
include::defining-rules.asciidoc[]
include::rule-management.asciidoc[]
include::stack-rules.asciidoc[]
include::domain-specific-rules.asciidoc[]
include::rule-types.asciidoc[]
include::alerting-troubleshooting.asciidoc[]
56 changes: 56 additions & 0 deletions docs/user/alerting/rule-types.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[role="xpack"]
[[rule-types]]
== Rule types

A rule is a set of <<alerting-concepts-conditions, conditions>>, <<alerting-concepts-scheduling, schedules>>, and <<alerting-concepts-actions, actions>> that enable notifications. {kib} provides two types of rules: rules specific to the Elastic Stack and rules specific to a domain.

[NOTE]
==============================================
Some rule types are subscription features, while others are free features.
For a comparison of the Elastic subscription levels,
see {subscriptions}[the subscription page].
==============================================

[float]
[[stack-rules]]
=== Stack rules

<<alert-management, Stack rules>> are built into {kib}. To access the *Stack Rules* feature and create and edit rules, users require the `all` privilege. See <<kibana-feature-privileges, feature privileges>> for more information.

[cols="2*<"]
|===

| <<rule-type-index-threshold>>
| Aggregate field values from documents using {es} queries, compare them to threshold values, and schedule actions to run when the thresholds are met.

| <<rule-type-es-query>>
| Run a user-configured {es} query, compare the number of matches to a configured threshold, and schedule actions to run when the threshold condition is met.

|===

[float]
[[domain-specific-rules]]
=== Domain rules

Domain rules are registered by *Observability*, *Security*, <<maps, Maps>> and <<xpack-ml, Machine Learning>>.

[cols="2*<"]
|===

| {observability-guide}/create-alerts.html[Observability rules]
| Detect complex conditions in the *Logs*, *Metrics*, and *Uptime* apps.

| {security-guide}/prebuilt-rules.html[Security rules]
| Detect suspicous source events with pre-built or custom rules and create alerts when a rule’s conditions are met.

| <<geo-alerting, Maps rules>>
| Run an {es} query to determine if any documents are currently contained in any boundaries from a specified boundary index and generate alerts when a rule's conditions are met.

| {ml-docs}/ml-configuring-alerts.html[{ml-cap} rules] beta:[]
| Run scheduled checks on an anomaly detection job to detect anomalies with certain conditions. If an anomaly meets the conditions, an alert is created and the associated action is triggered.

|===

include::rule-types/index-threshold.asciidoc[]
include::rule-types/es-query.asciidoc[]
include::rule-types/geo-rule-types.asciidoc[]
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[role="xpack"]
[[geo-alerting]]
=== Geo rule type
=== Tracking containment

Alerting now includes one additional stack rule: <<rule-type-tracking-containment>>.

As with other stack rules, you need `all` access to the *Stack Rules* feature
to be able to create and edit a geo rule.
See <<kibana-feature-privileges, feature privileges>> for more information on configuring roles that provide access to this feature.
<<maps, Maps>> offers the Tracking containment rule type which runs an {es} query over indices to determine whether any
documents are currently contained within any boundaries from the specified boundary index.
In the event that an entity is contained within a boundary, an alert may be generated.

[float]
==== Geo alerting requirements
To create a *Tracking containment* rule, the following requirements must be present:
==== Requirements
To create a Tracking containment rule, the following requirements must be present:

- *Tracks index or index pattern*: An index containing a `geo_point` field, `date` field,
and some form of entity identifier. An entity identifier is a `keyword` or `number`
Expand All @@ -29,22 +27,12 @@ than the current time minus the amount of the interval. If data older than
`now - <current interval>` is ingested, it won't trigger a rule.

[float]
==== Creating a geo rule
Click the *Create* button in the <<create-and-manage-rules, rule management UI>>.
Complete the <<defining-rules-general-details, general rule details>>.

[role="screenshot"]
image::user/alerting/images/alert-types-tracking-select.png[Choosing a tracking rule type]
==== Create the rule

[float]
[[rule-type-tracking-containment]]
==== Tracking containment
The Tracking containment rule type runs an {es} query over indices, determining if any
documents are currently contained within any boundaries from the specified boundary index.
In the event that an entity is contained within a boundary, an alert may be generated.
Fill in the <<defining-rules-general-details, rule details>>, then select Tracking containment.

[float]
===== Defining the conditions
==== Define the conditions
Tracking containment rules have 3 clauses that define the condition to detect,
as well as 2 Kuery bars used to provide additional filtering context for each of the indices.

Expand All @@ -61,6 +49,9 @@ Index (Boundary):: This clause requires an *index or index pattern*, a *`geo_sha
identifying boundaries, and an optional *Human-readable boundary name* for better alerting
messages.

[float]
==== Add action

Conditions for how a rule is tracked can be specified uniquely for each individual action.
A rule can be triggered either when a containment condition is met or when an entity
is no longer contained.
Expand Down
27 changes: 0 additions & 27 deletions docs/user/alerting/stack-rules.asciidoc

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
"cytoscape-dagre": "^2.2.2",
"d3": "3.5.17",
"d3-array": "1.2.4",
"d3-cloud": "1.2.5",
"d3-scale": "1.0.7",
"d3-shape": "^1.1.0",
"d3-time": "^1.1.0",
Expand Down
37 changes: 29 additions & 8 deletions packages/kbn-test/src/jest/utils/router_helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,39 @@

import React, { Component, ComponentType } from 'react';
import { MemoryRouter, Route, withRouter } from 'react-router-dom';
import * as H from 'history';
import { History, LocationDescriptor } from 'history';

export const WithMemoryRouter = (initialEntries: string[] = ['/'], initialIndex: number = 0) => (
WrappedComponent: ComponentType
) => (props: any) => (
const stringifyPath = (path: LocationDescriptor): string => {
if (typeof path === 'string') {
return path;
}

return path.pathname || '/';
};

const locationDescriptorToRoutePath = (
paths: LocationDescriptor | LocationDescriptor[]
): string | string[] => {
if (Array.isArray(paths)) {
return paths.map((path: LocationDescriptor) => {
return stringifyPath(path);
});
}

return stringifyPath(paths);
};

export const WithMemoryRouter = (
initialEntries: LocationDescriptor[] = ['/'],
initialIndex: number = 0
) => (WrappedComponent: ComponentType) => (props: any) => (
<MemoryRouter initialEntries={initialEntries} initialIndex={initialIndex}>
<WrappedComponent {...props} />
</MemoryRouter>
);

export const WithRoute = (
componentRoutePath: string | string[] = '/',
componentRoutePath: LocationDescriptor | LocationDescriptor[] = ['/'],
onRouter = (router: any) => {}
) => (WrappedComponent: ComponentType) => {
// Create a class component that will catch the router
Expand All @@ -40,16 +61,16 @@ export const WithRoute = (

return (props: any) => (
<Route
path={componentRoutePath}
path={locationDescriptorToRoutePath(componentRoutePath)}
render={(routerProps) => <CatchRouter {...routerProps} {...props} />}
/>
);
};

interface Router {
history: Partial<H.History>;
history: Partial<History>;
route: {
location: H.Location;
location: LocationDescriptor;
};
}

Expand Down
5 changes: 3 additions & 2 deletions packages/kbn-test/src/jest/utils/testbed/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Store } from 'redux';
import { ReactWrapper } from 'enzyme';
import { LocationDescriptor } from 'history';

export type SetupFunc<T> = (props?: any) => TestBed<T> | Promise<TestBed<T>>;

Expand Down Expand Up @@ -161,11 +162,11 @@ export interface MemoryRouterConfig {
/** Flag to add or not the `MemoryRouter`. If set to `false`, there won't be any router and the component won't be wrapped on a `<Route />`. */
wrapComponent?: boolean;
/** The React Router **initial entries** setting ([see documentation](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/MemoryRouter.md)) */
initialEntries?: string[];
initialEntries?: LocationDescriptor[];
/** The React Router **initial index** setting ([see documentation](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/MemoryRouter.md)) */
initialIndex?: number;
/** The route **path** for the mounted component (defaults to `"/"`) */
componentRoutePath?: string | string[];
componentRoutePath?: LocationDescriptor | LocationDescriptor[];
/** A callBack that will be called with the React Router instance once mounted */
onRouter?: (router: any) => void;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { parseArchive } from './parse_archive';

jest.mock('fs/promises', () => ({
readFile: jest.fn(),
}));

const mockReadFile = jest.requireMock('fs/promises').readFile;

beforeEach(() => {
jest.clearAllMocks();
});

it('parses archives with \\n', async () => {
mockReadFile.mockResolvedValue(
`{
"foo": "abc"
}\n\n{
"foo": "xyz"
}`
);

const archive = await parseArchive('mock');
expect(archive).toMatchInlineSnapshot(`
Array [
Object {
"foo": "abc",
},
Object {
"foo": "xyz",
},
]
`);
});

it('parses archives with \\r\\n', async () => {
mockReadFile.mockResolvedValue(
`{
"foo": "123"
}\r\n\r\n{
"foo": "456"
}`
);

const archive = await parseArchive('mock');
expect(archive).toMatchInlineSnapshot(`
Array [
Object {
"foo": "123",
},
Object {
"foo": "456",
},
]
`);
});
22 changes: 22 additions & 0 deletions packages/kbn-test/src/kbn_client/import_export/parse_archive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import Fs from 'fs/promises';

export interface SavedObject {
id: string;
type: string;
[key: string]: unknown;
}

export async function parseArchive(path: string): Promise<SavedObject[]> {
return (await Fs.readFile(path, 'utf-8'))
.split(/\r?\n\r?\n/)
.filter((line) => !!line)
.map((line) => JSON.parse(line));
}
Loading

0 comments on commit c247917

Please sign in to comment.