Skip to content

Commit

Permalink
Merge branch 'master' into logs-ui-fix-alert-condition-initial-field-…
Browse files Browse the repository at this point in the history
…selection
  • Loading branch information
weltenwort committed Dec 22, 2020
2 parents 969a22a + 9bc2fcc commit b83c309
Show file tree
Hide file tree
Showing 26 changed files with 199 additions and 96 deletions.
11 changes: 6 additions & 5 deletions docs/user/alerting/alerting-getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,15 @@ image::images/alert-concepts-connectors.svg[Connectors provide a central place t
[float]
=== Summary

An _alert_ consists of conditions, _actions_, and a schedule. When conditions are met, _alert instances_ are created that render _actions_ and invoke them. To make action setup and update easier, actions refer to _connectors_ that centralize the information used to connect with {kib} services and third-party integrations.
An _alert_ consists of conditions, _actions_, and a schedule. When conditions are met, _alert instances_ are created that render _actions_ and invoke them. To make action setup and update easier, actions refer to _connectors_ that centralize the information used to connect with {kib} services and third-party integrations. The following example ties these concepts together:

image::images/alert-concepts-summary.svg[Alerts, actions, alert instances and connectors work together to convert detection into action]

* *Alert*: a specification of the conditions to be detected, the schedule for detection, and the response when detection occurs.
* *Action*: the response to a detected condition defined in the alert. Typically actions specify a service or third party integration along with alert details that will be sent to it.
* *Alert instance*: state tracked by {kib} for every occurrence of a detected condition. Actions as well as controls like muting and re-notification are controlled at the instance level.
* *Connector*: centralized configurations for services and third party integration that are referenced by actions.
. Anytime an *alert*'s conditions are met, an *alert instance* is created. This example checks for servers with average CPU > 0.9. Three servers meet the condition, so three instances are created.
. Instances create *actions* as long as they are not muted or throttled. When actions are created, the template that was setup in the alert is filled with actual values. In this example three actions are created, and the template string {{server}} is replaced with the server name for each instance.
. {kib} invokes the actions, sending them to a 3rd party *integration* like an email service.
. If the 3rd party integration has connection parameters or credentials, {kib} will fetch these from the *connector* referenced in the action.


[float]
[[alerting-concepts-differences]]
Expand Down
2 changes: 1 addition & 1 deletion docs/user/alerting/images/alert-concepts-summary.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/dev/run_find_plugins_with_circular_deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type CircularDepList = Set<string>;
const allowedList: CircularDepList = new Set([
'src/plugins/charts -> src/plugins/discover',
'src/plugins/vis_default_editor -> src/plugins/visualizations',
'src/plugins/vis_default_editor -> src/plugins/visualize',
'src/plugins/visualizations -> src/plugins/visualize',
'x-pack/plugins/actions -> x-pack/plugins/case',
'x-pack/plugins/case -> x-pack/plugins/security_solution',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/apm_oss/server/tutorial/index_pattern.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/plugins/vis_default_editor/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"id": "visDefaultEditor",
"version": "kibana",
"ui": true,
"optionalPlugins": ["visualize"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "data"]
}
16 changes: 8 additions & 8 deletions src/plugins/vis_default_editor/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
* under the License.
*/

export { DefaultEditorController } from './default_editor_controller';
import { PluginInitializerContext } from 'kibana/public';
import { DefaultEditorController } from './default_editor_controller';
import { VisDefaultEditorPlugin } from './plugin';

export { DefaultEditorController };
export { useValidation } from './components/controls/utils';
export * from './components/options';
export { RangesParamEditor, RangeValues } from './components/controls/ranges';
Expand All @@ -26,10 +30,6 @@ export * from './vis_options_props';
export * from './utils';
export { ISchemas, Schemas, Schema } from './schemas';

/** dummy plugin, we just want visDefaultEditor to have its own bundle */
export function plugin() {
return new (class VisDefaultEditor {
setup() {}
start() {}
})();
}
export const plugin = (context: PluginInitializerContext) => {
return new VisDefaultEditorPlugin();
};
40 changes: 40 additions & 0 deletions src/plugins/vis_default_editor/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { CoreSetup, Plugin } from 'kibana/public';

import { VisualizePluginSetup } from '../../visualize/public';
import { DefaultEditorController } from './default_editor_controller';

export interface VisDefaultEditorSetupDependencies {
visualize: VisualizePluginSetup;
}

export class VisDefaultEditorPlugin
implements Plugin<void, void, VisDefaultEditorSetupDependencies, {}> {
public setup(core: CoreSetup, { visualize }: VisDefaultEditorSetupDependencies) {
if (visualize) {
visualize.setDefaultEditor(DefaultEditorController);
}
}

public start() {}

stop() {}
}
5 changes: 2 additions & 3 deletions src/plugins/visualize/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"kibanaUtils",
"kibanaReact",
"home",
"discover",
"visDefaultEditor",
"presentationUtil"
"presentationUtil",
"discover"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { redirectWhenMissing } from '../../../../../kibana_utils/public';
import { getEditBreadcrumbs, getCreateBreadcrumbs } from '../breadcrumbs';
import { VisualizeServices } from '../../types';
import { VisualizeConstants } from '../../visualize_constants';
import { setDefaultEditor } from '../../../services';

const mockDefaultEditorControllerDestroy = jest.fn();
const mockEmbeddableHandlerDestroy = jest.fn();
Expand Down Expand Up @@ -54,10 +55,14 @@ jest.mock('../breadcrumbs', () => ({
getEditBreadcrumbs: jest.fn((text) => text),
getCreateBreadcrumbs: jest.fn((text) => text),
}));
jest.mock('../../../../../vis_default_editor/public', () => ({
DefaultEditorController: jest.fn(() => ({ destroy: mockDefaultEditorControllerDestroy })),
}));
jest.mock('../../../../../kibana_utils/public');

jest.mock('../../../../../kibana_utils/public', () => {
const actual = jest.requireActual('../../../../../kibana_utils/public');
return {
...actual,
redirectWhenMissing: jest.fn(),
};
});

const mockGetVisualizationInstance = jest.requireMock('../get_visualization_instance')
.getVisualizationInstance;
Expand All @@ -69,6 +74,10 @@ describe('useSavedVisInstance', () => {
const eventEmitter = new EventEmitter();

beforeEach(() => {
setDefaultEditor(
jest.fn().mockImplementation(() => ({ destroy: mockDefaultEditorControllerDestroy }))
);

mockServices = ({
...coreStartMock,
toastNotifications,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import { parse } from 'query-string';
import { i18n } from '@kbn/i18n';

import { redirectWhenMissing } from '../../../../../kibana_utils/public';
import { DefaultEditorController } from '../../../../../vis_default_editor/public';

import { getVisualizationInstance } from '../get_visualization_instance';
import { getEditBreadcrumbs, getCreateBreadcrumbs } from '../breadcrumbs';
import { SavedVisInstance, IEditorController, VisualizeServices } from '../../types';
import { VisualizeConstants } from '../../visualize_constants';
import { getDefaultEditor } from '../../../services';

/**
* This effect is responsible for instantiating a saved vis or creating a new one
Expand Down Expand Up @@ -104,7 +104,7 @@ export const useSavedVisInstance = (
// do not create editor in embeded mode
if (visEditorRef.current) {
if (isChromeVisible) {
const Editor = vis.type.editor || DefaultEditorController;
const Editor = vis.type.editor || getDefaultEditor();
visEditorController = new Editor(
visEditorRef.current,
vis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { VisualizeInput } from 'src/plugins/visualizations/public';
import { ByValueVisInstance, IEditorController, VisualizeServices } from '../../types';
import { getVisualizationInstanceFromInput } from '../get_visualization_instance';
import { getBreadcrumbsPrefixedWithApp, getEditBreadcrumbs } from '../breadcrumbs';
import { DefaultEditorController } from '../../../../../vis_default_editor/public';
import { getDefaultEditor } from '../../../services';

export const useVisByValue = (
services: VisualizeServices,
Expand All @@ -46,7 +46,8 @@ export const useVisByValue = (
}
const byValueVisInstance = await getVisualizationInstanceFromInput(services, valueInput);
const { embeddableHandler, vis } = byValueVisInstance;
const Editor = vis.type.editor || DefaultEditorController;

const Editor = vis.type.editor || getDefaultEditor();
const visEditorController = new Editor(
visEditorRef.current,
vis,
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/visualize/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { PluginInitializerContext } from 'kibana/public';
import { VisualizePlugin } from './plugin';
import { VisualizePlugin, VisualizePluginSetup } from './plugin';

export type {
EditorRenderProps,
Expand All @@ -27,6 +27,8 @@ export type {
} from './application/types';
export { VisualizeConstants } from './application/visualize_constants';

export { VisualizePluginSetup };

export const plugin = (context: PluginInitializerContext) => {
return new VisualizePlugin(context);
};
20 changes: 18 additions & 2 deletions src/plugins/visualize/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { UrlForwardingSetup, UrlForwardingStart } from '../../url_forwarding/pub
import { VisualizationsStart } from '../../visualizations/public';
import { VisualizeConstants } from './application/visualize_constants';
import { FeatureCatalogueCategory, HomePublicPluginSetup } from '../../home/public';
import { VisualizeServices } from './application/types';
import { VisEditorConstructor, VisualizeServices } from './application/types';
import { DEFAULT_APP_CATEGORIES } from '../../../core/public';
import { SavedObjectsStart } from '../../saved_objects/public';
import { EmbeddableStart } from '../../embeddable/public';
Expand All @@ -57,6 +57,7 @@ import {
setIndexPatterns,
setQueryService,
setShareService,
setDefaultEditor,
} from './services';
import { visualizeFieldAction } from './actions/visualize_field_action';
import { createVisualizeUrlGenerator } from './url_generator';
Expand All @@ -81,9 +82,18 @@ export interface VisualizePluginSetupDependencies {
uiActions: UiActionsSetup;
}

export interface VisualizePluginSetup {
setDefaultEditor: (editor: VisEditorConstructor) => void;
}

export class VisualizePlugin
implements
Plugin<void, void, VisualizePluginSetupDependencies, VisualizePluginStartDependencies> {
Plugin<
VisualizePluginSetup,
void,
VisualizePluginSetupDependencies,
VisualizePluginStartDependencies
> {
private appStateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
private stopUrlTracking: (() => void) | undefined = undefined;
private currentHistory: ScopedHistory | undefined = undefined;
Expand Down Expand Up @@ -231,6 +241,12 @@ export class VisualizePlugin
category: FeatureCatalogueCategory.DATA,
});
}

return {
setDefaultEditor: (editor) => {
setDefaultEditor(editor);
},
} as VisualizePluginSetup;
}

public start(core: CoreStart, plugins: VisualizePluginStartDependencies) {
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/visualize/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ApplicationStart, IUiSettingsClient } from '../../../core/public';
import { createGetterSetter } from '../../../plugins/kibana_utils/public';
import { IndexPatternsContract, DataPublicPluginStart } from '../../../plugins/data/public';
import { SharePluginStart } from '../../../plugins/share/public';
import { VisEditorConstructor } from './application/types';

export const [getUISettings, setUISettings] = createGetterSetter<IUiSettingsClient>('UISettings');

Expand All @@ -32,6 +33,10 @@ export const [getIndexPatterns, setIndexPatterns] = createGetterSetter<IndexPatt
'IndexPatterns'
);

export const [getDefaultEditor, setDefaultEditor] = createGetterSetter<VisEditorConstructor>(
'DefaultEditor'
);

export const [getQueryService, setQueryService] = createGetterSetter<
DataPublicPluginStart['query']
>('Query');
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,32 @@ describe('SearchExperienceContent', () => {
expect(wrapper.isEmptyRender()).toBe(false);
});

it('passes engineName and schema to the result view', () => {
const props = {
result: {
id: {
raw: '1',
},
_meta: {
id: '1',
scopedId: '1',
score: 100,
engine: 'my-engine',
},
foo: {
raw: 'bar',
},
it('passes result, schema, and isMetaEngine to the result view', () => {
const result = {
id: {
raw: '1',
},
schemaForTypeHighlights: {
title: 'string' as SchemaTypes,
_meta: {
id: '1',
score: 100,
engine: 'my-engine',
},
foo: {
raw: 'bar',
},
};

const wrapper = shallow(<SearchExperienceContent />);
const resultView: any = wrapper.find(Results).prop('resultView');
expect(resultView(props)).toEqual(<ResultView {...props} />);
expect(resultView({ result })).toEqual(
<ResultView
{...{
isMetaEngine: values.isMetaEngine,
result,
schemaForTypeHighlights: values.engine.schema,
}}
/>
);
});

it('renders pagination', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import { useValues } from 'kea';

import { ResultView } from './views';
import { Pagination } from './pagination';
import { Props as ResultViewProps } from './views/result_view';
import { useSearchContextState } from './hooks';
import { DocumentCreationButton } from '../document_creation_button';
import { AppLogic } from '../../../app_logic';
import { EngineLogic } from '../../engine';
import { DOCS_PREFIX } from '../../../routes';
import { Result } from '../../result/types';

export const SearchExperienceContent: React.FC = () => {
const { resultSearchTerm, totalResults, wasSearched } = useSearchContextState();
Expand All @@ -43,8 +43,14 @@ export const SearchExperienceContent: React.FC = () => {
<EuiSpacer />
<Results
titleField="id"
resultView={(props: ResultViewProps) => {
return <ResultView {...props} schemaForTypeHighlights={engine.schema} />;
resultView={({ result }: { result: Result }) => {
return (
<ResultView
result={result}
schemaForTypeHighlights={engine.schema}
isMetaEngine={isMetaEngine}
/>
);
}}
/>
<EuiSpacer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('ResultView', () => {
},
_meta: {
id: '1',
scopedId: '1',
score: 100,
engine: 'my-engine',
},
Expand All @@ -33,11 +32,14 @@ describe('ResultView', () => {
};

it('renders', () => {
const wrapper = shallow(<ResultView result={result} schemaForTypeHighlights={schema} />);
const wrapper = shallow(
<ResultView result={result} schemaForTypeHighlights={schema} isMetaEngine={true} />
);
expect(wrapper.find(Result).props()).toEqual({
result,
shouldLinkToDetailPage: true,
schemaForTypeHighlights: schema,
isMetaEngine: true,
});
});
});
Loading

0 comments on commit b83c309

Please sign in to comment.