Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
eb01d93
[maps] time series geo line
nreese Jun 7, 2023
450cc53
cleanup typings
nreese Jun 14, 2023
33e5fcb
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 14, 2023
04a7037
remove changes to kbn-es-types
nreese Jun 14, 2023
b162a33
descriptor type
nreese Jun 14, 2023
8de2ca6
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jun 14, 2023
7ff0bde
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 14, 2023
af0a4db
Merge branch 'main' into time_series_geo_line
kibanamachine Jun 15, 2023
730946d
isTimeseries
nreese Jun 15, 2023
1d42c56
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jun 15, 2023
5f0858c
create form
nreese Jun 15, 2023
bc43bac
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 15, 2023
e2e62fa
Merge branch 'main' into time_series_geo_line
kibanamachine Jun 20, 2023
4adaee8
get time series tracks
nreese Jun 20, 2023
e556c4f
add clarification
nreese Jun 20, 2023
3e27cc0
wire update editor
nreese Jun 20, 2023
3108f71
clean up
nreese Jun 20, 2023
f053812
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jun 20, 2023
47bcee2
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 20, 2023
3e0cdf9
tslint
nreese Jun 20, 2023
193ea30
lint errors and i18n cleanup
nreese Jun 20, 2023
1584d4e
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 20, 2023
d400589
remove size parameter on time_series aggregation
nreese Jun 21, 2023
1fbcee2
line simplification size
nreese Jun 21, 2023
a3438f5
change tooltip to better reflect what complete means
nreese Jun 21, 2023
9bb39ad
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jun 21, 2023
3fcfd14
tslint
nreese Jun 21, 2023
b629cb7
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jun 21, 2023
3abc66b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 21, 2023
066f4ca
Merge branch 'main' into time_series_geo_line
kibanamachine Jun 21, 2023
c56b854
Merge branch 'main' into time_series_geo_line
kibanamachine Jun 22, 2023
adcf11b
compress form when edit panel
nreese Jun 22, 2023
d95d96e
button group
nreese Jun 22, 2023
132f0f2
show max term tracks in tooltip
nreese Jun 22, 2023
4cbeea2
reduce tooltip text size
nreese Jun 22, 2023
a05b1ab
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 22, 2023
5418213
Merge branch 'main' into time_series_geo_line
kibanamachine Jun 22, 2023
ea85cbf
merge with main
nreese Jun 27, 2023
d5acb83
review feedback
nreese Jun 27, 2023
9c9e649
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jun 27, 2023
2fb44e9
Merge branch 'main' into time_series_geo_line
kibanamachine Jun 28, 2023
5ffcc55
Merge branch 'main' into time_series_geo_line
kibanamachine Jun 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/plugins/data_views/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import type { SavedObject } from '@kbn/core/server';
import type { ErrorToastOptions, ToastInputFields } from '@kbn/core-notifications-browser';
Expand Down Expand Up @@ -437,7 +438,7 @@ export type FieldSpec = DataViewFieldBase & {
/**
* set if field is a TSDB metric field
*/
timeSeriesMetric?: 'histogram' | 'summary' | 'gauge' | 'counter';
timeSeriesMetric?: estypes.MappingTimeSeriesMetricType;
Comment thread
nreese marked this conversation as resolved.

// not persisted

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { ElasticsearchClient } from '@kbn/core/server';
import { keyBy } from 'lodash';
import type { QueryDslQueryContainer } from '../../common/types';
Expand All @@ -27,7 +28,7 @@ export interface FieldDescriptor {
metadata_field?: boolean;
fixedInterval?: string[];
timeZone?: string[];
timeSeriesMetric?: 'histogram' | 'summary' | 'counter' | 'gauge';
timeSeriesMetric?: estypes.MappingTimeSeriesMetricType;
timeSeriesDimension?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ export function readFieldCapsResponse(
return agg;
}

let timeSeriesMetricType: 'gauge' | 'counter' | undefined;
let timeSeriesMetricType: 'gauge' | 'counter' | 'position' | undefined;
if (timeSeriesMetricProp.length === 1 && timeSeriesMetricProp[0] === 'gauge') {
timeSeriesMetricType = 'gauge';
}
if (timeSeriesMetricProp.length === 1 && timeSeriesMetricProp[0] === 'counter') {
timeSeriesMetricType = 'counter';
}
// @ts-expect-error MappingTimeSeriesMetricType does not contain 'position'
if (timeSeriesMetricProp.length === 1 && timeSeriesMetricProp[0] === 'position') {
timeSeriesMetricType = 'position';
}
const esType = types[0];
const field = {
name: fieldName,
Expand All @@ -144,7 +148,9 @@ export function readFieldCapsResponse(
timeSeriesDimension: capsByType[types[0]].time_series_dimension,
};
// This is intentionally using a "hash" and a "push" to be highly optimized with very large indexes
// @ts-expect-error MappingTimeSeriesMetricType does not contain 'position'
agg.array.push(field);
// @ts-expect-error MappingTimeSeriesMetricType does not contain 'position'
agg.hash[fieldName] = field;
return agg;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ export type ESGeoGridSourceDescriptor = AbstractESAggSourceDescriptor & {

export type ESGeoLineSourceDescriptor = AbstractESAggSourceDescriptor & {
geoField: string;
splitField: string;
sortField: string;
groupByTimeseries: boolean;
lineSimplificationSize: number;
splitField?: string;
sortField?: string;
};

export type ESSearchSourceDescriptor = AbstractESSourceDescriptor & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function ShowAsLabel(props: Props) {
return (
<EuiToolTip
content={
<EuiText>
<EuiText size="s">
<dl>
<dt>{CLUSTER_LABEL}</dt>
<dd>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// geo_line aggregation without time series buckets uses lots of resources
// limit resource consumption by limiting number of tracks to smaller amount
export const MAX_TERMS_TRACKS = 250;

// Constant is used to identify time series id field in UIs, tooltips, and styling.
// Constant is not passed to Elasticsearch APIs and is not related to '_tsid' document metadata field.
// Constant value of '_tsid' is arbitrary.
export const TIME_SERIES_ID_FIELD_NAME = '_tsid';

export const DEFAULT_LINE_SIMPLIFICATION_SIZE = 500;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export function convertToGeoJson(esResponse: any, entitySplitFieldName: string)
for (let i = 0; i < entityKeys.length; i++) {
const entityKey = entityKeys[i];
const bucket = buckets[entityKey];
const feature = bucket.path as Feature;
const feature = {
...(bucket.path as Feature),
};
Comment thread
nreese marked this conversation as resolved.
if (!feature.properties!.complete) {
numTrimmedTracks++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,47 @@

import React, { Component } from 'react';

import { DataView } from '@kbn/data-plugin/common';
import { i18n } from '@kbn/i18n';
import { EuiFormRow, EuiPanel } from '@elastic/eui';
import { SingleFieldSelect } from '../../../components/single_field_select';
import type { DataView, DataViewField } from '@kbn/data-plugin/common';
import { EuiPanel } from '@elastic/eui';
import { GeoIndexPatternSelect } from '../../../components/geo_index_pattern_select';

import { getGeoPointFields } from '../../../index_pattern_util';
import { GeoFieldSelect } from '../../../components/geo_field_select';
import { ESGeoLineSourceDescriptor } from '../../../../common/descriptor_types';
import { getGeoPointFields, getIsTimeseries } from '../../../index_pattern_util';
import { GeoLineForm } from './geo_line_form';
import { DEFAULT_LINE_SIMPLIFICATION_SIZE } from './constants';

interface Props {
onSourceConfigChange: (
sourceConfig: {
indexPatternId: string;
geoField: string;
splitField: string;
sortField: string;
} | null
) => void;
onSourceConfigChange: (sourceConfig: Partial<ESGeoLineSourceDescriptor> | null) => void;
}

interface State {
indexPattern: DataView | null;
pointFields: DataViewField[];
geoField: string;
groupByTimeseries: boolean;
splitField: string;
sortField: string;
lineSimplificationSize: number;
}

export class CreateSourceEditor extends Component<Props, State> {
state: State = {
indexPattern: null,
pointFields: [],
geoField: '',
groupByTimeseries: false,
splitField: '',
sortField: '',
lineSimplificationSize: DEFAULT_LINE_SIMPLIFICATION_SIZE,
};

_onIndexPatternSelect = (indexPattern: DataView) => {
const pointFields = getGeoPointFields(indexPattern.fields);
this.setState(
{
indexPattern,
pointFields,
groupByTimeseries: getIsTimeseries(indexPattern),
geoField: pointFields.length ? pointFields[0].name : '',
sortField: indexPattern.timeFieldName ? indexPattern.timeFieldName : '',
},
Expand All @@ -67,6 +68,24 @@ export class CreateSourceEditor extends Component<Props, State> {
);
};

_onGroupByTimeseriesChange = (groupByTimeseries: boolean) => {
this.setState(
{
groupByTimeseries,
},
this.previewLayer
);
};

_onLineSimplificationSizeChange = (lineSimplificationSize: number) => {
this.setState(
{
lineSimplificationSize,
},
this.previewLayer
);
};

_onSplitFieldSelect = (newValue: string) => {
this.setState(
{
Expand All @@ -86,11 +105,28 @@ export class CreateSourceEditor extends Component<Props, State> {
};

previewLayer = () => {
const { indexPattern, geoField, splitField, sortField } = this.state;
const {
indexPattern,
geoField,
groupByTimeseries,
splitField,
sortField,
lineSimplificationSize,
} = this.state;

const sourceConfig =
indexPattern && indexPattern.id && geoField && splitField && sortField
? { indexPatternId: indexPattern.id, geoField, splitField, sortField }
indexPattern &&
indexPattern.id &&
geoField &&
(groupByTimeseries || (splitField && sortField))
? {
indexPatternId: indexPattern.id,
geoField,
groupByTimeseries,
lineSimplificationSize,
splitField,
sortField,
}
: null;
this.props.onSourceConfigChange(sourceConfig);
};
Expand All @@ -101,20 +137,12 @@ export class CreateSourceEditor extends Component<Props, State> {
}

return (
<EuiFormRow
label={i18n.translate('xpack.maps.source.esGeoLine.geofieldLabel', {
defaultMessage: 'Geospatial field',
})}
>
<SingleFieldSelect
placeholder={i18n.translate('xpack.maps.source.esGeoLine.geofieldPlaceholder', {
defaultMessage: 'Select geo field',
})}
value={this.state.geoField}
onChange={this._onGeoFieldSelect}
fields={getGeoPointFields(this.state.indexPattern.fields)}
/>
</EuiFormRow>
<GeoFieldSelect
value={this.state.geoField}
onChange={this._onGeoFieldSelect}
geoFields={this.state.pointFields}
isClearable={false}
/>
);
}

Expand All @@ -125,9 +153,14 @@ export class CreateSourceEditor extends Component<Props, State> {

return (
<GeoLineForm
isColumnCompressed={false}
indexPattern={this.state.indexPattern}
onGroupByTimeseriesChange={this._onGroupByTimeseriesChange}
onLineSimplificationSizeChange={this._onLineSimplificationSizeChange}
onSortFieldChange={this._onSortFieldSelect}
onSplitFieldChange={this._onSplitFieldSelect}
groupByTimeseries={this.state.groupByTimeseries}
lineSimplificationSize={this.state.lineSimplificationSize}
sortField={this.state.sortField}
splitField={this.state.splitField}
/>
Expand Down
Loading