Skip to content

Commit

Permalink
Merge branch 'master' into ml-apm-correlations-page
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Aug 13, 2021
2 parents e5b2aae + d78d66d commit 77a3564
Show file tree
Hide file tree
Showing 162 changed files with 3,567 additions and 1,467 deletions.
6 changes: 3 additions & 3 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Fetch Node.js rules
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "8f5f192ba02319254aaf2cdcca00ec12eaafeb979a80a1e946773c520ae0a2c9",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.7.0/rules_nodejs-3.7.0.tar.gz"],
sha256 = "e79c08a488cc5ac40981987d862c7320cee8741122a2649e9b08e850b6f20442",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.8.0/rules_nodejs-3.8.0.tar.gz"],
)

# Now that we have the rules let's import from them to complete the work
load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "yarn_install")

# Assure we have at least a given rules_nodejs version
check_rules_nodejs_version(minimum_version_string = "3.7.0")
check_rules_nodejs_version(minimum_version_string = "3.8.0")

# Setup the Node.js toolchain for the architectures we want to support
#
Expand Down
2 changes: 2 additions & 0 deletions docs/apm/agent-configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ For this reason, it is still essential to set custom default configurations loca
==== APM Server setup

This feature requires {apm-server-ref}/setup-kibana-endpoint.html[Kibana endpoint configuration] in APM Server.
In addition, if an APM agent is using {apm-server-ref}/configuration-anonymous.html[anonymous authentication] to communicate with the APM Server,
the agent's service name must be included in the `apm-server.auth.anonymous.allow_service` list.

APM Server acts as a proxy between the agents and Kibana.
Kibana communicates any changed settings to APM Server so that your agents only need to poll APM Server to determine which settings have changed.
Expand Down
Binary file added docs/maps/images/app_gis_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 12 additions & 11 deletions docs/maps/maps-getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ refer to <<xpack-security-authorization,Granting access to {kib}>>.
. Open the main menu, and then click *Dashboard*.
. Click **Create dashboard**.
. Set the time range to *Last 7 days*.
. Click **Create panel**.
. Click **Maps**.
. Click the **Create new Maps** icon image:maps/images/app_gis_icon.png[]

[float]
[[maps-add-choropleth-layer]]
Expand All @@ -62,14 +61,15 @@ and lighter shades will symbolize countries with less traffic.

. Add a Tooltip field:

** Select **ISO 3166-1 alpha-2 code** and **name**.
** Click **Add**.
** **ISO 3166-1 alpha-2 code** is added by default.
** Click **+ Add** to open field select.
** Select **name** and click *Add*.

. In **Layer style**, set:
. In **Layer style**:

** **Fill color: As number** to the grey color ramp
** **Border color** to white
** **Label** to symbol label
** Set **Fill color: As number** to the grey color ramp.
** Set **Border color** to white.
** Under **Label**, change **By value** to **Fixed**.

. Click **Save & close**.
+
Expand Down Expand Up @@ -135,9 +135,10 @@ grids with less bytes transferred.
** **Name** to `Total Requests and Bytes`
** **Visibility** to the range [0, 9]
** **Opacity** to 100%
. In **Metrics**, use:
** **Agregation** set to **Count**, and
** **Aggregation** set to **Sum** with **Field** set to **bytes**
. In **Metrics**:
** Set **Agregation** to **Count**.
** Click **Add metric**.
** Set **Aggregation** to **Sum** with **Field** set to **bytes**.
. In **Layer style**, change **Symbol size**:
** Set the field select to *sum bytes*.
** Set the min size to 7 and the max size to 25 px.
Expand Down
2 changes: 2 additions & 0 deletions docs/maps/vector-layer.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ To add a vector layer to your map, click *Add layer*, then select one of the fol
*Clusters and grids*:: Geospatial data grouped in grids with metrics for each gridded cell.
The index must contain at least one field mapped as {ref}/geo-point.html[geo_point] or {ref}/geo-shape.html[geo_shape].

*Create index*:: Draw shapes on the map and index in Elasticsearch.

