Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into apm-empty-charts
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Nov 24, 2020
2 parents c069d57 + b312c91 commit a99d89f
Show file tree
Hide file tree
Showing 303 changed files with 2,891 additions and 2,931 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<b>Signature:</b>

```typescript
SearchBar: React.ComponentClass<Pick<Pick<SearchBarProps, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "intl" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, any> & {
WrappedComponent: React.ComponentType<Pick<SearchBarProps, "query" | "isLoading" | "filters" | "onRefresh" | "onRefreshChange" | "refreshInterval" | "intl" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated"> & ReactIntl.InjectedIntlProps>;
SearchBar: React.ComponentClass<Pick<Pick<SearchBarProps, "query" | "isLoading" | "filters" | "intl" | "indexPatterns" | "dataTestSubj" | "refreshInterval" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, "query" | "isLoading" | "filters" | "indexPatterns" | "dataTestSubj" | "refreshInterval" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, any> & {
WrappedComponent: React.ComponentType<Pick<SearchBarProps, "query" | "isLoading" | "filters" | "intl" | "indexPatterns" | "dataTestSubj" | "refreshInterval" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "trackUiMetric" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated"> & ReactIntl.InjectedIntlProps>;
}
```
87 changes: 28 additions & 59 deletions docs/user/dashboard/tutorials.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ Now that you've created your *Lens* visualization, add it to a <<dashboard,dashb
[[vega-lite-tutorial-create-your-first-visualizations]]
=== Create your first visualization with Vega-Lite

experimental[]

In this tutorial, you will learn about how to edit Vega-Lite in {kib} to create
a stacked area chart from an {es} search query. It will give you a starting point
for a more comprehensive
Expand All @@ -88,7 +86,7 @@ In this tutorial, you will build a stacked area chart from one of the {kib} samp
sets.

[role="screenshot"]
image::visualize/images/vega_lite_tutorial_1.png[]
image::visualize/images/vega_lite_tutorial_1.png[Vega-Lite tutorial stacked area chart]

Before beginning this tutorial, install the <<add-sample-data, eCommerce sample data>>
set.
Expand All @@ -98,7 +96,7 @@ line chart which shows the total number of documents across all your indices
within the time range.

[role="screenshot"]
image::visualize/images/vega_lite_default.png[]
image::visualize/images/vega_lite_default.png[Vega-Lite tutorial default visualization]

The text editor contains a Vega-Lite spec written in https://hjson.github.io/[HJSON],
which is similar to JSON but optimized for human editing. HJSON supports:
Expand Down Expand Up @@ -134,7 +132,7 @@ Click "Update". The result is probably not what you expect. You should see a fla
line with 0 results.

You've only changed the index, so the difference must be the query is returning
no results. You can try the <<vega-browser-debugging-console, Vega debugging process>>,
no results. You can try the <<vega-debugging, Vega debugging process>>,
but intuition may be faster for this particular problem.

In this case, the problem is that you are querying the field `@timestamp`,
Expand Down Expand Up @@ -332,38 +330,29 @@ your spec:

If you copy and paste that into your Vega-Lite spec, and click "Update",
you will see a warning saying `Infinite extent for field "key": [Infinity, -Infinity]`.
Let's use our <<vega-browser-debugging-console, Vega debugging skills>> to understand why.
Let's use our <<vega-inspector, Vega debugging skills>> to understand why.

Vega-Lite generates data using the names `source_0` and `data_0`. `source_0` contains
the results from the {es} query, and `data_0` contains the visually encoded results
which are shown in the chart. To debug this problem, you need to compare both.

To look at the source, open the browser dev tools console and type
`VEGA_DEBUG.view.data('source_0')`. You will see:
To inspect data sets, go to *Inspect* and select *View: Vega debug*. You will see a menu with different data sources:

