Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into new-platform-clea…
Browse files Browse the repository at this point in the history
…nup-filters
  • Loading branch information
Liza Katz committed Apr 10, 2019
2 parents f5c3223 + d733a89 commit 9501d3d
Show file tree
Hide file tree
Showing 321 changed files with 8,290 additions and 3,949 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ In the screenshot below, you'll notice the URL is `localhost:9876/debug.html`. Y

### Unit Testing Plugins

This should work super if you're using the [Kibana plugin generator](https:/elastic/generator-kibana-plugin). If you're not using the generator, well, you're on your own. We suggest you look at how the generator works.
This should work super if you're using the [Kibana plugin generator](https:/elastic/kibana/tree/master/packages/kbn-plugin-generator). If you're not using the generator, well, you're on your own. We suggest you look at how the generator works.

To run the tests for just your particular plugin run the following command from your plugin:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export interface CoreSetup
| [i18n](./kibana-plugin-public.coresetup.i18n.md) | <code>I18nSetup</code> | |
| [injectedMetadata](./kibana-plugin-public.coresetup.injectedmetadata.md) | <code>InjectedMetadataSetup</code> | |
| [notifications](./kibana-plugin-public.coresetup.notifications.md) | <code>NotificationsSetup</code> | |
| [overlays](./kibana-plugin-public.coresetup.overlays.md) | <code>OverlaySetup</code> | |
| [uiSettings](./kibana-plugin-public.coresetup.uisettings.md) | <code>UiSettingsSetup</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Home](./index) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [CoreSetup](./kibana-plugin-public.coresetup.md) &gt; [overlays](./kibana-plugin-public.coresetup.overlays.md)

## CoreSetup.overlays property

<b>Signature:</b>

```typescript
overlays: OverlaySetup;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Home](./index) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [FlyoutRef](./kibana-plugin-public.flyoutref.md) &gt; [close](./kibana-plugin-public.flyoutref.close.md)

## FlyoutRef.close() method

Closes the referenced flyout if it's still open which in turn will resolve the `onClose` Promise. If the flyout had already been closed this method does nothing.

<b>Signature:</b>

```typescript
close(): Promise<void>;
```
<b>Returns:</b>

`Promise<void>`

24 changes: 24 additions & 0 deletions docs/development/core/public/kibana-plugin-public.flyoutref.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Home](./index) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [FlyoutRef](./kibana-plugin-public.flyoutref.md)

## FlyoutRef class

A FlyoutRef is a reference to an opened flyout panel. It offers methods to close the flyout panel again. If you open a flyout panel you should make sure you call `close()` when it should be closed. Since a flyout could also be closed by a user or from another flyout being opened, you must bind to the `onClose` Promise on the FlyoutRef instance. The Promise will resolve whenever the flyout was closed at which point you should discard the FlyoutRef.

<b>Signature:</b>

```typescript
export declare class FlyoutRef
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [onClose](./kibana-plugin-public.flyoutref.onclose.md) | | <code>Promise&lt;void&gt;</code> | An Promise that will resolve once this flyout is closed.<!-- -->Flyouts can close from user interaction, calling <code>close()</code> on the flyout reference or another call to <code>openFlyout()</code> replacing your flyout. |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [close()](./kibana-plugin-public.flyoutref.close.md) | | Closes the referenced flyout if it's still open which in turn will resolve the <code>onClose</code> Promise. If the flyout had already been closed this method does nothing. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Home](./index) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [FlyoutRef](./kibana-plugin-public.flyoutref.md) &gt; [onClose](./kibana-plugin-public.flyoutref.onclose.md)

## FlyoutRef.onClose property

An Promise that will resolve once this flyout is closed.

Flyouts can close from user interaction, calling `close()` on the flyout reference or another call to `openFlyout()` replacing your flyout.

<b>Signature:</b>

```typescript
readonly onClose: Promise<void>;
```
2 changes: 2 additions & 0 deletions docs/development/core/public/kibana-plugin-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

| Class | Description |
| --- | --- |
| [FlyoutRef](./kibana-plugin-public.flyoutref.md) | A FlyoutRef is a reference to an opened flyout panel. It offers methods to close the flyout panel again. If you open a flyout panel you should make sure you call <code>close()</code> when it should be closed. Since a flyout could also be closed by a user or from another flyout being opened, you must bind to the <code>onClose</code> Promise on the FlyoutRef instance. The Promise will resolve whenever the flyout was closed at which point you should discard the FlyoutRef. |
| [ToastsSetup](./kibana-plugin-public.toastssetup.md) | |
| [UiSettingsClient](./kibana-plugin-public.uisettingsclient.md) | |

