Skip to content

Commit

Permalink
Merge branch 'master' into feature-default-fleet-server-policies
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 16, 2021
2 parents 2b8cb40 + 7fc5613 commit 3313452
Show file tree
Hide file tree
Showing 231 changed files with 5,081 additions and 3,447 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export declare class SearchInterceptor
| --- | --- | --- |
| [getTimeoutMode()](./kibana-plugin-plugins-data-public.searchinterceptor.gettimeoutmode.md) | | |
| [handleSearchError(e, timeoutSignal, options)](./kibana-plugin-plugins-data-public.searchinterceptor.handlesearcherror.md) | | |
| [search(request, options)](./kibana-plugin-plugins-data-public.searchinterceptor.search.md) | | Searches using the given <code>search</code> method. Overrides the <code>AbortSignal</code> with one that will abort either when <code>cancelPending</code> is called, when the request times out, or when the original <code>AbortSignal</code> is aborted. Updates <code>pendingCount$</code> when the request is started/finalized. |
| [search(request, options)](./kibana-plugin-plugins-data-public.searchinterceptor.search.md) | | Searches using the given <code>search</code> method. Overrides the <code>AbortSignal</code> with one that will abort either when the request times out, or when the original <code>AbortSignal</code> is aborted. Updates <code>pendingCount$</code> when the request is started/finalized. |
| [showError(e)](./kibana-plugin-plugins-data-public.searchinterceptor.showerror.md) | | |

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## SearchInterceptor.search() method

Searches using the given `search` method. Overrides the `AbortSignal` with one that will abort either when `cancelPending` is called, when the request times out, or when the original `AbortSignal` is aborted. Updates `pendingCount$` when the request is started/finalized.
Searches using the given `search` method. Overrides the `AbortSignal` with one that will abort either when the request times out, or when the original `AbortSignal` is aborted. Updates `pendingCount$` when the request is started/finalized.

<b>Signature:</b>

Expand Down
6 changes: 3 additions & 3 deletions docs/user/dashboard/url-drilldown.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ internal {kib} navigations with carrying over current filters.
| Current query string.

|
| context.panel.query.lang
| context.panel.query.language
| Current query language.

|
Expand All @@ -200,8 +200,8 @@ context.panel.timeRange.to
Tip: Use in combination with <<helpers, date>> helper to format date.

|
| context.panel.timeRange.indexPatternId +
context.panel.timeRange.indexPatternIds
| context.panel.indexPatternId +
context.panel.indexPatternIds
|Index pattern ids used by a panel.