```js
[{
doc_count: 454
key: "Men's Clothing"
time_buckets: {buckets: Array(57)}
Symbol(vega_id): 12822
}, ...]
```
[role="screenshot"]
image::visualize/images/vega_lite_tutorial_3.png[Data set selector showing root, source_0, data_0, and marks]

To compare to the visually encoded data, open the browser dev tools console and type
`VEGA_DEBUG.view.data('data_0')`. You will see:
To look closer at the raw data in Vega, select the option for `source_0` in the dropdown:

```js
[{
doc_count: 454
key: NaN
time_buckets: {buckets: Array(57)}
Symbol(vega_id): 13879
}]
```
[role="screenshot"]
image::visualize/images/vega_lite_tutorial_4.png[Table for data_0 with columns key, doc_count and array of time_buckets]

To compare to the visually encoded data, change the dropdown selection to `data_0`. You will see:

[role="screenshot"]
image::visualize/images/vega_lite_tutorial_5.png[Table for data_0 where the key is NaN instead of a string]

The issue seems to be that the `key` property is not being converted the right way,
which makes sense because the `key` is now `Men's Clothing` instead of a timestamp.
which makes sense because the `key` is now category (`Men's Clothing`, `Women's Clothing`, etc.) instead of a timestamp.

To fix this, try updating the `encoding` of your Vega-Lite spec to:

Expand All @@ -382,21 +371,13 @@ To fix this, try updating the `encoding` of your Vega-Lite spec to:
}
```

This will show more errors, and you can inspect `VEGA_DEBUG.view.data('data_0')` to
This will show more errors, so you need to debug. Click *Inspect*, switch the view to *Vega Debug*, and switch to look at the visually encoded data in `data_0` to
understand why. This now shows:

```js
[{
doc_count: 454
key: "Men's Clothing"
time_buckets: {buckets: Array(57)}
time_buckets.buckets.doc_count: undefined
time_buckets.buckets.key: null
Symbol(vega_id): 14094
}]
```
[role="screenshot"]
image::visualize/images/vega_lite_tutorial_6.png[Table for data_0 showing that the column time_buckets.buckets.key is undefined]

It looks like the problem is that the `time_buckets` inner array is not being
It looks like the problem is that the `time_buckets.buckets` inner array is not being
extracted by Vega. The solution is to use a Vega-lite
https://vega.github.io/vega-lite/docs/flatten.html[flatten transformation], available in {kib} 7.9 and later.
If using an older version of Kibana, the flatten transformation is available in Vega
Expand All @@ -411,23 +392,10 @@ Add this section in between the `data` and `encoding` section:
```

This does not yet produce the results you expect. Inspect the transformed data
by typing `VEGA_DEBUG.view.data('data_0')` into the console again:
by selecting `data_0` in *Data sets* again:

```js
[{
doc_count: 453
key: "Men's Clothing"
time_bucket.buckets.doc_count: undefined
time_buckets: {buckets: Array(57)}
time_buckets.buckets: {
key_as_string: "2020-06-30T15:00:00.000Z",
key: 1593529200000,
doc_count: 2
}
time_buckets.buckets.key: null
Symbol(vega_id): 21564
}]
```
[role="screenshot"]
image::visualize/images/vega_lite_tutorial_7.png[Table showing data_0 with multiple pages of results, but undefined values in the column time_buckets.buckets.key]

The debug view shows `undefined` values where you would expect to see numbers, and
the cause is that there are duplicate names which are confusing Vega-Lite. This can
Expand Down Expand Up @@ -564,7 +532,9 @@ Now that you've enabled a selection, try moving the mouse around the visualizati
and seeing the points respond to the nearest position:

[role="screenshot"]
image::visualize/images/vega_lite_tutorial_2.png[]
image::visualize/images/vega_lite_tutorial_2.png[Vega-Lite tutorial selection enabled]

The selection is controlled by a Vega signal, and can be viewed using the <<vega-inspector, Vega Inspector>>.

The final result of this tutorial is this spec:

Expand Down Expand Up @@ -683,8 +653,6 @@ The final result of this tutorial is this spec:
[[vega-tutorial-update-kibana-filters-from-vega]]
=== Update {kib} filters from Vega

experimental[]

In this tutorial you will build an area chart in Vega using an {es} search query,
and add a click handler and drag handler to update {kib} filters.
This tutorial is not a full https://vega.github.io/vega/tutorials/[Vega tutorial],
Expand Down Expand Up @@ -935,6 +903,7 @@ The first step is to add a new `signal` to track the X position of the cursor:
}]
}
```
To learn more about inspecting signals, explore the <<vega-inspector, Vega Inspector>>.

Now add a new `mark` to indicate the current cursor position:

Expand Down Expand Up @@ -1756,4 +1725,4 @@ Customize and format the visualization using functions:
image::images/timelion-conditional04.png[]
{nbsp}

For additional information on Timelion conditional capabilities, go to https://www.elastic.co/blog/timeseries-if-then-else-with-timelion[I have but one .condition()].
For additional information on Timelion conditional capabilities, go to https://www.elastic.co/blog/timeseries-if-then-else-with-timelion[I have but one .condition()].
Binary file added docs/visualize/images/vega_lite_tutorial_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/visualize/images/vega_lite_tutorial_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/visualize/images/vega_lite_tutorial_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/visualize/images/vega_lite_tutorial_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/visualize/images/vega_lite_tutorial_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"**/prismjs": "1.22.0",
"**/request": "^2.88.2",
"**/trim": "0.0.3",
"**/typescript": "4.0.2"
"**/typescript": "4.1.2"
},
"engines": {
"node": "12.19.1",
Expand Down Expand Up @@ -827,7 +827,7 @@
"topojson-client": "3.0.0",
"ts-loader": "^7.0.5",
"tsd": "^0.13.1",
"typescript": "4.0.2",
"typescript": "4.1.2",
"typescript-fsa": "^3.0.0",
"typescript-fsa-reducers": "^1.2.1",
"unlazy-loader": "^0.1.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-es-archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@kbn/dev-utils": "link:../kbn-dev-utils",
"@kbn/test": "link:../kbn-test"
"@kbn/test": "link:../kbn-test",
"@kbn/utils": "link:../kbn-utils"
}
}
3 changes: 1 addition & 2 deletions packages/kbn-es-archiver/src/actions/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import { createGunzip, createGzip, Z_BEST_COMPRESSION } from 'zlib';
import { promisify } from 'util';
import globby from 'globby';
import { ToolingLog } from '@kbn/dev-utils';

import { createPromiseFromStreams } from '../lib/streams';
import { createPromiseFromStreams } from '@kbn/utils';

const unlinkAsync = promisify(Fs.unlink);

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/actions/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Readable } from 'stream';
import { ToolingLog, KbnClient } from '@kbn/dev-utils';
import { Client } from 'elasticsearch';

import { createPromiseFromStreams, concatStreamProviders } from '../lib/streams';
import { createPromiseFromStreams, concatStreamProviders } from '@kbn/utils';

import {
isGzip,
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-es-archiver/src/actions/rebuild_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { stat, Stats, rename, createReadStream, createWriteStream } from 'fs';
import { Readable, Writable } from 'stream';
import { fromNode } from 'bluebird';
import { ToolingLog } from '@kbn/dev-utils';

import { createPromiseFromStreams } from '../lib/streams';
import { createPromiseFromStreams } from '@kbn/utils';
import {
prioritizeMappings,
readDirectory,
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/actions/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { createWriteStream, mkdirSync } from 'fs';
import { Readable, Writable } from 'stream';
import { Client } from 'elasticsearch';
import { ToolingLog } from '@kbn/dev-utils';
import { createListStream, createPromiseFromStreams } from '@kbn/utils';

import { createListStream, createPromiseFromStreams } from '../lib/streams';
import {
createStats,
createGenerateIndexRecordsStream,
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/actions/unload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { createReadStream } from 'fs';
import { Readable, Writable } from 'stream';
import { Client } from 'elasticsearch';
import { ToolingLog, KbnClient } from '@kbn/dev-utils';
import { createPromiseFromStreams } from '@kbn/utils';

import { createPromiseFromStreams } from '../lib/streams';
import {
isGzip,
createStats,
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export function runCli() {
output: process.stdout,
});

await new Promise((resolveInput) => {
await new Promise<void>((resolveInput) => {
rl.question(`Press enter when you're done`, () => {
rl.close();
resolveInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import Stream, { Readable, Writable } from 'stream';
import { createGunzip } from 'zlib';

