Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/merge-code
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 committed Mar 5, 2019
2 parents c21706f + 3155533 commit 58585ee
Show file tree
Hide file tree
Showing 81 changed files with 1,340 additions and 988 deletions.
2 changes: 2 additions & 0 deletions docs/getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ If you are running our https://cloud.elastic.co[hosted Elasticsearch Service]
on Elastic Cloud, you can access Kibana with a single click.
--

include::getting-started/add-sample-data.asciidoc[]

include::getting-started/tutorial-sample-data.asciidoc[]

include::getting-started/tutorial-sample-filter.asciidoc[]
Expand Down
31 changes: 31 additions & 0 deletions docs/getting-started/add-sample-data.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[[add-sample-data]]
== Get up and running with sample data

{kib} has three sample data sets that you can use to explore {kib} before loading your own data
source. Each set is prepackaged with a dashboard of visualizations and a
{kibana-ref}/canvas-getting-started.html[Canvas workpad].

The sample data sets address common use cases:

* *eCommerce orders* includes visualizations for product-related information,
such as cost, revenue, and price.
* *Web logs* lets you analyze website traffic.
* *Flight data* enables you to view and interact with flight routes for four airlines.

To get started, go to the home page and click the link next to *Add sample data*.

Once you have loaded a data set, click *View data* to view visualizations in *Dashboard*.

*Note:* The timestamps in the sample data sets are relative to when they are installed.
If you uninstall and reinstall a data set, the timestamps will change to reflect the most recent installation.


[role="screenshot"]
image::images/add-sample-data.png[]

[float]
==== Next steps

Play with the sample flight data in the {kibana-ref}/tutorial-sample-data.html[flight dashboard tutorial].

Learn how to load data, define index patterns and build visualizations by {kibana-ref}/tutorial-build-dashboard.html[building your own dashboard].
Binary file added docs/images/add-sample-data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions kibana.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export * from './target/types/type_exports';
* All exports from TS ambient definitions (where types are added for JS source in a .d.ts file).
*/
import * as LegacyElasticsearch from './src/legacy/core_plugins/elasticsearch';
import * as LegacyKibanaPluginSpec from './src/legacy/plugin_discovery/plugin_spec/plugin_spec_options';
import * as LegacyKibanaServer from './src/legacy/server/kbn_server';

/**
Expand All @@ -40,6 +41,10 @@ export namespace Legacy {
export type SavedObjectsService = LegacyKibanaServer.SavedObjectsService;
export type Server = LegacyKibanaServer.Server;

export type InitPluginFunction = LegacyKibanaPluginSpec.InitPluginFunction;
export type UiExports = LegacyKibanaPluginSpec.UiExports;
export type PluginSpecOptions = LegacyKibanaPluginSpec.PluginSpecOptions;

export namespace Plugins {
export namespace elasticsearch {
export type Plugin = LegacyElasticsearch.ElasticsearchPlugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@
*/

import { resolve } from 'path';
import init from './init';
import { Legacy } from '../../../../kibana';
import { init } from './init';

