Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into detections-ad…
Browse files Browse the repository at this point in the history
…d-alerts
  • Loading branch information
XavierM committed Jan 16, 2020
2 parents 7660edb + bc69d6e commit 12395be
Show file tree
Hide file tree
Showing 51 changed files with 530 additions and 1,607 deletions.
129 changes: 48 additions & 81 deletions docs/visualize/tilemap.asciidoc
Original file line number Diff line number Diff line change
@@ -1,105 +1,72 @@
[[tilemap]]
== Coordinate Maps
== Coordinate map

A coordinate map displays a geographic area overlaid with circles keyed to the data determined by the buckets you specify.
Coordinate maps display geographic areas overlaid with circles keyed to the data determined by the buckets you specify. To use coordinate maps, you plot latitude and longitude coordinates.

Kibana’s out-of-the-box settings do not show a coordinate map in the New Visualization menu. Use <<maps>> instead, which offers more functionality and is easier to use.
If you want to create new coordinate map visualizations, set `xpack.maps.showMapVisualizationTypes` to `true`.
NOTE: Coordinate maps have been replaced with <<maps>>, which offers more functionality and is easier to use.

Kibana uses the https://www.elastic.co/elastic-maps-service[Elastic Maps Service]
to display map tiles. To use other tile service providers, configure the <<tilemap-settings,tilemap settings>>
To create coordinate maps in Visualize:

* Set `xpack.maps.showMapVisualizationTypes` to `true`.

* To display map tiles, {kib} uses the https://www.elastic.co/elastic-maps-service[Elastic Maps Service].
To use other tile service providers, configure the <<tilemap-settings,tilemap settings>>
in `kibana.yml`.

[float]
[[tilemap-configuration]]
=== Configuration
[[coordinate-map-aggregation]]
=== Supported aggregations

[float]
==== Data
Coordinate maps support the metric and bucket aggregations.

[float]
===== Metrics

The default _metrics_ aggregation for a coordinate map is the *Count* aggregation. You can select any of the following
aggregations as the metrics aggregation:

*Count*:: The {ref}/search-aggregations-metrics-valuecount-aggregation.html[_count_] aggregation returns a raw count of
the elements in the selected index pattern.
*Average*:: This aggregation returns the {ref}/search-aggregations-metrics-avg-aggregation.html[_average_] of a numeric
field. Select a field from the drop-down.
*Sum*:: The {ref}/search-aggregations-metrics-sum-aggregation.html[_sum_] aggregation returns the total sum of a numeric
field. Select a field from the drop-down.
*Min*:: The {ref}/search-aggregations-metrics-min-aggregation.html[_min_] aggregation returns the minimum value of a
numeric field. Select a field from the drop-down.
*Max*:: The {ref}/search-aggregations-metrics-max-aggregation.html[_max_] aggregation returns the maximum value of a
numeric field. Select a field from the drop-down.
*Unique Count*:: The {ref}/search-aggregations-metrics-cardinality-aggregation.html[_cardinality_] aggregation returns
the number of unique values in a field. Select a field from the drop-down.

Enter a string in the *Custom Label* field to change the display label.
===== Metric aggregations

[float]
===== Buckets
The following metric aggregations are supported:

Coordinate maps use the {ref}/search-aggregations-bucket-geohashgrid-aggregation.html[_geohash_] aggregation. Select a field, typically coordinates, from the
drop-down.
{ref}/search-aggregations-metrics-valuecount-aggregation.html[Count]:: Returns a raw count of
the elements in the index pattern. The default metrics aggregation for a coordinate map is *Count*.

- The _Change precision on map zoom_ box is checked by default. Uncheck the box to disable this behavior.
The _Precision_ slider determines the granularity of the results displayed on the map. See the documentation
for the {ref}/search-aggregations-bucket-geohashgrid-aggregation.html#_cell_dimensions_at_the_equator[geohash grid]
aggregation for details on the area specified by each precision level.
{ref}/search-aggregations-metrics-avg-aggregation.html[Average]:: Returns the average of a numeric
field.

NOTE: Higher precisions increase memory usage for the browser displaying Kibana as well as for the underlying
Elasticsearch cluster.
{ref}/search-aggregations-metrics-sum-aggregation.html[Sum]:: Returns the total sum of a numeric
field.

