Skip to content

Commit

Permalink
Merge branch 'master' into collect-code-coverage-for-jest-integration…
Browse files Browse the repository at this point in the history
…-tests
  • Loading branch information
kibanamachine authored Nov 21, 2020
2 parents a03f90a + 3ee6e47 commit 6295ce1
Show file tree
Hide file tree
Showing 31 changed files with 239 additions and 197 deletions.
42 changes: 21 additions & 21 deletions docs/user/dashboard/drilldowns.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
== Create custom dashboard actions

Custom dashboard actions, also known as drilldowns, allow you to create
workflows for analyzing and troubleshooting your data. Drilldowns apply only to the panel that you created the drilldown from, and are not shared across all of the panels. Each panel can have multiple drilldowns.
workflows for analyzing and troubleshooting your data. Drilldowns apply only to the panel that you created the drilldown from, and are not shared across all of the panels. Each panel can have multiple drilldowns.

Third-party developers can create drilldowns. To learn how to code drilldowns, refer to {kib-repo}blob/{branch}/x-pack/examples/ui_actions_enhanced_examples[this example plugin].

Expand All @@ -28,7 +28,7 @@ Dashboard drilldowns enable you to open a dashboard from another dashboard,
taking the time range, filters, and other parameters with you,
so the context remains the same. Dashboard drilldowns help you to continue your analysis from a new perspective.

For example, if you have a dashboard that shows the overall status of multiple data center,
For example, if you have a dashboard that shows the overall status of multiple data center,
you can create a drilldown that navigates from the overall status dashboard to a dashboard
that shows a single data center or server.

Expand All @@ -41,14 +41,14 @@ Destination URLs can be dynamic, depending on the dashboard context or user inte
For example, if you have a dashboard that shows data from a Github repository, you can create a URL drilldown
that opens Github from the dashboard.

Some panels support multiple interactions, also known as triggers.
Some panels support multiple interactions, also known as triggers.
The <<variables,variables>> you use to create a <<url_templating, URL template>> depends on the trigger you choose. URL drilldowns support these types of triggers:

* *Single click* &mdash; A single data point in the visualization.

* *Range selection* &mdash; A range of values in a visualization.

For example, *Single click* has `{{event.value}}` and *Range selection* has `{{event.from}}` and `{{event.to}}`.
For example, *Single click* has `{{event.value}}` and *Range selection* has `{{event.from}}` and `{{event.to}}`.

To disable URL drilldowns on your {kib} instance, disable the plugin:

Expand Down Expand Up @@ -77,20 +77,20 @@ The following panels support dashboard and URL drilldowns.
^| X

| Controls
^|
^|
^|
^|

| Data Table
^| X
^| X

| Gauge
^|
^|
^|
^|

| Goal
^|
^|
^|
^|

| Heat map
^| X
Expand All @@ -106,35 +106,35 @@ The following panels support dashboard and URL drilldowns.

| Maps
^| X
^|
^| X

| Markdown
^|
^|
^|
^|

| Metric
^|
^|
^|
^|

| Pie
^| X
^| X

| TSVB
^| X
^|
^|

| Tag Cloud
^| X
^| X

| Timelion
^| X
^|
^|

| Vega
^| X
^|
^|