export default function (kibana) {
return new kibana.Plugin({
// tslint:disable-next-line
export default function InterpreterPlugin(kibana: any) {
const config: Legacy.PluginSpecOptions = {
id: 'interpreter',
require: ['kibana', 'elasticsearch'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
injectDefaultVars: server => ({ serverBasePath: server.config().get('server.basePath') }),
},
init,
});
}
};

return new kibana.Plugin(config);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,26 @@
* under the License.
*/

import { routes } from './server/routes';
// @ts-ignore
import { registryFactory } from '@kbn/interpreter/common';

// @ts-ignore
import { registries } from '@kbn/interpreter/server';

export default async function (server /*options*/) {
// @ts-ignore
import { routes } from './server/routes';

import { Legacy } from '../../../../kibana';

export async function init(server: Legacy.Server /*options*/) {
server.injectUiAppVars('canvas', () => {
const config = server.config();
const basePath = config.get('server.basePath');
const reportingBrowserType = (() => {
const configKey = 'xpack.reporting.capture.browser.type';
if (!config.has(configKey)) return null;
if (!config.has(configKey)) {
return null;
}
return config.get(configKey);
})();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('context app', function () {
it('should use the `fetch` method of the SearchSource', function () {
const searchSourceStub = new SearchSourceStub();

return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'asc' }])
return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'desc' }])
.then(() => {
expect(searchSourceStub.fetch.calledOnce).to.be(true);
});
Expand All @@ -77,7 +77,7 @@ describe('context app', function () {
it('should configure the SearchSource to not inherit from the implicit root', function () {
const searchSourceStub = new SearchSourceStub();

return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'asc' }])
return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'desc' }])
.then(() => {
const setParentSpy = searchSourceStub.setParent;
expect(setParentSpy.calledOnce).to.be(true);
Expand All @@ -88,7 +88,7 @@ describe('context app', function () {
it('should set the SearchSource index pattern', function () {
const searchSourceStub = new SearchSourceStub();

return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'asc' }])
return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'desc' }])
.then(() => {
const setFieldSpy = searchSourceStub.setField;
expect(setFieldSpy.firstCall.args[1]).to.eql({ id: 'INDEX_PATTERN_ID' });
Expand All @@ -98,7 +98,7 @@ describe('context app', function () {
it('should set the SearchSource version flag to true', function () {
const searchSourceStub = new SearchSourceStub();

return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'asc' }])
return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'desc' }])
.then(() => {
const setVersionSpy = searchSourceStub.setField.withArgs('version');
expect(setVersionSpy.calledOnce).to.be(true);
Expand All @@ -109,7 +109,7 @@ describe('context app', function () {
it('should set the SearchSource size to 1', function () {
const searchSourceStub = new SearchSourceStub();

return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'asc' }])
return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'desc' }])
.then(() => {
const setSizeSpy = searchSourceStub.setField.withArgs('size');
expect(setSizeSpy.calledOnce).to.be(true);
Expand All @@ -120,7 +120,7 @@ describe('context app', function () {
it('should set the SearchSource query to an ids query', function () {
const searchSourceStub = new SearchSourceStub();

return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'asc' }])
return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'desc' }])
.then(() => {
const setQuerySpy = searchSourceStub.setField.withArgs('query');
expect(setQuerySpy.calledOnce).to.be(true);
Expand All @@ -143,13 +143,13 @@ describe('context app', function () {
it('should set the SearchSource sort order', function () {
const searchSourceStub = new SearchSourceStub();

return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'asc' }])
return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'desc' }])
.then(() => {
const setSortSpy = searchSourceStub.setField.withArgs('sort');
expect(setSortSpy.calledOnce).to.be(true);
expect(setSortSpy.firstCall.args[1]).to.eql([
{ '@timestamp': 'desc' },
{ '_doc': 'asc' },
{ '_doc': 'desc' },
]);
});
});
Expand All @@ -158,7 +158,7 @@ describe('context app', function () {
const searchSourceStub = new SearchSourceStub();
searchSourceStub._stubHits = [];

return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'asc' }])
return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'desc' }])
.then(
() => {
expect().fail('expected the promise to be rejected');
Expand All @@ -176,7 +176,7 @@ describe('context app', function () {
{ property2: 'value2' },
];

return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'asc' }])
return fetchAnchor('INDEX_PATTERN_ID', 'doc', 'id', [{ '@timestamp': 'desc' }, { '_doc': 'desc' }])
.then((anchorDocument) => {
expect(anchorDocument).to.have.property('property1', 'value1');
expect(anchorDocument).to.have.property('$$_isAnchor', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 3000,
'_doc',
'asc',
0,
3,
[]
Expand All @@ -90,7 +89,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 3000,
'_doc',
'asc',
0,
6,
[]
Expand Down Expand Up @@ -126,7 +124,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 1000,
'_doc',
'asc',
0,
3,
[]
Expand All @@ -153,7 +150,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 3,
'_doc',
'asc',
0,
3,
[]
Expand All @@ -172,7 +168,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 3,
'_doc',
'asc',
0,
3,
[]
Expand All @@ -183,5 +178,26 @@ describe('context app', function () {
expect(setParentSpy.called).to.be(true);
});
});

it('should set the tiebreaker sort order to the opposite as the time field', function () {
const searchSourceStub = getSearchSourceStub();

return fetchPredecessors(
'INDEX_PATTERN_ID',
'@timestamp',
'desc',
MS_PER_DAY,
'_doc',
0,
3,
[]
)
.then(() => {
expect(searchSourceStub.setField.calledWith('sort', [
{ '@timestamp': 'asc' },
{ '_doc': 'asc' },
])).to.be(true);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 3000,
'_doc',
'asc',
0,
3,
[]
Expand All @@ -90,7 +89,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 3000,
'_doc',
'asc',
0,
6,
[]
Expand Down Expand Up @@ -128,7 +126,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 3000,
'_doc',
'asc',
0,
4,
[]
Expand All @@ -155,7 +152,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 3,
'_doc',
'asc',
0,
3,
[]
Expand All @@ -174,7 +170,6 @@ describe('context app', function () {
'desc',
MS_PER_DAY * 3,
'_doc',
'asc',
0,
3,
[]
Expand All @@ -185,5 +180,26 @@ describe('context app', function () {
expect(setParentSpy.called).to.be(true);
});
});

it('should set the tiebreaker sort order to the same as the time field', function () {
const searchSourceStub = getSearchSourceStub();

return fetchSuccessors(
'INDEX_PATTERN_ID',
'@timestamp',
'desc',
MS_PER_DAY,
'_doc',
0,
3,
[]
)
.then(() => {
expect(searchSourceStub.setField.calledWith('sort', [
{ '@timestamp': 'desc' },
{ '_doc': 'desc' },
])).to.be(true);
});
});
});
});
Loading

0 comments on commit 58585ee

Please sign in to comment.