Expand All @@ -16,6 +17,7 @@
| [ChromeBrand](./kibana-plugin-public.chromebrand.md) | |
| [ChromeBreadcrumb](./kibana-plugin-public.chromebreadcrumb.md) | |
| [CoreSetup](./kibana-plugin-public.coresetup.md) | Core services exposed to the start lifecycle |
| [OverlaySetup](./kibana-plugin-public.overlaysetup.md) | |
| [Plugin](./kibana-plugin-public.plugin.md) | The interface that should be returned by a <code>PluginInitializer</code>. |
| [PluginInitializerContext](./kibana-plugin-public.plugininitializercontext.md) | The available core services passed to a <code>PluginInitializer</code> |
| [PluginSetupContext](./kibana-plugin-public.pluginsetupcontext.md) | The available core services passed to a plugin's <code>Plugin#setup</code> method. |
Expand Down
17 changes: 17 additions & 0 deletions docs/development/core/public/kibana-plugin-public.overlaysetup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Home](./index) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [OverlaySetup](./kibana-plugin-public.overlaysetup.md)

## OverlaySetup interface


<b>Signature:</b>

```typescript
export interface OverlaySetup
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [openFlyout](./kibana-plugin-public.overlaysetup.openflyout.md) | <code>(flyoutChildren: React.ReactNode, flyoutProps?: {`<p/>` closeButtonAriaLabel?: string;`<p/>` 'data-test-subj'?: string;`<p/>` }) =&gt; FlyoutRef</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Home](./index) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [OverlaySetup](./kibana-plugin-public.overlaysetup.md) &gt; [openFlyout](./kibana-plugin-public.overlaysetup.openflyout.md)

## OverlaySetup.openFlyout property

<b>Signature:</b>

```typescript
openFlyout: (flyoutChildren: React.ReactNode, flyoutProps?: {
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
}) => FlyoutRef;
```
30 changes: 7 additions & 23 deletions docs/monitoring/monitoring-metricbeat.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,38 +90,22 @@ run the following command:

["source","sh",subs="attributes,callouts"]
----------------------------------------------------------------------
metricbeat modules enable kibana
metricbeat modules enable kibana-xpack
----------------------------------------------------------------------

For more information, see
{metricbeat-ref}/configuration-metricbeat.html[Specify which modules to run] and
{metricbeat-ref}/metricbeat-module-kibana.html[{kib} module].
--

. Configure the {kib} module in {metricbeat}. +
+
--
You must specify the following settings in the `modules.d/kibana.yml` file:

[source,yaml]
----------------------------------
- module: kibana
metricsets:
- stats
period: 10s
hosts: ["http://localhost:5601"] <1>
xpack.enabled: true <2>
----------------------------------
<1> This setting identifies the host and port number that are used to access {kib}.
<2> This setting ensures that {kib} can read the monitoring data successfully.
That is to say, it's stored in the same location and format as monitoring data
that is sent by {ref}/es-monitoring-exporters.html[exporters].
--
. By default the module will collect {kib} monitoring metrics from `http://localhost:5601`.
If the local {kib} instance has a different address, you must specify it via the `hosts` setting
in the `modules.d/kibana-xpack.yml` file.

. If the Elastic {security-features} are enabled, you must also provide a user
ID and password so that {metricbeat} can collect metrics successfully.

... Create a user on the production cluster that has the
.. Create a user on the production cluster that has the
`remote_monitoring_collector` {stack-ov}/built-in-roles.html[built-in role].
Alternatively, use the `remote_monitoring_user`
{stack-ov}/built-in-users.html[built-in user].
Expand All @@ -130,7 +114,7 @@ Alternatively, use the `remote_monitoring_user`
file.
+
--
For example, add the following settings in the `modules.d/kibana.yml` file:
For example, add the following settings in the `modules.d/kibana-xpack.yml` file:

[source,yaml]
----------------------------------
Expand All @@ -143,7 +127,7 @@ For example, add the following settings in the `modules.d/kibana.yml` file:

. If you configured {kib} to use <<configuring-tls,encrypted communications>>,
you must access it via HTTPS. For example, use a `hosts` setting like
`https://localhost:5601` in the `modules.d/kibana.yml` file.
`https://localhost:5601` in the `modules.d/kibana-xpack.yml` file.

