Skip to content

Commit

Permalink
Merge branch 'ilm/fix/pre-existing-policy-with-no-existing-repository…
Browse files Browse the repository at this point in the history
…' of github.com:jloleysens/kibana into ilm/fix/pre-existing-policy-with-no-existing-repository

* 'ilm/fix/pre-existing-policy-with-no-existing-repository' of github.com:jloleysens/kibana:
  fix empty string in selected indices (elastic#76855)
  [Security Solution] Refactor OverviewHost and OverviewNetwork to use Search Strategy (elastic#76409)
  Use Search API in Timelion (sync) (elastic#75115)
  [telemetry] expose getIsOptedIn function in plugin start contract (elastic#75143)
  [ILM] Clean up remaining js files and any typings (elastic#76803)
  [Logs UI] Shared `<LogStream />` component (elastic#76262)
  [Security Solution] Add unit test for all hosts (elastic#76752)
  [Security Solution] Add unit test for authentications search strategy (elastic#76665)
  Do not apply search source data for tsvb (elastic#75137)
  [Security Solution] Refactor NetworkDns to use Search Strategy (elastic#76250)
  [SECURITY SOLUTION] Adds 'cypress:open-as-ci' command (elastic#76125)
  [Logs UI] Update alert executor tests (elastic#75764)
  [Functional] Unskip vega tests and fix flakiness (elastic#76600)
  [Data] Query String Input accepts classname prop (elastic#76848)
  [ML] Swim lane pagination for viewing by job id (elastic#76847)
  [Security Solution] Refactor MatrixHistogram to use Search Strategy (elastic#76603)
  [APM] Use the outcome field to calculate the transaction error rate chart (elastic#75528)
  [APM] Use observer.hostname instead of observer.name (elastic#76074)
  Legacy logging: fix remoteAddress being duplicated in userAgent field (elastic#76751)
  • Loading branch information
jloleysens committed Sep 8, 2020
2 parents 0a646d5 + e104911 commit 1a85d85
Show file tree
Hide file tree
Showing 206 changed files with 72,220 additions and 3,299 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [ES\_SEARCH\_STRATEGY](./kibana-plugin-plugins-data-server.es_search_strategy.md)

## ES\_SEARCH\_STRATEGY variable

<b>Signature:</b>

```typescript
ES_SEARCH_STRATEGY = "es"
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export interface ISearchStart<SearchStrategyRequest extends IEsSearchRequest = I
| --- | --- | --- |
| [aggs](./kibana-plugin-plugins-data-server.isearchstart.aggs.md) | <code>AggsStart</code> | |
| [getSearchStrategy](./kibana-plugin-plugins-data-server.isearchstart.getsearchstrategy.md) | <code>(name: string) =&gt; ISearchStrategy&lt;SearchStrategyRequest, SearchStrategyResponse&gt;</code> | Get other registered search strategies. For example, if a new strategy needs to use the already-registered ES search strategy, it can use this function to accomplish that. |
| [search](./kibana-plugin-plugins-data-server.isearchstart.search.md) | <code>(context: RequestHandlerContext, request: IKibanaSearchRequest, options: ISearchOptions) =&gt; Promise&lt;IKibanaSearchResponse&gt;</code> | |
| [search](./kibana-plugin-plugins-data-server.isearchstart.search.md) | <code>(context: RequestHandlerContext, request: IEsSearchRequest, options: ISearchOptions) =&gt; Promise&lt;IEsSearchResponse&gt;</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
search: (context: RequestHandlerContext, request: IKibanaSearchRequest, options: ISearchOptions) => Promise<IKibanaSearchResponse>;
search: (context: RequestHandlerContext, request: IEsSearchRequest, options: ISearchOptions) => Promise<IEsSearchResponse>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
| [AggGroupNames](./kibana-plugin-plugins-data-server.agggroupnames.md) | |
| [castEsToKbnFieldTypeName](./kibana-plugin-plugins-data-server.castestokbnfieldtypename.md) | Get the KbnFieldType name for an esType string |
| [config](./kibana-plugin-plugins-data-server.config.md) | |
| [ES\_SEARCH\_STRATEGY](./kibana-plugin-plugins-data-server.es_search_strategy.md) | |
| [esFilters](./kibana-plugin-plugins-data-server.esfilters.md) | |
| [esKuery](./kibana-plugin-plugins-data-server.eskuery.md) | |
| [esQuery](./kibana-plugin-plugins-data-server.esquery.md) | |
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/server/logging/log_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class TransformObjStream extends Stream.Transform {
method: event.method || '',
headers: event.headers,
remoteAddress: source.remoteAddress,
userAgent: source.remoteAddress,
userAgent: source.userAgent,
referer: source.referer,
};

Expand Down
4 changes: 3 additions & 1 deletion src/legacy/server/logging/log_format_json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ describe('KbnLoggerJsonFormat', () => {
},
};
const result = await createPromiseFromStreams([createListStream([event]), format]);
const { type, method, statusCode, message } = JSON.parse(result);
const { type, method, statusCode, message, req } = JSON.parse(result);

expect(type).toBe('response');
expect(method).toBe('GET');
expect(statusCode).toBe(200);
expect(message).toBe('GET /path/to/resource 200 12000ms - 13.0B');
expect(req.remoteAddress).toBe('127.0.0.1');
expect(req.userAgent).toBe('Test Thing');
});

it('ops', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ export interface QueryState {
// Warning: (ae-missing-release-tag) "QueryStringInput" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const QueryStringInput: React.FC<Pick<Props_3, "query" | "prepend" | "size" | "placeholder" | "onChange" | "onBlur" | "onSubmit" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition" | "onChangeQueryInputFocus">>;
export const QueryStringInput: React.FC<Pick<Props_3, "query" | "prepend" | "size" | "className" | "placeholder" | "onChange" | "onBlur" | "onSubmit" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition" | "onChangeQueryInputFocus">>;

// @public (undocumented)
export type QuerySuggestion = QuerySuggestionBasic | QuerySuggestionField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React, { Component, RefObject, createRef } from 'react';
import { i18n } from '@kbn/i18n';

import classNames from 'classnames';
import {
EuiTextArea,
EuiOutsideClickDetector,
Expand Down Expand Up @@ -62,6 +62,7 @@ interface Props {
onSubmit?: (query: Query) => void;
dataTestSubj?: string;
size?: SuggestionsListSize;
className?: string;
}

interface State {
Expand Down Expand Up @@ -586,9 +587,12 @@ export class QueryStringInputUI extends Component<Props, State> {
'aria-owns': 'kbnTypeahead__items',
};
const ariaCombobox = { ...isSuggestionsVisible, role: 'combobox' };

const className = classNames(
'euiFormControlLayout euiFormControlLayout--group kbnQueryBar__wrap',
this.props.className
);
return (
<div className="euiFormControlLayout euiFormControlLayout--group kbnQueryBar__wrap">
<div className={className}>
{this.props.prepend}
<EuiOutsideClickDetector onOutsideClick={this.onOutsideClick}>
<div
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export {
ISearchOptions,
IEsSearchRequest,
IEsSearchResponse,
ES_SEARCH_STRATEGY,
// tabify
TabbedAggColumn,
TabbedAggRow,
Expand Down
19 changes: 18 additions & 1 deletion src/plugins/data/server/search/routes/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,24 @@ describe('Search service', () => {
});

it('handler calls context.search.search with the given request and strategy', async () => {
const response = { id: 'yay' };
const response = {
id: 'yay',
rawResponse: {
took: 100,
timed_out: true,
_shards: {
total: 0,
successful: 0,
failed: 0,
skipped: 0,
},
hits: {
total: 0,
max_score: 0,
hits: [],
},
},
};
mockDataStart.search.search.mockResolvedValue(response);
const mockContext = {};
const mockBody = { id: undefined, params: {} };
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/data/server/search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { RequestHandlerContext } from '../../../../core/server';
import { IKibanaSearchResponse, IKibanaSearchRequest, ISearchOptions } from '../../common/search';
import { ISearchOptions } from '../../common/search';
import { AggsSetup, AggsStart } from './aggs';
import { SearchUsage } from './collectors/usage';
import { IEsSearchRequest, IEsSearchResponse } from './es_search';
Expand Down Expand Up @@ -66,9 +66,9 @@ export interface ISearchStart<
) => ISearchStrategy<SearchStrategyRequest, SearchStrategyResponse>;
search: (
context: RequestHandlerContext,
request: IKibanaSearchRequest,
request: IEsSearchRequest,
options: ISearchOptions
) => Promise<IKibanaSearchResponse>;
) => Promise<IEsSearchResponse>;
}

/**
Expand Down
33 changes: 19 additions & 14 deletions src/plugins/data/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ export enum ES_FIELD_TYPES {
_TYPE = "_type"
}

// Warning: (ae-missing-release-tag) "ES_SEARCH_STRATEGY" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const ES_SEARCH_STRATEGY = "es";

// Warning: (ae-forgotten-export) The symbol "ExpressionFunctionDefinition" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Input" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "Arguments" needs to be exported by the entry point index.d.ts
Expand Down Expand Up @@ -710,7 +715,7 @@ export interface ISearchStart<SearchStrategyRequest extends IEsSearchRequest = I
// Warning: (ae-forgotten-export) The symbol "RequestHandlerContext" needs to be exported by the entry point index.d.ts
//
// (undocumented)
search: (context: RequestHandlerContext, request: IKibanaSearchRequest, options: ISearchOptions) => Promise<IKibanaSearchResponse>;
search: (context: RequestHandlerContext, request: IEsSearchRequest, options: ISearchOptions) => Promise<IEsSearchResponse>;
}

// Warning: (ae-missing-release-tag) "ISearchStrategy" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
Expand Down Expand Up @@ -1086,19 +1091,19 @@ export function usageProvider(core: CoreSetup_2): SearchUsage;
// src/plugins/data/server/index.ts:101:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:127:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:127:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:221:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:221:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:221:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:221:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:223:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:224:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:233:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:234:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:235:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:239:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:240:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:244:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:247:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:222:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:222:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:222:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:222:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:224:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:225:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:234:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:235:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:236:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:240:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:241:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:245:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/index.ts:248:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/server/plugin.ts:88:66 - (ae-forgotten-export) The symbol "DataEnhancements" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)
Expand Down
58 changes: 58 additions & 0 deletions src/plugins/telemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,61 @@ Telemetry allows Kibana features to have usage tracked in the wild. The general
3. Viewing usage data in the Kibana instance of the telemetry cluster (Viewing).

This plugin is responsible for sending usage data to the telemetry cluster. For collecting usage data, use the [`usageCollection` plugin](../usage_collection/README.md)

## Telemetry Plugin public API

### Setup

The `setup` function exposes the following interface:

- `getTelemetryUrl: () => Promise<URL>`:
An async function that resolves into the telemetry Url used to send telemetry. The url is wrapped with node's [URL constructor](https://nodejs.org/api/url.html). Here is an example on how to grab the url origin:
```
const telemetryUrl = await getTelemetryUrl();
> telemetryUrl.origin; // 'https://telemetry.elastic.co'
```
Note that the telemetry URL is a kibana.yml configuration hence it is recommended to call the `getTelemetryUrl` everytime before using the actual url.

### Start

The `start` function exposes the following interface:

- `async getIsOptedIn(): Promise<boolean>`:
An async function that resolves into `true` if the user has opted into send Elastic usage data.
Resolves to `false` if the user explicitly opted out of sending usage data to Elastic or did not choose
to opt-in or out yet after a minor or major upgrade (only when previously opted out).

### Usage

To use the exposed plugin start and setup contracts:

1. Make sure `telemetry` is in your `optionalPlugins` in the `kibana.json` file:

```json5
// <plugin>/kibana.json
{
"id": "...",
"optionalPlugins": ["telemetry"]
}
```

2. Use the exposed contracts:
```ts
// <plugin>/server/plugin.ts

import { TelemetryPluginsStart } from '../telemetry/server`;

interface MyPlyginStartDeps {
telemetry?: TelemetryPluginsStart;
}

class MyPlugin {
public async start(
core: CoreStart,
{ telemetry }: MyPlyginStartDeps
) {
const isOptedIn = await telemetry?.getIsOptedIn();
...
}
}
```
2 changes: 1 addition & 1 deletion src/plugins/telemetry/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { configSchema, TelemetryConfigType } from './config';

export { FetcherTask } from './fetcher';
export { handleOldSettings } from './handle_old_settings';
export { TelemetryPluginsSetup } from './plugin';
export { TelemetryPluginSetup, TelemetryPluginStart } from './plugin';

export const config: PluginConfigDescriptor<TelemetryConfigType> = {
schema: configSchema,
Expand Down
46 changes: 46 additions & 0 deletions src/plugins/telemetry/server/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 { URL } from 'url';
import { TelemetryPluginStart, TelemetryPluginSetup } from './plugin';

export type Setup = jest.Mocked<TelemetryPluginSetup>;
export type Start = jest.Mocked<TelemetryPluginStart>;

export const telemetryPluginMock = {
createSetupContract,
createStartContract,
};

function createSetupContract(): Setup {
const telemetryUrl = new URL('https://telemetry-staging.elastic.co/xpack/MOCK_URL/send');
const setupContract: Setup = {
getTelemetryUrl: jest.fn().mockResolvedValue(telemetryUrl),
};

return setupContract;
}

function createStartContract(): Start {
const startContract: Start = {
getIsOptedIn: jest.fn(),
};

return startContract;
}
Loading

0 comments on commit 1a85d85

Please sign in to comment.