*Documents*:: Points, lines, and polyons from Elasticsearch.
The index must contain at least one field mapped as {ref}/geo-point.html[geo_point] or {ref}/geo-shape.html[geo_shape].
+
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@
"@babel/traverse": "^7.12.12",
"@babel/types": "^7.12.12",
"@bazel/ibazel": "^0.15.10",
"@bazel/typescript": "^3.7.0",
"@bazel/typescript": "^3.8.0",
"@cypress/snapshot": "^2.1.7",
"@cypress/webpack-preprocessor": "^5.6.0",
"@elastic/eslint-config-kibana": "link:bazel-bin/packages/elastic-eslint-config-kibana",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-es-archiver/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}
25 changes: 19 additions & 6 deletions packages/kbn-es-archiver/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-es-archiver"
PKG_REQUIRE_NAME = "@kbn/es-archiver"
Expand Down Expand Up @@ -27,7 +28,7 @@ NPM_MODULE_EXTRA_FILES = [
"package.json",
]

SRC_DEPS = [
RUNTIME_DEPS = [
"//packages/kbn-dev-utils",
"//packages/kbn-test",
"//packages/kbn-utils",
Expand All @@ -43,6 +44,13 @@ SRC_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-dev-utils",
"//packages/kbn-test",
"//packages/kbn-utils",
"@npm//@elastic/elasticsearch",
"@npm//aggregate-error",
"@npm//globby",
"@npm//zlib",
"@npm//@types/bluebird",
"@npm//@types/chance",
"@npm//@types/jest",
Expand All @@ -52,7 +60,11 @@ TYPES_DEPS = [
"@npm//@types/sinon",
]

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

ts_config(
name = "tsconfig",
Expand All @@ -64,13 +76,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 @@ -79,7 +92,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-es-archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": "true",
"main": "target/index.js",
"types": "target/index.d.ts",
"main": "target_node/index.js",
"types": "target_types/index.d.ts",
"kibana": {
"devOnly": true
}
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-es-archiver/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",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-es-archiver/src",
"types": [
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-io-ts-utils/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}
22 changes: 16 additions & 6 deletions packages/kbn-io-ts-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-io-ts-utils"
PKG_REQUIRE_NAME = "@kbn/io-ts-utils"
Expand All @@ -24,7 +25,7 @@ NPM_MODULE_EXTRA_FILES = [
"package.json",
]

SRC_DEPS = [
RUNTIME_DEPS = [
"//packages/kbn-config-schema",
"@npm//fp-ts",
"@npm//io-ts",
Expand All @@ -33,12 +34,20 @@ SRC_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-config-schema",
"@npm//fp-ts",
"@npm//io-ts",
"@npm//tslib",
"@npm//@types/jest",
"@npm//@types/lodash",
"@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 @@ -50,13 +59,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 @@ -65,7 +75,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-io-ts-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@kbn/io-ts-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
1 change: 1 addition & 0 deletions packages/kbn-io-ts-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

export { deepExactRt } from './deep_exact_rt';
export { jsonRt } from './json_rt';
export { mergeRt } from './merge_rt';
export { strictKeysRt } from './strict_keys_rt';
Expand Down
6 changes: 4 additions & 2 deletions packages/kbn-io-ts-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"outDir": "./target/types",
"stripInternal": false,
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "./target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-io-ts-utils/src",
"stripInternal": false,
"types": [
"jest",
"node"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import React from 'react';
import * as t from 'io-ts';
import { toNumberRt } from '@kbn/io-ts-utils/target/to_number_rt';
import { toNumberRt } from '@kbn/io-ts-utils';
import { createRouter } from './create_router';
import { createMemoryHistory } from 'history';
import { route } from './route';
Expand Down
10 changes: 8 additions & 2 deletions packages/kbn-typed-react-router-config/src/create_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ import {
} from 'react-router-config';
import qs from 'query-string';
import { findLastIndex, merge, compact } from 'lodash';
import { deepExactRt } from '@kbn/io-ts-utils/target/deep_exact_rt';
import { mergeRt } from '@kbn/io-ts-utils/target/merge_rt';
import type { deepExactRt as deepExactRtTyped, mergeRt as mergeRtTyped } from '@kbn/io-ts-utils';
// @ts-expect-error
import { deepExactRt as deepExactRtNonTyped } from '@kbn/io-ts-utils/target_node/deep_exact_rt';
// @ts-expect-error
import { mergeRt as mergeRtNonTyped } from '@kbn/io-ts-utils/target_node/merge_rt';
import { Route, Router } from './types';

const deepExactRt: typeof deepExactRtTyped = deepExactRtNonTyped;
const mergeRt: typeof mergeRtTyped = mergeRtNonTyped;

export function createRouter<TRoutes extends Route[]>(routes: TRoutes): Router<TRoutes> {
const routesByReactRouterConfig = new Map<ReactRouterConfig, Route>();
const reactRouterConfigsByRoute = new Map<Route, ReactRouterConfig>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ type SavedObjectType = SavedObject<{ title?: string }>;
type CheckOriginConflictsParams = Parameters<typeof checkOriginConflicts>[0];

/**
* Function to create a realistic-looking import object given a type, ID, and optional originId
* Function to create a realistic-looking import object given a type, ID, optional originId, and optional updated_at
*/
const createObject = (type: string, id: string, originId?: string): SavedObjectType => ({
const createObject = (
type: string,
id: string,
originId?: string,
updatedAt?: string
): SavedObjectType => ({
type,
id,
attributes: { title: `Title for ${type}:${id}` },
references: (Symbol() as unknown) as SavedObjectReference[],
...(originId && { originId }),
...(updatedAt && { updated_at: updatedAt }),
});

const MULTI_NS_TYPE = 'multi';
Expand Down Expand Up @@ -389,21 +395,21 @@ describe('#checkOriginConflicts', () => {
// try to import obj1 and obj2
const obj1 = createObject(MULTI_NS_TYPE, 'id-1');
const obj2 = createObject(MULTI_NS_TYPE, 'id-2', 'originId-foo');
const objA = createObject(MULTI_NS_TYPE, 'id-A', obj1.id);
const objB = createObject(MULTI_NS_TYPE, 'id-B', obj1.id);
const objA = createObject(MULTI_NS_TYPE, 'id-A', obj1.id, '2017-09-21T18:59:16.270Z');
const objB = createObject(MULTI_NS_TYPE, 'id-B', obj1.id, '2021-08-10T13:21:44.135Z');
const objC = createObject(MULTI_NS_TYPE, 'id-C', obj2.originId);
const objD = createObject(MULTI_NS_TYPE, 'id-D', obj2.originId);
const objects = [obj1, obj2];
const params = setupParams({ objects });
mockFindResult(objA, objB); // find for obj1: the result is an inexact match with two destinations
mockFindResult(objC, objD); // find for obj2: the result is an inexact match with two destinations
mockFindResult(objD, objC); // find for obj2: the result is an inexact match with two destinations

const checkOriginConflictsResult = await checkOriginConflicts(params);
const expectedResult = {
importIdMap: new Map(),
errors: [
createAmbiguousConflictError(obj1, [objA, objB]),
createAmbiguousConflictError(obj2, [objC, objD]),
createAmbiguousConflictError(obj1, [objB, objA]), // Assert that these have been sorted by updatedAt in descending order
createAmbiguousConflictError(obj2, [objC, objD]), // Assert that these have been sorted by ID in ascending order (since their updatedAt values are the same)
],
pendingOverwrites: new Set(),
};
Expand Down
20 changes: 15 additions & 5 deletions src/core/server/saved_objects/import/lib/check_origin_conflicts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,21 @@ const createQuery = (type: string, id: string, rawIdPrefix: string) =>
const transformObjectsToAmbiguousConflictFields = (
objects: Array<SavedObject<{ title?: string }>>
) =>
objects.map(({ id, attributes, updated_at: updatedAt }) => ({
id,
title: attributes?.title,
updatedAt,
}));
objects
.map(({ id, attributes, updated_at: updatedAt }) => ({
id,
title: attributes?.title,
updatedAt,
}))
// Sort to ensure that integration tests are not flaky
.sort((a, b) => {
const aUpdatedAt = a.updatedAt ?? '';
const bUpdatedAt = b.updatedAt ?? '';
if (aUpdatedAt !== bUpdatedAt) {
return aUpdatedAt < bUpdatedAt ? 1 : -1; // descending
}
return a.id < b.id ? -1 : 1; // ascending
});
const getAmbiguousConflictSourceKey = <T>({ object }: InexactMatch<T>) =>
`${object.type}:${object.originId || object.id}`;

Expand Down
Loading

0 comments on commit 77a3564

Please sign in to comment.