Skip to content

Commit

Permalink
Merge branch 'master' into apm-70422-anomaly-detection-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 7, 2020
2 parents 12c55d0 + f62f3e3 commit 680ea4b
Show file tree
Hide file tree
Showing 317 changed files with 15,029 additions and 4,202 deletions.
1 change: 1 addition & 0 deletions docs/apm/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ allowing you to easily see how these events are impacting the performance of you

By default, annotations are stored in a newly created `observability-annotations` index.
The name of this index can be changed in your `config.yml` by editing `xpack.observability.annotations.index`.
If you change the default index name, you'll also need to <<apm-app-annotation-user-create,update your user privileges>> accordingly.

The following APIs are available:

Expand Down
50 changes: 49 additions & 1 deletion docs/apm/apm-app-users.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

:beat_default_index_prefix: apm
:beat_kib_app: APM app
:annotation_index: `observability-annotations`
:annotation_index: observability-annotations

++++
<titleabbrev>Users and privileges</titleabbrev>
Expand Down Expand Up @@ -102,6 +102,54 @@ Here are two examples:
*********************************** ***********************************
////

[role="xpack"]
[[apm-app-annotation-user-create]]
=== APM app annotation user

++++
<titleabbrev>Create an annotation user</titleabbrev>
++++

NOTE: By default, the `apm_user` built-in role provides access to Observability annotations.
You only need to create an annotation user if the default annotation index
defined in <<apm-settings-kb,`xpack.observability.annotations.index`>> has been customized.

[[apm-app-annotation-user]]
==== Annotation user

View deployment annotations in the APM app.

. Create a new role, named something like `annotation_user`,
and assign the following privileges:
+
[options="header"]
|====
|Type | Privilege | Purpose

|Index
|`read` on +\{ANNOTATION_INDEX\}+^1^
|Read-only access to the observability annotation index

|Index
|`view_index_metadata` on +\{ANNOTATION_INDEX\}+^1^
|Read-only access to observability annotation index metadata
|====
+
^1^ +\{ANNOTATION_INDEX\}+ should be the index name you've defined in
<<apm-settings-kb,`xpack.observability.annotations.index`>>.

. Assign the `annotation_user` created previously, and the built-in roles necessary to create
a <<apm-app-reader-full,full>> or <<apm-app-reader-partial,partial>> APM reader to any users that need to view annotations in the APM app

[[apm-app-annotation-api]]
==== Annotation API

See <<apm-app-api-user>>.

////
*********************************** ***********************************
////

[role="xpack"]
[[apm-app-central-config-user]]
=== APM app central config user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ two out-of-the box connectors: <<slack-action-type, Slack>> and <<webhook-action
my-slack1: <1>
actionTypeId: .slack <2>
name: 'Slack #xyz' <3>
secrets: <4>
secrets:
webhookUrl: 'https://hooks.slack.com/services/abcd/efgh/ijklmnopqrstuvwxyz'
webhook-service:
actionTypeId: .webhook
name: 'Email service'
config:
config: <4>
url: 'https://email-alert-service.elastic.co'
method: post
headers:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,10 @@
"is-path-inside": "^2.1.0",
"istanbul-instrumenter-loader": "3.0.1",
"jest": "^25.5.4",
"jest-environment-jsdom-thirteen": "^1.0.1",
"jest-canvas-mock": "^2.2.0",
"jest-circus": "^25.5.4",
"jest-cli": "^25.5.4",
"jest-environment-jsdom-thirteen": "^1.0.1",
"jest-raw-loader": "^1.0.1",
"jimp": "^0.9.6",
"json5": "^1.0.1",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { inspect } from 'util';

import cpy from 'cpy';
import del from 'del';
import { toArray, tap } from 'rxjs/operators';
import { toArray, tap, filter } from 'rxjs/operators';
import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
import { runOptimizer, OptimizerConfig, OptimizerUpdate, logOptimizerState } from '@kbn/optimizer';

Expand Down Expand Up @@ -63,8 +63,7 @@ afterAll(async () => {
await del(TMP_DIR);
});

// FLAKY: https://github.com/elastic/kibana/issues/70762
it.skip('builds expected bundles, saves bundle counts to metadata', async () => {
it('builds expected bundles, saves bundle counts to metadata', async () => {
const config = OptimizerConfig.create({
repoRoot: MOCK_REPO_DIR,
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
Expand All @@ -75,7 +74,11 @@ it.skip('builds expected bundles, saves bundle counts to metadata', async () =>
expect(config).toMatchSnapshot('OptimizerConfig');

const msgs = await runOptimizer(config)
.pipe(logOptimizerState(log, config), toArray())
.pipe(
logOptimizerState(log, config),
filter((x) => x.event?.type !== 'worker stdio'),
toArray()
)
.toPromise();

const assert = (statement: string, truth: boolean, altStates?: OptimizerUpdate[]) => {
Expand Down Expand Up @@ -168,8 +171,7 @@ it.skip('builds expected bundles, saves bundle counts to metadata', async () =>
`);
});

// FLAKY: https://github.com/elastic/kibana/issues/70764
it.skip('uses cache on second run and exist cleanly', async () => {
it('uses cache on second run and exist cleanly', async () => {
const config = OptimizerConfig.create({
repoRoot: MOCK_REPO_DIR,
pluginScanDirs: [Path.resolve(MOCK_REPO_DIR, 'plugins')],
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

29 changes: 27 additions & 2 deletions src/plugins/expressions/common/execution/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { keys, last, mapValues, reduce, zipObject } from 'lodash';
import { Executor } from '../executor';
import { Executor, ExpressionExecOptions } from '../executor';
import { createExecutionContainer, ExecutionContainer } from './container';
import { createError } from '../util';
import { Defer, now } from '../../../kibana_utils/common';
Expand All @@ -31,6 +31,7 @@ import {
parse,
formatExpression,
parseExpression,
ExpressionAstNode,
} from '../ast';
import { ExecutionContext, DefaultInspectorAdapters } from './types';
import { getType, ExpressionValue } from '../expression_types';
Expand Down Expand Up @@ -382,7 +383,7 @@ export class Execution<
const resolveArgFns = mapValues(argAstsWithDefaults, (asts, argName) => {
return asts.map((item: ExpressionAstExpression) => {
return async (subInput = input) => {
const output = await this.params.executor.interpret(item, subInput, {
const output = await this.interpret(item, subInput, {
debug: this.params.debug,
});
if (isExpressionValueError(output)) throw output.error;
Expand Down Expand Up @@ -415,4 +416,28 @@ export class Execution<
// function which would be treated as a promise
return { resolvedArgs };
}

public async interpret<T>(
ast: ExpressionAstNode,
input: T,
options?: ExpressionExecOptions
): Promise<unknown> {
switch (getType(ast)) {
case 'expression':
const execution = this.params.executor.createExecution(
ast as ExpressionAstExpression,
this.context,
options
);
execution.start(input);
return await execution.result;
case 'string':
case 'number':
case 'null':
case 'boolean':
return ast;
default:
throw new Error(`Unknown AST object: ${JSON.stringify(ast)}`);
}
}
}
Loading

0 comments on commit 680ea4b

Please sign in to comment.