|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ test('parses fully specified config', () => {
"apiVersion": "v7.0.0",
"hosts": Array [
Object {
"auth": "elastic:changeme",
"headers": Object {
"x-elastic-product-origin": "kibana",
"xsrf": "something",
Expand All @@ -111,7 +110,6 @@ test('parses fully specified config', () => {
"query": null,
},
Object {
"auth": "elastic:changeme",
"headers": Object {
"x-elastic-product-origin": "kibana",
"xsrf": "something",
Expand All @@ -123,7 +121,6 @@ test('parses fully specified config', () => {
"query": null,
},
Object {
"auth": "elastic:changeme",
"headers": Object {
"x-elastic-product-origin": "kibana",
"xsrf": "something",
Expand All @@ -135,6 +132,7 @@ test('parses fully specified config', () => {
"query": null,
},
],
"httpAuth": "elastic:changeme",
"keepAlive": true,
"log": [Function],
"pingTimeout": 12345,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ export function parseElasticsearchClientConfig(
esClientConfig.sniffInterval = getDurationAsMs(config.sniffInterval);
}

const needsAuth = auth !== false && config.username && config.password;
if (needsAuth) {
esClientConfig.httpAuth = `${config.username}:${config.password}`;
}

if (Array.isArray(config.hosts)) {
const needsAuth = auth !== false && config.username && config.password;
esClientConfig.hosts = config.hosts.map((nodeUrl: string) => {
const uri = url.parse(nodeUrl);

const httpsURI = uri.protocol === 'https:';
const httpURI = uri.protocol === 'http:';

Expand All @@ -126,10 +129,6 @@ export function parseElasticsearchClientConfig(
},
};

if (needsAuth) {
host.auth = `${config.username}:${config.password}`;
}

return host;
});
}
Expand Down
1 change: 1 addition & 0 deletions src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const storybookAliases = {
apm: 'x-pack/plugins/apm/.storybook',
canvas: 'x-pack/plugins/canvas/storybook',
codeeditor: 'src/plugins/kibana_react/public/code_editor/.storybook',
url_template_editor: 'src/plugins/kibana_react/public/url_template_editor/.storybook',
dashboard: 'src/plugins/dashboard/.storybook',
dashboard_enhanced: 'x-pack/plugins/dashboard_enhanced/.storybook',
data_enhanced: 'x-pack/plugins/data_enhanced/.storybook',
Expand Down
12 changes: 11 additions & 1 deletion src/plugins/console/public/lib/es/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import $ from 'jquery';
import { stringify } from 'query-string';

interface SendOptions {
asSystemRequest?: boolean;
}

const esVersion: string[] = [];

export function getVersion() {
Expand All @@ -20,13 +24,19 @@ export function getContentType(body: any) {
return 'application/json';
}

export function send(method: string, path: string, data: any) {
export function send(
method: string,
path: string,
data: any,
{ asSystemRequest }: SendOptions = {}
) {
const wrappedDfd = $.Deferred();

const options: JQuery.AjaxSettings = {
url: '../api/console/proxy?' + stringify({ path, method }, { sort: false }),
headers: {
'kbn-xsrf': 'kibana',
...(asSystemRequest && { 'kbn-system-request': 'true' }),
},
data,
contentType: getContentType(data),
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/console/public/lib/mappings/mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function retrieveSettings(settingsKey, settingsToRetrieve) {

// Fetch autocomplete info if setting is set to true, and if user has made changes.
if (settingsToRetrieve[settingsKey] === true) {
return es.send('GET', settingKeyToPathMap[settingsKey], null);
return es.send('GET', settingKeyToPathMap[settingsKey], null, true);
} else {
const settingsPromise = new $.Deferred();
if (settingsToRetrieve[settingsKey] === false) {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ export type {
ISessionService,
SearchSessionInfoProvider,
ISessionsClient,
SearchUsageCollector,
} from './search';

export { ISearchOptions, isErrorResponse, isCompleteResponse, isPartialResponse } from '../common';
Expand Down
66 changes: 50 additions & 16 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ export interface ISearchSetup {
aggs: AggsSetup;
session: ISessionService;
sessionsClient: ISessionsClient;
// Warning: (ae-forgotten-export) The symbol "SearchUsageCollector" needs to be exported by the entry point index.d.ts
// Warning: (ae-incompatible-release-tags) The symbol "usageCollector" is marked as @public, but its signature references "SearchUsageCollector" which is marked as @internal
//
// (undocumented)
usageCollector?: SearchUsageCollector;
Expand Down Expand Up @@ -2329,6 +2329,8 @@ export interface SearchInterceptorDeps {
toasts: ToastsSetup;
// (undocumented)
uiSettings: CoreSetup_2['uiSettings'];
// Warning: (ae-incompatible-release-tags) The symbol "usageCollector" is marked as @public, but its signature references "SearchUsageCollector" which is marked as @internal
//
// (undocumented)
usageCollector?: SearchUsageCollector;
}
Expand Down Expand Up @@ -2453,6 +2455,38 @@ export class SearchTimeoutError extends KbnError {
mode: TimeoutErrorMode;
}

// @internal (undocumented)
export interface SearchUsageCollector {
// (undocumented)
trackQueryTimedOut: () => Promise<void>;
// (undocumented)
trackSessionCancelled: () => Promise<void>;
// (undocumented)
trackSessionDeleted: () => Promise<void>;
// (undocumented)
trackSessionExtended: () => Promise<void>;
// (undocumented)
trackSessionIndicatorSaveDisabled: () => Promise<void>;
// (undocumented)
trackSessionIndicatorTourLoading: () => Promise<void>;
// (undocumented)
trackSessionIndicatorTourRestored: () => Promise<void>;
// (undocumented)
trackSessionIsRestored: () => Promise<void>;
// (undocumented)
trackSessionReloaded: () => Promise<void>;
// (undocumented)
trackSessionSavedResults: () => Promise<void>;
// (undocumented)
trackSessionSentToBackground: () => Promise<void>;
// (undocumented)
trackSessionsListLoaded: () => Promise<void>;
// (undocumented)
trackSessionViewRestored: () => Promise<void>;
// (undocumented)
trackViewSessionsList: () => Promise<void>;
}

// Warning: (ae-missing-release-tag) "SortDirection" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -2607,21 +2641,21 @@ export const UI_SETTINGS: {
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:397:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:397:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:397:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:397:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:399:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:416:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:417:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:420:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:421:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:424:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:398:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:398:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:398:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:398:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:417:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:418:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:421:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:422:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:425:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:34:5 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/search/session/session_service.ts:42:5 - (ae-forgotten-export) The symbol "UrlGeneratorStateMapping" needs to be exported by the entry point index.d.ts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,66 @@ describe('Search Usage Collector', () => {
);
});

test('tracks query cancellation', async () => {
await usageCollector.trackQueriesCancelled();
test('tracks session sent to background', async () => {
await usageCollector.trackSessionSentToBackground();
expect(mockUsageCollectionSetup.reportUiCounter).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][1]).toBe(METRIC_TYPE.LOADED);
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][1]).toBe(METRIC_TYPE.CLICK);
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.SESSION_SENT_TO_BACKGROUND
);
});

test('tracks session saved results', async () => {
await usageCollector.trackSessionSavedResults();
expect(mockUsageCollectionSetup.reportUiCounter).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][1]).toBe(METRIC_TYPE.CLICK);
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.SESSION_SAVED_RESULTS
);
});

test('tracks session view restored', async () => {
await usageCollector.trackSessionViewRestored();
expect(mockUsageCollectionSetup.reportUiCounter).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][1]).toBe(METRIC_TYPE.CLICK);
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.SESSION_VIEW_RESTORED
);
});

test('tracks session is restored', async () => {
await usageCollector.trackSessionIsRestored();
expect(mockUsageCollectionSetup.reportUiCounter).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][1]).toBe(METRIC_TYPE.CLICK);
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.SESSION_IS_RESTORED
);
});

test('tracks session reloaded', async () => {
await usageCollector.trackSessionReloaded();
expect(mockUsageCollectionSetup.reportUiCounter).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][1]).toBe(METRIC_TYPE.CLICK);
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.SESSION_RELOADED
);
});

test('tracks session extended', async () => {
await usageCollector.trackSessionExtended();
expect(mockUsageCollectionSetup.reportUiCounter).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][1]).toBe(METRIC_TYPE.CLICK);
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.SESSION_EXTENDED
);
});

