Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into fix/kbn-optim…
Browse files Browse the repository at this point in the history
…izer/zombie-workers
  • Loading branch information
spalger committed May 19, 2020
2 parents d1f722c + a7c2db7 commit 5fc11e5
Show file tree
Hide file tree
Showing 41 changed files with 448 additions and 197 deletions.
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/aggs/metrics/avg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getAvgMetricAgg = ({ getInternalStartServices }: AvgMetricAggDepend
{
name: 'field',
type: 'field',
filterFieldTypes: KBN_FIELD_TYPES.NUMBER,
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM],
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/aggs/metrics/sum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getSumMetricAgg = ({ getInternalStartServices }: SumMetricAggDepend
{
name: 'field',
type: 'field',
filterFieldTypes: KBN_FIELD_TYPES.NUMBER,
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM],
},
],
},
Expand Down
1 change: 1 addition & 0 deletions test/functional/page_objects/visualize_chart_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ export function VisualizeChartPageProvider({ getService, getPageObjects }: FtrPr

/**
* If you are writing new tests, you should rather look into getTableVisContent method instead.
* @deprecated Use getTableVisContent instead.
*/
public async getTableVisData() {
return await testSubjects.getVisibleText('paginated-table-body');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React, { useMemo } from 'react';
import { EuiFlexItem } from '@elastic/eui';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { WaffleSortControls } from '../../../../public/pages/metrics/inventory_view/components/waffle/waffle_sort_controls';
import { ToolbarProps } from '../../../../public/pages/metrics/inventory_view/components/toolbars/toolbar';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { WaffleMetricControls } from '../../../../public/pages/metrics/inventory_view/components/waffle/metric_control';
Expand Down Expand Up @@ -58,6 +59,11 @@ export const MetricsAndGroupByToolbarItems = (props: Props) => {
customOptions={props.customOptions}
/>
</EuiFlexItem>
{props.view === 'map' && (
<EuiFlexItem grow={false}>
<WaffleSortControls sort={props.sort} onChange={props.changeSort} />
</EuiFlexItem>
)}
</>
);
};
10 changes: 10 additions & 0 deletions x-pack/plugins/infra/common/saved_objects/inventory_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ export const inventoryViewSavedObjectType: SavedObjectsType = {
name: {
type: 'keyword',
},
sort: {
properties: {
by: {
type: 'keyword',
},
direction: {
type: 'keyword',
},
},
},
metric: {
properties: {
type: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
Settings,
TooltipValue,
RectAnnotation,
AnnotationDomainTypes,
LineAnnotation,
} from '@elastic/charts';
import { first, last } from 'lodash';
import moment from 'moment';
Expand Down Expand Up @@ -140,6 +142,7 @@ export const ExpressionChart: React.FC<Props> = ({
}

const isAbove = [Comparator.GT, Comparator.GT_OR_EQ].includes(expression.comparator);
const isBelow = [Comparator.LT, Comparator.LT_OR_EQ].includes(expression.comparator);
const opacity = 0.3;
const { timeSize, timeUnit } = expression;
const timeLabel = TIME_LABELS[timeUnit];
Expand All @@ -149,44 +152,49 @@ export const ExpressionChart: React.FC<Props> = ({
<ChartContainer>
<Chart>
<MetricExplorerSeriesChart
type={MetricsExplorerChartType.area}
type={MetricsExplorerChartType.bar}
metric={metric}
id="0"
series={series}
stack={false}
/>
{thresholds.length ? (
<MetricExplorerSeriesChart
type={isAbove ? MetricsExplorerChartType.line : MetricsExplorerChartType.area}
metric={{
...metric,
color: MetricsExplorerColor.color1,
label: i18n.translate('xpack.infra.metrics.alerts.thresholdLabel', {
defaultMessage: 'Threshold',
}),
}}
id={thresholds.map((t, i) => `threshold_${i}`)}
series={series}
stack={false}
opacity={opacity}
/>
) : null}
{thresholds.length && expression.comparator === Comparator.OUTSIDE_RANGE ? (
<LineAnnotation
id={`thresholds`}
domainType={AnnotationDomainTypes.YDomain}
dataValues={thresholds.map(threshold => ({
dataValue: threshold,
}))}
style={{
line: {
strokeWidth: 2,
stroke: colorTransformer(MetricsExplorerColor.color1),
opacity: 1,
},
}}
/>
{thresholds.length === 2 && expression.comparator === Comparator.BETWEEN ? (
<>
<MetricExplorerSeriesChart
type={MetricsExplorerChartType.line}
metric={{
...metric,
color: MetricsExplorerColor.color1,
label: i18n.translate('xpack.infra.metrics.alerts.thresholdLabel', {
defaultMessage: 'Threshold',
}),
<RectAnnotation
id="lower-threshold"
style={{
fill: colorTransformer(MetricsExplorerColor.color1),
opacity,
}}
id={thresholds.map((t, i) => `threshold_${i}`)}
series={series}
stack={false}
opacity={opacity}
dataValues={[
{
coordinates: {
x0: firstTimestamp,
x1: lastTimestamp,
y0: first(expression.threshold),
y1: last(expression.threshold),
},
},
]}
/>
</>
) : null}
{thresholds.length === 2 && expression.comparator === Comparator.OUTSIDE_RANGE ? (
<>
<RectAnnotation
id="lower-threshold"
style={{
Expand Down Expand Up @@ -223,6 +231,25 @@ export const ExpressionChart: React.FC<Props> = ({
/>
</>
) : null}
{isBelow && first(expression.threshold) != null ? (
<RectAnnotation
id="upper-threshold"
style={{
fill: colorTransformer(MetricsExplorerColor.color1),
opacity,
}}
dataValues={[
{
coordinates: {
x0: firstTimestamp,
x1: lastTimestamp,
y0: domain.min,
y1: first(expression.threshold),
},
},
]}
/>
) : null}
{isAbove && first(expression.threshold) != null ? (
<RectAnnotation
id="upper-threshold"
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/infra/public/lib/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
SnapshotNodeMetric,
SnapshotNodePath,
} from '../../common/http_api/snapshot_api';
import { WaffleSortOption } from '../pages/metrics/inventory_view/hooks/use_waffle_options';

export interface InfraFrontendLibs {
apolloClient: InfraApolloClient;
Expand Down Expand Up @@ -163,6 +164,7 @@ export interface InfraWaffleMapOptions {
metric: SnapshotMetricInput;
groupBy: SnapshotGroupBy;
legend: InfraWaffleMapLegend;
sort: WaffleSortOption;
}

export interface InfraOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const Layout = () => {
const {
metric,
groupBy,
sort,
nodeType,
accountId,
region,
Expand Down Expand Up @@ -64,6 +65,7 @@ export const Layout = () => {
],
} as InfraWaffleMapGradientLegend,
metric,
sort,
fields: source?.configuration?.fields,
groupBy,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ import { ToolbarWrapper } from './toolbar_wrapper';
import { InfraGroupByOptions } from '../../../../../lib/lib';
import { IIndexPattern } from '../../../../../../../../../src/plugins/data/public';
import { InventoryItemType } from '../../../../../../common/inventory_models/types';
import { WaffleOptionsState } from '../../hooks/use_waffle_options';
import { WaffleOptionsState, WaffleSortOption } from '../../hooks/use_waffle_options';
import { useInventoryMeta } from '../../hooks/use_inventory_meta';

export interface ToolbarProps
extends Omit<WaffleOptionsState, 'view' | 'boundsOverride' | 'autoBounds'> {
export interface ToolbarProps extends Omit<WaffleOptionsState, 'boundsOverride' | 'autoBounds'> {
createDerivedIndexPattern: (type: 'logs' | 'metrics' | 'both') => IIndexPattern;
changeMetric: (payload: SnapshotMetricInput) => void;
changeGroupBy: (payload: SnapshotGroupBy) => void;
changeCustomOptions: (payload: InfraGroupByOptions[]) => void;
changeAccount: (id: string) => void;
changeRegion: (name: string) => void;
changeSort: (sort: WaffleSortOption) => void;
accounts: InventoryCloudAccount[];
regions: string[];
changeCustomMetrics: (payload: SnapshotCustomMetricInput[]) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ export const ToolbarWrapper = (props: Props) => {
changeCustomOptions,
changeAccount,
changeRegion,
changeSort,
customOptions,
groupBy,
metric,
nodeType,
accountId,
view,
region,
sort,
customMetrics,
changeCustomMetrics,
} = useWaffleOptionsContext();
Expand All @@ -47,8 +50,11 @@ export const ToolbarWrapper = (props: Props) => {
changeAccount,
changeRegion,
changeCustomOptions,
changeSort,
customOptions,
groupBy,
sort,
view,
metric,
nodeType,
region,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { GroupOfNodes } from './group_of_nodes';
import { applyWaffleMapLayout } from '../../lib/apply_wafflemap_layout';
import { SnapshotNode } from '../../../../../../common/http_api/snapshot_api';
import { InventoryItemType } from '../../../../../../common/inventory_models/types';
import { sortNodes } from '../../lib/sort_nodes';

interface Props {
nodes: SnapshotNode[];
Expand All @@ -37,7 +38,8 @@ export const Map: React.FC<Props> = ({
nodeType,
dataBounds,
}) => {
const map = nodesToWaffleMap(nodes);
const sortedNodes = sortNodes(options.sort, nodes);
const map = nodesToWaffleMap(sortedNodes);
return (
<AutoSizer content>
{({ measureRef, content: { width = 0, height = 0 } }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ export const WaffleMetricControls = ({
}

const button = (
<DropdownButton onClick={handleToggle} label="Metric">
<DropdownButton
onClick={handleToggle}
label={i18n.translate('xpack.infra.waffle.metriclabel', { defaultMessage: 'Metric' })}
>
{currentLabel}
</DropdownButton>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export const WaffleAccountsControls = (props: Props) => {
);

const button = (
<DropdownButton label="Account" onClick={showPopover}>
<DropdownButton
label={i18n.translate('xpack.infra.waffle.accountLabel', { defaultMessage: 'Account' })}
onClick={showPopover}
>
{currentLabel
? currentLabel.name
: i18n.translate('xpack.infra.waffle.accountAllTitle', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ export const WaffleGroupByControls = class extends React.PureComponent<Props, St
);

const button = (
<DropdownButton label="Group By" onClick={this.handleToggle}>
<DropdownButton
label={i18n.translate('xpack.infra.waffle.groupByLabel', { defaultMessage: 'Group by' })}
onClick={this.handleToggle}
>
{buttonBody}
</DropdownButton>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { EuiPopover, EuiContextMenu, EuiContextMenuPanelDescriptor } from '@elastic/eui';

import React, { useCallback, useState, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { findInventoryModel } from '../../../../../../common/inventory_models';
import { InventoryItemType } from '../../../../../../common/inventory_models/types';
import { useWaffleOptionsContext } from '../../hooks/use_waffle_options';
Expand Down Expand Up @@ -115,7 +116,10 @@ export const WaffleInventorySwitcher: React.FC = () => {
}, [nodeType]);

const button = (
<DropdownButton onClick={openPopover} label="Show">
<DropdownButton
onClick={openPopover}
label={i18n.translate('xpack.infra.waffle.showLabel', { defaultMessage: 'Show' })}
>
{selectedText}
</DropdownButton>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export const WaffleRegionControls = (props: Props) => {
);

const button = (
<DropdownButton onClick={showPopover} label="Region">
<DropdownButton
onClick={showPopover}
label={i18n.translate('xpack.infra.waffle.regionLabel', { defaultMessage: 'Region' })}
>
{currentLabel ||
i18n.translate('xpack.infra.waffle.region', {
defaultMessage: 'All',
Expand Down
Loading

0 comments on commit 5fc11e5

Please sign in to comment.