Skip to content

Commit

Permalink
[Maps] observability real user monitoring solution layer (#64949)
Browse files Browse the repository at this point in the history
* [Maps] observability real user monitoring solution layer

* make stateful component

* rename RUM to observability

* layer select

* metrics select

* display select

* clean up

* create cholopleth map layer descriptor

* get styling working

* fix unique count agg

* create geo grid source

* render as heatmap

* clusters

* tslint errors

* last tslint fix

* only show card when APM index exists

* layer label

* clean up

* fix getLayerWizards

* add parans

* review feedback

* add cluster labels

* use green to red ramp

* tslint fix

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
nreese and elasticmachine authored May 5, 2020
1 parent 415d33b commit 891e27e
Show file tree
Hide file tree
Showing 26 changed files with 1,075 additions and 81 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export enum SOURCE_TYPES {
ES_GEO_GRID = 'ES_GEO_GRID',
ES_SEARCH = 'ES_SEARCH',
ES_PEW_PEW = 'ES_PEW_PEW',
ES_TERM_SOURCE = 'ES_TERM_SOURCE',
EMS_XYZ = 'EMS_XYZ', // identifies a custom TMS source. Name is a little unfortunate.
WMS = 'WMS',
KIBANA_TILEMAP = 'KIBANA_TILEMAP',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export type ESPewPewSourceDescriptor = AbstractESAggSourceDescriptor & {
export type ESTermSourceDescriptor = AbstractESAggSourceDescriptor & {
indexPatternTitle: string;
term: string; // term field name
whereQuery?: Query;
};

export type KibanaRegionmapSourceDescriptor = AbstractSourceDescriptor & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { AGG_DELIMITER, AGG_TYPE, JOIN_FIELD_NAME_PREFIX } from './constants';
import { AGG_DELIMITER, AGG_TYPE, COUNT_PROP_NAME, JOIN_FIELD_NAME_PREFIX } from './constants';

// function in common since its needed by migration
export function getJoinAggKey({
aggType,
aggFieldName,
Expand All @@ -15,8 +14,18 @@ export function getJoinAggKey({
aggType: AGG_TYPE;
aggFieldName?: string;
rightSourceId: string;
}) {
}): string {
const metricKey =
aggType !== AGG_TYPE.COUNT ? `${aggType}${AGG_DELIMITER}${aggFieldName}` : aggType;
return `${JOIN_FIELD_NAME_PREFIX}${metricKey}__${rightSourceId}`;
}

export function getSourceAggKey({
aggType,
aggFieldName,
}: {
aggType: AGG_TYPE;
aggFieldName?: string;
}): string {
return aggType !== AGG_TYPE.COUNT ? `${aggType}${AGG_DELIMITER}${aggFieldName}` : COUNT_PROP_NAME;
}
2 changes: 1 addition & 1 deletion x-pack/plugins/maps/common/migrations/join_agg_key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
LAYER_TYPE,
VECTOR_STYLES,
} from '../constants';
import { getJoinAggKey } from '../get_join_key';
import { getJoinAggKey } from '../get_agg_key';
import {
AggDescriptor,
JoinDescriptor,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import 'gis_map/gis_map';
@import 'layer_addpanel/source_select/index';
@import 'layer_addpanel/index';
@import 'layer_panel/index';
@import 'widget_overlay/index';
@import 'toolbar_overlay/index';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.
*/

import _ from 'lodash';
import React, { Component, Fragment } from 'react';
import { EuiSpacer, EuiCard, EuiIcon } from '@elastic/eui';
import { getLayerWizards, LayerWizard } from '../../layers/layer_wizard_registry';

interface Props {
onSelect: (layerWizard: LayerWizard) => void;
}

interface State {
layerWizards: LayerWizard[];
}

export class LayerWizardSelect extends Component<Props, State> {
private _isMounted: boolean = false;

state = {
layerWizards: [],
};

componentDidMount() {
this._isMounted = true;
this._loadLayerWizards();
}

componentWillUnmount() {
this._isMounted = false;
}

async _loadLayerWizards() {
const layerWizards = await getLayerWizards();
if (this._isMounted) {
this.setState({ layerWizards });
}
}

render() {
return this.state.layerWizards.map((layerWizard: LayerWizard) => {
const icon = layerWizard.icon ? <EuiIcon type={layerWizard.icon} size="l" /> : undefined;

const onClick = () => {
this.props.onSelect(layerWizard);
};

return (
<Fragment key={layerWizard.title}>
<EuiSpacer size="s" />
<EuiCard
className="mapLayerAddpanel__card"
title={layerWizard.title}
icon={icon}
onClick={onClick}
description={layerWizard.description}
layout="horizontal"
data-test-subj={_.camelCase(layerWizard.title)}
/>
</Fragment>
);
});
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import React, { Component, Fragment } from 'react';
import { SourceSelect } from './source_select/source_select';
import { LayerWizardSelect } from './layer_wizard_select';
import { FlyoutFooter } from './flyout_footer';
import { ImportEditor } from './import_editor';
import { EuiButtonEmpty, EuiPanel, EuiTitle, EuiFlyoutHeader, EuiSpacer } from '@elastic/eui';
Expand Down Expand Up @@ -80,8 +80,8 @@ export class AddLayerPanel extends Component {
this.props.removeTransientLayer();
};

_onSourceSelectionChange = ({ layerWizard, isIndexingSource }) => {
this.setState({ layerWizard, importView: isIndexingSource });
_onWizardSelect = layerWizard => {
this.setState({ layerWizard, importView: !!layerWizard.isIndexingSource });
};

_layerAddHandler = () => {
Expand All @@ -100,7 +100,7 @@ export class AddLayerPanel extends Component {

_renderPanelBody() {
if (!this.state.layerWizard) {
return <SourceSelect updateSourceSelection={this._onSourceSelectionChange} />;
return <LayerWizardSelect onSelect={this._onWizardSelect} />;
}

const backButton = this.props.isIndexingTriggered ? null : (
Expand Down
22 changes: 17 additions & 5 deletions x-pack/plugins/maps/public/layers/layer_wizard_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type RenderWizardArguments = {
};

export type LayerWizard = {
checkVisibility?: () => boolean;
checkVisibility?: () => Promise<boolean>;
description: string;
icon: string;
isIndexingSource?: boolean;
Expand All @@ -31,11 +31,23 @@ export type LayerWizard = {
const registry: LayerWizard[] = [];

export function registerLayerWizard(layerWizard: LayerWizard) {
registry.push(layerWizard);
registry.push({
checkVisibility: async () => {
return true;
},
...layerWizard,
});
}

export function getLayerWizards(): LayerWizard[] {
return registry.filter(layerWizard => {
return layerWizard.checkVisibility ? layerWizard.checkVisibility() : true;
export async function getLayerWizards(): Promise<LayerWizard[]> {
const promises = registry.map(async layerWizard => {
return {
...layerWizard,
// @ts-ignore
isVisible: await layerWizard.checkVisibility(),
};
});
return (await Promise.all(promises)).filter(({ isVisible }) => {
return isVisible;
});
}
6 changes: 4 additions & 2 deletions x-pack/plugins/maps/public/layers/load_layer_wizards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ import { tmsLayerWizardConfig } from './sources/xyz_tms_source';
// @ts-ignore
import { wmsLayerWizardConfig } from './sources/wms_source';
import { mvtVectorSourceWizardConfig } from './sources/mvt_single_layer_vector_source';
// @ts-ignore
import { ObservabilityLayerWizardConfig } from './solution_layers/observability';
import { getInjectedVarFunc } from '../kibana_services';

// Registration order determines display order
let registered = false;
export function registerLayerWizards() {
if (registered) {
return;
}

// Registration order determines display order
// @ts-ignore
registerLayerWizard(uploadLayerWizardConfig);
registerLayerWizard(ObservabilityLayerWizardConfig);
// @ts-ignore
registerLayerWizard(esDocumentsLayerWizardConfig);
// @ts-ignore
Expand Down
Loading

0 comments on commit 891e27e

Please sign in to comment.