- The _place markers off grid (use {ref}/search-aggregations-metrics-geocentroid-aggregation.html[geocentroid])_ box is checked by default. When this box is checked, the markers are
placed in the center of all the documents in that bucket. When unchecked, the markers are placed in the center
of the geohash grid cell. Leaving this checked generally results in a more accurate visualization.
{ref}/search-aggregations-metrics-min-aggregation.html[Min]:: Returns the minimum value of a
numeric field.

{ref}/search-aggregations-metrics-max-aggregation.html[Max]:: Returns the maximum value of a
numeric field.

Enter a string in the *Custom Label* field to change the display label.
{ref}/search-aggregations-metrics-cardinality-aggregation.html[Unique Count]:: Returns
the number of unique values in a field.

[float]
==== Options

*Map type*:: Select one of the following options from the drop-down.
*_Scaled Circle Markers_*:: Scale the size of the markers based on the metric aggregation's value.
*_Shaded Circle Markers_*:: Displays the markers with different shades based on the metric aggregation's value.
*_Shaded Geohash Grid_*:: Displays the rectangular cells of the geohash grid instead of circular markers, with different
shades based on the metric aggregation's value.
*_Heatmap_*:: A heat map applies blurring to the circle markers and applies shading based on the amount of overlap.
Heatmaps have the following options:

* *Cluster size*: Adjust the size of the heatmap clustering.
* *Show Tooltip*: Check this box to have a tooltip with the values for a given dot when the cursor is on that dot.

*Desaturate map tiles*:: Desaturate the map's color in order to make the markers stand out more clearly.
*WMS compliant map server*:: Check this box to enable the use of a third-party mapping service that complies with the Web
Map Service (WMS) standard. Specify the following elements:

* *WMS url*: The URL for the WMS map service.
* *WMS layers*: A comma-separated list of the layers to use in this visualization. Each map server provides its own list of
layers.
* *WMS version*: The WMS version used by this map service.
* *WMS format*: The image format used by this map service. The two most common formats are `image/png` and `image/jpeg`.
* *WMS attribution*: An optional, user-defined string that identifies the map source. Maps display the attribution string
in the lower right corner.
* *WMS styles*: A comma-separated list of the styles to use in this visualization. Each map server provides its own styling
options.

After changing options, click the *Apply changes* button to update your visualization, or the grey *Discard
changes* button to keep your visualization in its current state.
[[coordinate-bucket-aggregation]]
===== Bucket aggregation

Coordinate maps support the {ref}/search-aggregations-bucket-geohashgrid-aggregation.html[_geohash_] bucket aggregation.

When you deselect *Change precision on map zoom*, the *Precision* slider appears. The *Precision* slider determines the granularity of the results displayed on the map. For details on the area specified by each precision level, refer to {ref}/search-aggregations-bucket-geohashgrid-aggregation.html#_cell_dimensions_at_the_equator[geohash grid].

NOTE: Higher precisions increase memory usage for the browser that displays {kib} and the underlying
{es} cluster.

When you select *Place markers off grid (use {ref}/search-aggregations-metrics-geocentroid-aggregation.html[geocentroid])*, the markers are
placed in the center of all documents in the bucket, and a more accurate visualization is created.
NOTE: When you have multiple values in the geo_point, the coordinate map is unable to accurately calculate the geo_centroid.

When you deselect *Place markers off grid (use {ref}/search-aggregations-metrics-geocentroid-aggregation.html[geocentroid])*, the markers are placed in the center
of the geohash grid cell.

[float]
[[navigate-map]]
=== Navigating the Map
=== Navigate the coordinate map

Once your tilemap visualization is ready, you can explore the map in several ways:
Use the following navigation options:

* Click and hold anywhere on the map and move the cursor to move the map center. Hold Shift and drag a bounding box
across the map to zoom in on the selection.
* Click the *Zoom In/Out* image:images/viz-zoom.png[] buttons to change the zoom level manually.
* Click the *Fit Data Bounds* image:images/viz-fit-bounds.png[] button to automatically crop the map boundaries to the
geohash buckets that have at least one result.
* Click the *Latitude/Longitude Filter* image:images/viz-lat-long-filter.png[] button, then drag a bounding box across the
map, to create a filter for the box coordinates.
* To move the map center, click and hold anywhere on the map and move the cursor.
* To change the zoom level, click *Zoom In* or *Zoom out* image:images/viz-zoom.png[].
* To automatically crop the map boundaries to the
geohash buckets that have at least one result, click *Fit Data Bounds* image:images/viz-fit-bounds.png[].
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ export const TimePickerPopover: FunctionComponent<Props> = ({ from, to, onSelect
anchorClassName="canvasTimePickerPopover__anchor"
button={button}
>
{() => <TimePicker from={from} to={to} onSelect={onSelect} />}
{({ closePopover }) => (
<TimePicker
from={from}
to={to}
onSelect={(...args) => {
onSelect(...args);
closePopover();
}}
/>
)}
</Popover>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ function selectorFactory(dispatch) {
export const ElementWrapper = compose(
connectAdvanced(selectorFactory),
withPropsOnChange(
(props, nextProps) => !isEqual(props.element, nextProps.element),
(props, nextProps) =>
!isEqual(props.element, nextProps.element) ||
!isEqual(props.selectedPage, nextProps.selectedPage),
props => {
const { element, createHandlers } = props;
const handlers = createHandlers(element, props.selectedPage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ export const WorkpadExport = compose<ComponentProps, {}>(
enabled,
getExportUrl: type => {
if (type === 'pdf') {
const { createPdfUri } = getPdfUrl(
workpad,
{ pageCount },
kibana.services.http.basePath.prepend
);
return getAbsoluteUrl(createPdfUri);
const pdfUrl = getPdfUrl(workpad, { pageCount }, kibana.services.http.basePath.prepend);
return getAbsoluteUrl(pdfUrl);
}

throw new Error(strings.getUnknownExportErrorMessage(type));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

jest.mock('../../../../common/lib/fetch');

import { getPdfUrl, createPdf } from './utils';
import { workpads } from '../../../../__tests__/fixtures/workpads';
import { fetch } from '../../../../common/lib/fetch';

const addBasePath = jest.fn().mockImplementation(s => `basepath/${s}`);
const workpad = workpads[0];

test('getPdfUrl returns the correct url', () => {
const url = getPdfUrl(workpad, { pageCount: 2 }, addBasePath);

expect(url).toMatchInlineSnapshot(
`"basepath//api/reporting/generate/printablePdf?jobParams=(browserTimezone:America%2FPhoenix,layout:(dimensions:(height:0,width:0),id:preserve_layout),objectType:'canvas%20workpad',relativeUrls:!(%2Fapp%2Fcanvas%23%2Fexport%2Fworkpad%2Fpdf%2Fbase-workpad%2Fpage%2F1,%2Fapp%2Fcanvas%23%2Fexport%2Fworkpad%2Fpdf%2Fbase-workpad%2Fpage%2F2),title:'base%20workpad')"`
);
});

test('createPdf posts to create the pdf', () => {
createPdf(workpad, { pageCount: 2 }, addBasePath);

expect(fetch.post).toBeCalled();

const args = (fetch.post as jest.MockedFunction<typeof fetch.post>).mock.calls[0];

expect(args[0]).toMatchInlineSnapshot(`"basepath//api/reporting/generate/printablePdf"`);
expect(args[1]).toMatchInlineSnapshot(`
Object {
"jobParams": "(browserTimezone:America/Phoenix,layout:(dimensions:(height:0,width:0),id:preserve_layout),objectType:'canvas workpad',relativeUrls:!(/app/canvas#/export/workpad/pdf/base-workpad/page/1,/app/canvas#/export/workpad/pdf/base-workpad/page/2),title:'base workpad')",
}
`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import rison from 'rison-node';
// @ts-ignore Untyped local.
import { fetch } from '../../../../common/lib/fetch';
import { getStartPlugins } from '../../../legacy';
import { CanvasWorkpad } from '../../../../types';

// type of the desired pdf output (print or preserve_layout)
Expand All @@ -25,7 +26,7 @@ interface PdfUrlData {
createPdfPayload: { jobParams: string };
}

export function getPdfUrl(
function getPdfUrlParts(
{ id, name: title, width, height }: CanvasWorkpad,
{ pageCount }: PageCount,
addBasePath: (path: string) => string
Expand Down Expand Up @@ -68,7 +69,16 @@ export function getPdfUrl(
};
}

export function getPdfUrl(...args: Arguments): string {
const urlParts = getPdfUrlParts(...args);

return `${urlParts.createPdfUri}?${getStartPlugins().__LEGACY.QueryString.param(
'jobParams',
urlParts.createPdfPayload.jobParams
)}`;
}

export function createPdf(...args: Arguments) {
const { createPdfUri, createPdfPayload } = getPdfUrl(...args);
const { createPdfUri, createPdfPayload } = getPdfUrlParts(...args);
return fetch.post(createPdfUri, createPdfPayload);
}
3 changes: 3 additions & 0 deletions x-pack/legacy/plugins/canvas/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url'; // eslint-d
import { Storage } from '../../../../../src/plugins/kibana_utils/public'; // eslint-disable-line import/order
// @ts-ignore Untyped Kibana Lib
import { formatMsg } from 'ui/notify/lib/format_msg'; // eslint-disable-line import/order
// @ts-ignore Untyped Kibana Lib
import { QueryString } from 'ui/utils/query_string'; // eslint-disable-line import/order

const shimCoreSetup = {
...npSetup.core,
Expand All @@ -30,6 +32,7 @@ const shimStartPlugins: CanvasStartDeps = {
absoluteToParsedUrl,
// ToDo: Copy directly into canvas
formatMsg,
QueryString,
// ToDo: Remove in favor of core.application.register
setRootController: chrome.setRootController,
storage: Storage,
Expand Down
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/canvas/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface CanvasStartDeps {
__LEGACY: {
absoluteToParsedUrl: (url: string, basePath: string) => any;
formatMsg: any;
QueryString: any;
setRootController: Chrome['setRootController'];
storage: typeof Storage;
trackSubUrlForApp: Chrome['trackSubUrlForApp'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ $icon-size: 20px;
border-radius: 4px;
width: $icon-size;
height: $icon-size;
line-height: $icon-size;;
line-height: $icon-size;
text-align: center;
position: relative;

.field-type-icon {
padding: 0;
display: inline !important;
vertical-align: initial;
display: inline-block !important;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
border-color: $euiColorVis5;

.field-type-icon-container {
background-color: rgba($euiColorVis5, 0.5);
background-color: rgba($euiColorVis5, 0.2);
}
}

Expand All @@ -26,7 +26,7 @@
border-color: $euiColorVis7;

.field-type-icon-container {
background-color: rgba($euiColorVis7, 0.5);
background-color: rgba($euiColorVis7, 0.2);
}
}

Expand All @@ -35,7 +35,7 @@
border-color: $euiColorVis2;

.field-type-icon-container {
background-color: rgba($euiColorVis2, 0.5);
background-color: rgba($euiColorVis2, 0.2);
}
}

Expand All @@ -44,7 +44,7 @@
border-color: $euiColorVis8;

.field-type-icon-container {
background-color: rgba($euiColorVis8, 0.5);
background-color: rgba($euiColorVis8, 0.2);
}
}

Expand All @@ -53,7 +53,7 @@
border-color: $euiColorVis3;

.field-type-icon-container {
background-color: rgba($euiColorVis3, 0.5);
background-color: rgba($euiColorVis3, 0.2);
}
}

Expand All @@ -62,7 +62,7 @@
border-color: $euiColorVis0;

.field-type-icon-container {
background-color: rgba($euiColorVis0, 0.5);
background-color: rgba($euiColorVis0, 0.2);
}
}

Expand All @@ -71,7 +71,7 @@
border-color: $euiColorVis1;

.field-type-icon-container {
background-color: rgba($euiColorVis1, 0.5);
background-color: rgba($euiColorVis1, 0.2);
}
}

Expand All @@ -80,7 +80,7 @@
border-color: $euiColorVis9;

.field-type-icon-container {
background-color: rgba($euiColorVis9, 0.5);
background-color: rgba($euiColorVis9, 0.2);
}
}

Expand All @@ -90,7 +90,7 @@
border-color: $euiColorVis6;

.field-type-icon-container {
background-color: rgba($euiColorVis6, 0.5);
background-color: rgba($euiColorVis6, 0.2);
}
}

Expand Down
Loading

0 comments on commit 12395be

Please sign in to comment.