| Vertical Bar
^| X
Expand Down Expand Up @@ -192,7 +192,7 @@ image::images/drilldown_create.png[Create drilldown with entries for drilldown n

. Click *Create drilldown*.
+
The drilldown is stored as dashboard metadata.
The drilldown is stored as dashboard metadata.

. Save the dashboard.
+
Expand Down Expand Up @@ -226,7 +226,7 @@ image:images/url_drilldown_go_to_github.gif[Drilldown on pie chart that navigate

.. Select *Go to URL*.

.. Enter the URL template:
.. Enter the URL template:
+
[source, bash]
----
Expand All @@ -240,7 +240,7 @@ image:images/url_drilldown_url_template.png[URL template input]

.. Click *Create drilldown*.
+
The drilldown is stored as dashboard metadata.
The drilldown is stored as dashboard metadata.

. Save the dashboard.
+
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ The PagerDuty action uses the [V2 Events API](https://v2.developer.pagerduty.com
| Property | Description | Type |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
| eventAction | One of `trigger` _(default)_, `resolve`, or `acknowlege`. See [event action](https://v2.developer.pagerduty.com/docs/events-api-v2#event-action) for more details. | string _(optional)_ |
| dedupKey | All actions sharing this key will be associated with the same PagerDuty alert. Used to correlate trigger and resolution. The maximum length is **255** characters. See [alert deduplication](https://v2.developer.pagerduty.com/docs/events-api-v2#alert-de-duplication) for details. | string _(optional)_ |
| dedupKey | All actions sharing this key will be associated with the same PagerDuty alert. Used to correlate trigger and resolution. Defaults to `action:<action id>`. The maximum length is **255** characters. See [alert deduplication](https://v2.developer.pagerduty.com/docs/events-api-v2#alert-de-duplication) for details. | string _(optional)_ |
| summary | A text summary of the event, defaults to `No summary provided`. The maximum length is **1024** characters. | string _(optional)_ |
| source | The affected system, preferably a hostname or fully qualified domain name. Defaults to `Kibana Action <action id>`. | string _(optional)_ |
| severity | The perceived severity of on the affected system. This can be one of `critical`, `error`, `warning` or `info`_(default)_. | string _(optional)_ |
Expand Down
51 changes: 25 additions & 26 deletions x-pack/plugins/actions/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { first, map } from 'rxjs/operators';
import { first } from 'rxjs/operators';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { Observable } from 'rxjs';
import {
PluginInitializerContext,
Plugin,
CoreSetup,
CoreStart,
KibanaRequest,
Logger,
SharedGlobalConfig,
RequestHandler,
IContextProvider,
ElasticsearchServiceStart,
Expand Down Expand Up @@ -128,7 +128,6 @@ const includedHiddenTypes = [
];

export class ActionsPlugin implements Plugin<Promise<PluginSetupContract>, PluginStartContract> {
private readonly kibanaIndex: Promise<string>;
private readonly config: Promise<ActionsConfig>;

private readonly logger: Logger;
Expand All @@ -143,20 +142,14 @@ export class ActionsPlugin implements Plugin<Promise<PluginSetupContract>, Plugi
private isESOUsingEphemeralEncryptionKey?: boolean;
private readonly telemetryLogger: Logger;
private readonly preconfiguredActions: PreConfiguredAction[];
private readonly kibanaIndexConfig: Observable<{ kibana: { index: string } }>;

constructor(initContext: PluginInitializerContext) {
this.config = initContext.config.create<ActionsConfig>().pipe(first()).toPromise();

this.kibanaIndex = initContext.config.legacy.globalConfig$
.pipe(
first(),
map((config: SharedGlobalConfig) => config.kibana.index)
)
.toPromise();

this.logger = initContext.logger.get('actions');
this.telemetryLogger = initContext.logger.get('usage');
this.preconfiguredActions = [];
this.kibanaIndexConfig = initContext.config.legacy.globalConfig$;
}

public async setup(
Expand Down Expand Up @@ -220,22 +213,26 @@ export class ActionsPlugin implements Plugin<Promise<PluginSetupContract>, Plugi

const usageCollection = plugins.usageCollection;
if (usageCollection) {
initializeActionsTelemetry(
this.telemetryLogger,
plugins.taskManager,
core,
await this.kibanaIndex
registerActionsUsageCollector(
usageCollection,
core.getStartServices().then(([_, { taskManager }]) => taskManager)
);

core.getStartServices().then(async ([, startPlugins]) => {
registerActionsUsageCollector(usageCollection, startPlugins.taskManager);
});
}

core.http.registerRouteHandlerContext(
'actions',
this.createRouteHandlerContext(core, await this.kibanaIndex)
);
this.kibanaIndexConfig.subscribe((config) => {
core.http.registerRouteHandlerContext(
'actions',
this.createRouteHandlerContext(core, config.kibana.index)
);
if (usageCollection) {
initializeActionsTelemetry(
this.telemetryLogger,
plugins.taskManager,
core,
config.kibana.index
);
}
});

// Routes
const router = core.http.createRouter();
Expand Down Expand Up @@ -269,7 +266,7 @@ export class ActionsPlugin implements Plugin<Promise<PluginSetupContract>, Plugi
actionExecutor,
actionTypeRegistry,
taskRunnerFactory,
kibanaIndex,
kibanaIndexConfig,
isESOUsingEphemeralEncryptionKey,
preconfiguredActions,
instantiateAuthorization,
Expand Down Expand Up @@ -297,10 +294,12 @@ export class ActionsPlugin implements Plugin<Promise<PluginSetupContract>, Plugi
request
);

const kibanaIndex = (await kibanaIndexConfig.pipe(first()).toPromise()).kibana.index;

return new ActionsClient({
unsecuredSavedObjectsClient,
actionTypeRegistry: actionTypeRegistry!,
defaultKibanaIndex: await kibanaIndex,
defaultKibanaIndex: kibanaIndex,
scopedClusterClient: core.elasticsearch.legacy.client.asScoped(request),
preconfiguredActions,
request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ describe('registerActionsUsageCollector', () => {
it('should call registerCollector', () => {
registerActionsUsageCollector(
usageCollectionMock as UsageCollectionSetup,
mockTaskManagerStart
new Promise(() => mockTaskManagerStart)
);
expect(usageCollectionMock.registerCollector).toHaveBeenCalledTimes(1);
});

it('should call makeUsageCollector with type = actions', () => {
registerActionsUsageCollector(
usageCollectionMock as UsageCollectionSetup,
mockTaskManagerStart
new Promise(() => mockTaskManagerStart)
);
expect(usageCollectionMock.makeUsageCollector).toHaveBeenCalledTimes(1);
expect(usageCollectionMock.makeUsageCollector.mock.calls[0][0].type).toBe('actions');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ const byTypeSchema: MakeSchemaFrom<ActionsUsage>['count_by_type'] = {

export function createActionsUsageCollector(
usageCollection: UsageCollectionSetup,
taskManager: TaskManagerStartContract
taskManager: Promise<TaskManagerStartContract>
) {
return usageCollection.makeUsageCollector<ActionsUsage>({
type: 'actions',
isReady: () => true,
isReady: async () => {
await taskManager;
return true;
},
schema: {
count_total: { type: 'long' },
count_active_total: { type: 'long' },
Expand Down Expand Up @@ -79,7 +82,7 @@ async function getLatestTaskState(taskManager: TaskManagerStartContract) {

export function registerActionsUsageCollector(
usageCollection: UsageCollectionSetup,
taskManager: TaskManagerStartContract
taskManager: Promise<TaskManagerStartContract>
) {
const collector = createActionsUsageCollector(usageCollection, taskManager);
usageCollection.registerCollector(collector);
Expand Down
33 changes: 15 additions & 18 deletions x-pack/plugins/alerts/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { first, map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { combineLatest } from 'rxjs';
import { SecurityPluginSetup } from '../../security/server';
Expand All @@ -28,7 +29,6 @@ import {
SavedObjectsServiceStart,
IContextProvider,
RequestHandler,
SharedGlobalConfig,
ElasticsearchServiceStart,
ILegacyClusterClient,
StatusServiceSetup,
Expand Down Expand Up @@ -124,30 +124,25 @@ export class AlertingPlugin {
private security?: SecurityPluginSetup;
private readonly alertsClientFactory: AlertsClientFactory;
private readonly telemetryLogger: Logger;
private readonly kibanaIndex: Promise<string>;
private readonly kibanaVersion: PluginInitializerContext['env']['packageInfo']['version'];
private eventLogService?: IEventLogService;
private eventLogger?: IEventLogger;
private readonly kibanaIndexConfig: Observable<{ kibana: { index: string } }>;

constructor(initializerContext: PluginInitializerContext) {
this.config = initializerContext.config.create<AlertsConfig>().pipe(first()).toPromise();
this.logger = initializerContext.logger.get('plugins', 'alerting');
this.taskRunnerFactory = new TaskRunnerFactory();
this.alertsClientFactory = new AlertsClientFactory();
this.telemetryLogger = initializerContext.logger.get('usage');
this.kibanaIndex = initializerContext.config.legacy.globalConfig$
.pipe(
first(),
map((config: SharedGlobalConfig) => config.kibana.index)
)
.toPromise();
this.kibanaIndexConfig = initializerContext.config.legacy.globalConfig$;
this.kibanaVersion = initializerContext.env.packageInfo.version;
}

public async setup(
public setup(
core: CoreSetup<AlertingPluginsStart, unknown>,
plugins: AlertingPluginsSetup
): Promise<PluginSetupContract> {
): PluginSetupContract {
this.licenseState = new LicenseState(plugins.licensing.license$);
this.security = plugins.security;

Expand Down Expand Up @@ -187,15 +182,17 @@ export class AlertingPlugin {

const usageCollection = plugins.usageCollection;
if (usageCollection) {
initializeAlertingTelemetry(
this.telemetryLogger,
core,
plugins.taskManager,
await this.kibanaIndex
registerAlertsUsageCollector(
usageCollection,
core.getStartServices().then(([_, { taskManager }]) => taskManager)
);

core.getStartServices().then(async ([, startPlugins]) => {
registerAlertsUsageCollector(usageCollection, startPlugins.taskManager);
this.kibanaIndexConfig.subscribe((config) => {
initializeAlertingTelemetry(
this.telemetryLogger,
core,
plugins.taskManager,
config.kibana.index
);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ describe('registerAlertsUsageCollector', () => {
});

it('should call registerCollector', () => {
registerAlertsUsageCollector(usageCollectionMock as UsageCollectionSetup, taskManagerStart);
registerAlertsUsageCollector(
usageCollectionMock as UsageCollectionSetup,
new Promise(() => taskManagerStart)
);
expect(usageCollectionMock.registerCollector).toHaveBeenCalledTimes(1);
});

it('should call makeUsageCollector with type = alerts', () => {
registerAlertsUsageCollector(usageCollectionMock as UsageCollectionSetup, taskManagerStart);
registerAlertsUsageCollector(
usageCollectionMock as UsageCollectionSetup,
new Promise(() => taskManagerStart)
);
expect(usageCollectionMock.makeUsageCollector).toHaveBeenCalledTimes(1);
expect(usageCollectionMock.makeUsageCollector.mock.calls[0][0].type).toBe('alerts');
});
Expand Down
Loading

0 comments on commit 6295ce1

Please sign in to comment.