import expect from '@kbn/expect';

import { createListStream, createPromiseFromStreams, createConcatStream } from '../../streams';
import { createListStream, createPromiseFromStreams, createConcatStream } from '@kbn/utils';

import { createFormatArchiveStreams } from '../format';

Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-es-archiver/src/lib/archives/__tests__/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import Stream, { PassThrough, Readable, Writable, Transform } from 'stream';
import { createGzip } from 'zlib';

import expect from '@kbn/expect';

import { createConcatStream, createListStream, createPromiseFromStreams } from '../../streams';
import { createConcatStream, createListStream, createPromiseFromStreams } from '@kbn/utils';

import { createParseArchiveStreams } from '../parse';

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/lib/archives/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { createGzip, Z_BEST_COMPRESSION } from 'zlib';
import { PassThrough } from 'stream';
import stringify from 'json-stable-stringify';

import { createMapStream, createIntersperseStream } from '../streams';
import { createMapStream, createIntersperseStream } from '@kbn/utils';
import { RECORD_SEPARATOR } from './constants';

export function createFormatArchiveStreams({ gzip = false }: { gzip?: boolean } = {}) {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/lib/archives/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
createSplitStream,
createReplaceStream,
createMapStream,
} from '../streams';
} from '@kbn/utils';

import { RECORD_SEPARATOR } from './constants';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import sinon from 'sinon';
import expect from '@kbn/expect';
import { delay } from 'bluebird';

import { createListStream, createPromiseFromStreams, createConcatStream } from '../../streams';
import { createListStream, createPromiseFromStreams, createConcatStream } from '@kbn/utils';

import { createGenerateDocRecordsStream } from '../generate_doc_records_stream';
import { Progress } from '../../progress';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

import expect from '@kbn/expect';
import { delay } from 'bluebird';

import { createListStream, createPromiseFromStreams } from '../../streams';
import { createListStream, createPromiseFromStreams } from '@kbn/utils';

import { Progress } from '../../progress';
import { createIndexDocRecordsStream } from '../index_doc_records_stream';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import expect from '@kbn/expect';
import sinon from 'sinon';
import Chance from 'chance';

import { createPromiseFromStreams, createConcatStream, createListStream } from '../../streams';
import { createPromiseFromStreams, createConcatStream, createListStream } from '@kbn/utils';

import { createCreateIndexStream } from '../create_index_stream';

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

import sinon from 'sinon';

import { createListStream, createPromiseFromStreams } from '../../streams';
import { createListStream, createPromiseFromStreams } from '@kbn/utils';

import { createDeleteIndexStream } from '../delete_index_stream';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

import sinon from 'sinon';
import expect from '@kbn/expect';

import { createListStream, createPromiseFromStreams, createConcatStream } from '../../streams';
import { createListStream, createPromiseFromStreams, createConcatStream } from '@kbn/utils';

import { createStubClient, createStubStats } from './stubs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import Chance from 'chance';
import expect from '@kbn/expect';

import { createListStream, createPromiseFromStreams, createConcatStream } from '../../streams';
import { createListStream, createPromiseFromStreams, createConcatStream } from '@kbn/utils';

import { createFilterRecordsStream } from '../filter_records_stream';

Expand Down
Loading

0 comments on commit a99d89f

Please sign in to comment.