test('tracks session cancelled', async () => {
await usageCollector.trackSessionCancelled();
expect(mockUsageCollectionSetup.reportUiCounter).toHaveBeenCalled();
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][1]).toBe(METRIC_TYPE.CLICK);
expect(mockUsageCollectionSetup.reportUiCounter.mock.calls[0][2]).toBe(
SEARCH_EVENT_TYPE.QUERIES_CANCELLED
SEARCH_EVENT_TYPE.SESSION_CANCELLED
);
});
});
59 changes: 43 additions & 16 deletions src/plugins/data/public/search/collectors/create_usage_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { first } from 'rxjs/operators';
import { UiCounterMetricType } from '@kbn/analytics';
import { StartServicesAccessor } from '../../../../../core/public';
import { METRIC_TYPE, UsageCollectionSetup } from '../../../../usage_collection/public';
import { SEARCH_EVENT_TYPE, SearchUsageCollector } from './types';
Expand All @@ -20,22 +21,48 @@ export const createUsageCollector = (
return application.currentAppId$.pipe(first()).toPromise();
};

return {
trackQueryTimedOut: async () => {
const currentApp = await getCurrentApp();
return usageCollection?.reportUiCounter(
currentApp!,
METRIC_TYPE.LOADED,
SEARCH_EVENT_TYPE.QUERY_TIMED_OUT
);
},
trackQueriesCancelled: async () => {
const getCollector = (metricType: UiCounterMetricType, eventType: SEARCH_EVENT_TYPE) => {
return async () => {
const currentApp = await getCurrentApp();
return usageCollection?.reportUiCounter(
currentApp!,
METRIC_TYPE.LOADED,
SEARCH_EVENT_TYPE.QUERIES_CANCELLED
);
},
return usageCollection?.reportUiCounter(currentApp!, metricType, eventType);
};
};

return {
trackQueryTimedOut: getCollector(METRIC_TYPE.LOADED, SEARCH_EVENT_TYPE.QUERY_TIMED_OUT),
trackSessionIndicatorTourLoading: getCollector(
METRIC_TYPE.LOADED,
SEARCH_EVENT_TYPE.SESSION_INDICATOR_TOUR_LOADING
),
trackSessionIndicatorTourRestored: getCollector(
METRIC_TYPE.LOADED,
SEARCH_EVENT_TYPE.SESSION_INDICATOR_TOUR_RESTORED
),
trackSessionIndicatorSaveDisabled: getCollector(
METRIC_TYPE.LOADED,
SEARCH_EVENT_TYPE.SESSION_INDICATOR_SAVE_DISABLED
),
trackSessionSentToBackground: getCollector(
METRIC_TYPE.CLICK,
SEARCH_EVENT_TYPE.SESSION_SENT_TO_BACKGROUND
),
trackSessionSavedResults: getCollector(
METRIC_TYPE.CLICK,
SEARCH_EVENT_TYPE.SESSION_SAVED_RESULTS
),
trackSessionViewRestored: getCollector(
METRIC_TYPE.CLICK,
SEARCH_EVENT_TYPE.SESSION_VIEW_RESTORED
),
trackSessionIsRestored: getCollector(METRIC_TYPE.CLICK, SEARCH_EVENT_TYPE.SESSION_IS_RESTORED),
trackSessionReloaded: getCollector(METRIC_TYPE.CLICK, SEARCH_EVENT_TYPE.SESSION_RELOADED),
trackSessionExtended: getCollector(METRIC_TYPE.CLICK, SEARCH_EVENT_TYPE.SESSION_EXTENDED),
trackSessionCancelled: getCollector(METRIC_TYPE.CLICK, SEARCH_EVENT_TYPE.SESSION_CANCELLED),
trackSessionDeleted: getCollector(METRIC_TYPE.CLICK, SEARCH_EVENT_TYPE.SESSION_DELETED),
trackViewSessionsList: getCollector(METRIC_TYPE.CLICK, SEARCH_EVENT_TYPE.SESSION_VIEW_LIST),
trackSessionsListLoaded: getCollector(
METRIC_TYPE.LOADED,
SEARCH_EVENT_TYPE.SESSIONS_LIST_LOADED
),
};
};
Loading

0 comments on commit 3313452

Please sign in to comment.