Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/elastic/kibana into alert…
Browse files Browse the repository at this point in the history
…ing/use-resolve-in-rule-details
  • Loading branch information
ymao1 committed Aug 12, 2021
2 parents ba27a12 + 2ab5c2c commit 016da6d
Show file tree
Hide file tree
Showing 427 changed files with 9,585 additions and 2,002 deletions.
1 change: 0 additions & 1 deletion docs/developer/advanced/running-elasticsearch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ If many other users will be interacting with your remote cluster, you'll want to
[source,bash]
----
kibana.index: '.{YourGitHubHandle}-kibana'
xpack.task_manager.index: '.{YourGitHubHandle}-task-manager-kibana'
----

==== Running remote clusters
Expand Down
3 changes: 0 additions & 3 deletions docs/settings/task-manager-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ Task Manager runs background tasks by polling for work on an interval. You can
| `xpack.task_manager.request_capacity`
| How many requests can Task Manager buffer before it rejects new requests. Defaults to 1000.

| `xpack.task_manager.index`
| The name of the index used to store task information. Defaults to `.kibana_task_manager`.

| `xpack.task_manager.max_workers`
| The maximum number of tasks that this Kibana instance will run simultaneously. Defaults to 10.
Starting in 8.0, it will not be possible to set the value greater than 100.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This has three major benefits:

[IMPORTANT]
==============================================
Task definitions for alerts and actions are stored in the index specified by <<task-manager-settings, `xpack.task_manager.index`>>. The default is `.kibana_task_manager`.
Task definitions for alerts and actions are stored in the index `.kibana_task_manager`.
You must have at least one replica of this index for production deployments.
Expand Down
7 changes: 6 additions & 1 deletion examples/search_examples/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
"ui": true,
"requiredPlugins": ["navigation", "data", "developerExamples", "kibanaUtils", "share"],
"optionalPlugins": [],
"requiredBundles": ["kibanaReact"]
"requiredBundles": ["kibanaReact"],
"owner": {
"name": "App Services",
"githubTeam": "kibana-app-services"
},
"description": "Examples for using the data plugin search service. Includes examples for searching using the high level search source, or low-level search services, as well as integrating with search sessions."
}
3 changes: 3 additions & 0 deletions packages/kbn-crypto/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}
22 changes: 13 additions & 9 deletions packages/kbn-crypto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")

PKG_BASE_NAME = "kbn-crypto"
PKG_REQUIRE_NAME = "@kbn/crypto"
Expand All @@ -26,22 +27,24 @@ NPM_MODULE_EXTRA_FILES = [
"README.md"
]

SRC_DEPS = [
RUNTIME_DEPS = [
"//packages/kbn-dev-utils",
"@npm//node-forge",
]

TYPES_DEPS = [
"//packages/kbn-dev-utils",
"@npm//@types/flot",
"@npm//@types/jest",
"@npm//@types/node",
"@npm//@types/node-forge",
"@npm//@types/testing-library__jest-dom",
"@npm//resize-observer-polyfill",
"@npm//@emotion/react",
]

DEPS = SRC_DEPS + TYPES_DEPS
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

ts_config(
name = "tsconfig",
Expand All @@ -53,13 +56,14 @@ ts_config(
)

ts_project(
name = "tsc",
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
out_dir = "target",
emit_declaration_only = True,
out_dir = "target_types",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
Expand All @@ -68,7 +72,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":tsc"],
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts"
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts"
}
3 changes: 2 additions & 1 deletion packages/kbn-crypto/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"outDir": "./target/types",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "./target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-crypto/src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@ const testRecords = [
},
];