. Identify where to send the monitoring data. +
+
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"uiFramework:documentComponent": "cd packages/kbn-ui-framework && yarn documentComponent",
"kbn:watch": "node scripts/kibana --dev --logging.json=false",
"build:types": "tsc --p tsconfig.types.json",
"core:acceptApiChanges": "yarn build:types && node scripts/check_core_api_changes.js --accept",
"kbn:bootstrap": "yarn build:types && node scripts/register_git_hook"
},
"repository": {
Expand Down Expand Up @@ -99,7 +100,7 @@
"@babel/polyfill": "^7.2.5",
"@babel/register": "^7.0.0",
"@elastic/datemath": "5.0.2",
"@elastic/eui": "9.8.0",
"@elastic/eui": "9.9.0",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "8.1.1-kibana2",
"@elastic/numeral": "2.3.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-es-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"kbn:watch": "node scripts/build --source-maps --watch"
},
"dependencies": {
"lodash": "npm:@elastic/[email protected]"
"lodash": "npm:@elastic/[email protected]",
"moment-timezone": "^0.5.14"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
Expand Down
30 changes: 30 additions & 0 deletions packages/kbn-es-query/src/es_query/__tests__/build_es_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,36 @@ describe('build query', function () {
expect(result).to.eql(expectedResult);
});

it('should use the default time zone set in the Advanced Settings in queries and filters', function () {
const queries = [
{ query: '@timestamp:"2019-03-23T13:18:00"', language: 'kuery' },
{ query: '@timestamp:"2019-03-23T13:18:00"', language: 'lucene' }
];
const filters = [
{ match_all: {}, meta: { type: 'match_all' } }
];
const config = {
allowLeadingWildcards: true,
queryStringOptions: {},
ignoreFilterIfFieldNotInIndex: false,
dateFormatTZ: 'Africa/Johannesburg',
};

const expectedResult = {
bool: {
must: [
decorateQuery(luceneStringToDsl('@timestamp:"2019-03-23T13:18:00"'), config.queryStringOptions, config.dateFormatTZ),
{ match_all: {} }
],
filter: [toElasticsearchQuery(fromKueryExpression('@timestamp:"2019-03-23T13:18:00"'), indexPattern, config)],
should: [],
must_not: [],
}
};
const result = buildEsQuery(indexPattern, queries, filters, config);
expect(result).to.eql(expectedResult);
});

});

});
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ describe('Query decorator', function () {
const decoratedQuery = decorateQuery({ query_string: { query: '*' } }, { analyze_wildcard: true });
expect(decoratedQuery).to.eql({ query_string: { query: '*', analyze_wildcard: true } });
});

it('should add a default of a time_zone parameter if one is provided', function () {
const decoratedQuery = decorateQuery({ query_string: { query: '*' } }, { analyze_wildcard: true }, 'America/Phoenix');
expect(decoratedQuery).to.eql({ query_string: { query: '*', analyze_wildcard: true, time_zone: 'America/Phoenix' } });
});
});
25 changes: 25 additions & 0 deletions packages/kbn-es-query/src/es_query/__tests__/from_kuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ describe('build query', function () {
);
});


it('should accept a specific date format for a kuery query into an ES query in the bool\'s filter clause', function () {
const queries = [{ query: '@timestamp:"2018-04-03T19:04:17"', language: 'kuery' }];

const expectedESQueries = queries.map(query => {
return toElasticsearchQuery(fromKueryExpression(query.query), indexPattern, { dateFormatTZ: 'America/Phoenix' });
});

const result = buildQueryFromKuery(indexPattern, queries, true, 'America/Phoenix');

expect(result.filter).to.eql(expectedESQueries);
});

it('should gracefully handle date queries when no date format is provided', function () {
const queries = [{ query: '@timestamp:"2018-04-03T19:04:17Z"', language: 'kuery' }];

const expectedESQueries = queries.map(query => {
return toElasticsearchQuery(fromKueryExpression(query.query), indexPattern);
});

const result = buildQueryFromKuery(indexPattern, queries, true);

expect(result.filter).to.eql(expectedESQueries);
});

});

});
18 changes: 18 additions & 0 deletions packages/kbn-es-query/src/es_query/__tests__/from_lucene.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,22 @@ describe('build query', function () {

});

it('should accept a date format in the decorated queries and combine that into the bool\'s must clause', function () {
const queries = [
{ query: 'foo:bar', language: 'lucene' },
{ query: 'bar:baz', language: 'lucene' },
];
const dateFormatTZ = 'America/Phoenix';

const expectedESQueries = queries.map(
(query) => {
return decorateQuery(luceneStringToDsl(query.query), {}, dateFormatTZ);
}
);

const result = buildQueryFromLucene(queries, {}, dateFormatTZ);

expect(result.must).to.eql(expectedESQueries);
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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 expect from '@kbn/expect';
import { getEsQueryConfig } from '../get_es_query_config';

const config = {
get(item) {
return config[item];
},
'query:allowLeadingWildcards': {
allowLeadingWildcards: true,
},
'query:queryString:options': {
queryStringOptions: {},
},
'courier:ignoreFilterIfFieldNotInIndex': {
ignoreFilterIfFieldNotInIndex: true,
},
'dateFormat:tz': {
dateFormatTZ: 'Browser',
},
};

describe('getEsQueryConfig', function () {
it('should return the parameters of an Elasticsearch query config requested', function () {
const result = getEsQueryConfig(config);
const expected = {
allowLeadingWildcards: {
allowLeadingWildcards: true,
},
dateFormatTZ: {
dateFormatTZ: 'Browser',
},
ignoreFilterIfFieldNotInIndex: {
ignoreFilterIfFieldNotInIndex: true,
},
queryStringOptions: {
queryStringOptions: {},
},
};
expect(result).to.eql(expected);
expect(result).to.have.keys(
'allowLeadingWildcards',
'dateFormatTZ',
'ignoreFilterIfFieldNotInIndex',
'queryStringOptions'
);
});
});
Loading

0 comments on commit 9501d3d

Please sign in to comment.