// FLAKY: https://github.com/elastic/kibana/issues/108043
it.skip('indexes documents using the bulk client helper', async () => {
it('indexes documents using the bulk client helper', async () => {
const client = new MockClient();
client.helpers.bulk.mockImplementation(async () => {});

const progress = new Progress();
const stats = createStats('test', log);
Expand Down Expand Up @@ -186,11 +184,11 @@ it.skip('indexes documents using the bulk client helper', async () => {
"results": Array [
Object {
"type": "return",
"value": Promise {},
"value": undefined,
},
Object {
"type": "return",
"value": Promise {},
"value": undefined,
},
],
}
Expand Down
9 changes: 5 additions & 4 deletions packages/kbn-es-query/src/es_query/build_es_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import { buildQueryFromFilters } from './from_filters';
import { buildQueryFromLucene } from './from_lucene';
import { Filter, Query } from '../filters';
import { IndexPatternBase } from './types';
import { KueryQueryOptions } from '../kuery';

/**
* Configurations to be used while constructing an ES query.
* @public
*/
export interface EsQueryConfig {
export type EsQueryConfig = KueryQueryOptions & {
allowLeadingWildcards: boolean;
queryStringOptions: Record<string, any>;
ignoreFilterIfFieldNotInIndex: boolean;
dateFormatTZ?: string;
}
};

function removeMatchAll<T>(filters: T[]) {
return filters.filter(
Expand Down Expand Up @@ -59,7 +59,8 @@ export function buildEsQuery(
indexPattern,
queriesByLanguage.kuery,
config.allowLeadingWildcards,
config.dateFormatTZ
config.dateFormatTZ,
config.filtersInMustClause
);
const luceneQuery = buildQueryFromLucene(
queriesByLanguage.lucene,
Expand Down
5 changes: 3 additions & 2 deletions packages/kbn-es-query/src/es_query/from_kuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ export function buildQueryFromKuery(
indexPattern: IndexPatternBase | undefined,
queries: Query[] = [],
allowLeadingWildcards: boolean = false,
dateFormatTZ?: string
dateFormatTZ?: string,
filtersInMustClause: boolean = false
) {
const queryASTs = queries.map((query) => {
return fromKueryExpression(query.query, { allowLeadingWildcards });
});

return buildQuery(indexPattern, queryASTs, { dateFormatTZ });
return buildQuery(indexPattern, queryASTs, { dateFormatTZ, filtersInMustClause });
}

function buildQuery(
Expand Down
18 changes: 18 additions & 0 deletions packages/kbn-es-query/src/kuery/functions/and.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ describe('kuery functions', () => {
)
);
});

test("should wrap subqueries in an ES bool query's must clause for scoring if enabled", () => {
const node = nodeTypes.function.buildNode('and', [childNode1, childNode2]);
const result = and.toElasticsearchQuery(node, indexPattern, {
filtersInMustClause: true,
});

expect(result).toHaveProperty('bool');
expect(Object.keys(result).length).toBe(1);
expect(result.bool).toHaveProperty('must');
expect(Object.keys(result.bool).length).toBe(1);

expect(result.bool.must).toEqual(
[childNode1, childNode2].map((childNode) =>
ast.toElasticsearchQuery(childNode, indexPattern)
)
);
});
});
});
});
8 changes: 5 additions & 3 deletions packages/kbn-es-query/src/kuery/functions/and.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import * as ast from '../ast';
import { IndexPatternBase, KueryNode } from '../..';
import { IndexPatternBase, KueryNode, KueryQueryOptions } from '../..';

export function buildNodeParams(children: KueryNode[]) {
return {
Expand All @@ -18,14 +18,16 @@ export function buildNodeParams(children: KueryNode[]) {
export function toElasticsearchQuery(
node: KueryNode,
indexPattern?: IndexPatternBase,
config: Record<string, any> = {},
config: KueryQueryOptions = {},
context: Record<string, any> = {}
) {
const { filtersInMustClause } = config;
const children = node.arguments || [];
const key = filtersInMustClause ? 'must' : 'filter';

return {
bool: {
filter: children.map((child: KueryNode) => {
[key]: children.map((child: KueryNode) => {
return ast.toElasticsearchQuery(child, indexPattern, config, context);
}),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-query/src/kuery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
export { KQLSyntaxError } from './kuery_syntax_error';
export { nodeTypes, nodeBuilder } from './node_types';
export { fromKueryExpression, toElasticsearchQuery } from './ast';
export { DslQuery, KueryNode } from './types';
export { DslQuery, KueryNode, KueryQueryOptions } from './types';
6 changes: 6 additions & 0 deletions packages/kbn-es-query/src/kuery/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ export interface KueryParseOptions {
}

export { nodeTypes } from './node_types';

/** @public */
export interface KueryQueryOptions {
filtersInMustClause?: boolean;
dateFormatTZ?: string;
}
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pageLoadAssetSize:
charts: 95000
cloud: 21076
console: 46091
core: 434325
core: 435325
crossClusterReplication: 65408
dashboard: 374194
dashboardEnhanced: 65646
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-rule-data-utils/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}
25 changes: 18 additions & 7 deletions packages/kbn-rule-data-utils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")

PKG_BASE_NAME = "kbn-rule-data-utils"
PKG_REQUIRE_NAME = "@kbn/rule-data-utils"
Expand All @@ -21,19 +22,27 @@ NPM_MODULE_EXTRA_FILES = [
"package.json",
]

SRC_DEPS = [
RUNTIME_DEPS = [
"//packages/kbn-es-query",
"@npm//@elastic/elasticsearch",
"@npm//tslib",
"@npm//utility-types",
"@npm//@elastic/elasticsearch",
]

TYPES_DEPS = [
"//packages/kbn-es-query",
"@npm//@elastic/elasticsearch",
"@npm//tslib",
"@npm//utility-types",
"@npm//@types/jest",
"@npm//@types/node",
]

DEPS = SRC_DEPS + TYPES_DEPS
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

ts_config(
name = "tsconfig",
Expand All @@ -45,13 +54,15 @@ ts_config(
)

ts_project(
name = "tsc",
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
out_dir = "target",
emit_declaration_only = True,
incremental = False,
out_dir = "target_types",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
Expand All @@ -60,7 +71,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = DEPS + [":tsc"],
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-rule-data-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kbn/rule-data-utils",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true
Expand Down
10 changes: 6 additions & 4 deletions packages/kbn-rule-data-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"outDir": "./target/types",
"stripInternal": false,
"declaration": true,
"declarationMap": true,
"rootDir": "./src",
"emitDeclarationOnly": true,
"incremental": false,
"outDir": "./target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-rule-data-utils/src",
"stripInternal": false,
"types": [
"jest",
"node"
]
},
"include": [
"./src/**/*.ts"
"src/**/*.ts"
]
}
Loading

0 comments on commit 016da6d

Please sign in to comment.