Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Synthetics] [ON Week] Refactor Synthetics Overview page for increased scalability #187092

Merged
merged 48 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6528bb2
TEMP.
justinkambic Jun 26, 2024
607f8f9
TEMP.
justinkambic Jun 26, 2024
9895747
PoC.
justinkambic Jun 26, 2024
f0f3cc9
Clean up.
justinkambic Jun 27, 2024
ecac143
Fixup.
justinkambic Jun 27, 2024
c9468f1
Cleanup.
justinkambic Jun 27, 2024
7859e3c
Cleanup.
justinkambic Jun 27, 2024
541a539
Cleanup.
justinkambic Jun 27, 2024
5f7f0e8
Cleanup types.
justinkambic Jul 1, 2024
5b56fe6
Fix color generation code.
justinkambic Jul 2, 2024
31f1bcb
TEMP
justinkambic Jul 3, 2024
3368b3a
TEMP
justinkambic Jul 8, 2024
e3f2a5b
Cleanup.
justinkambic Jul 10, 2024
c1dd4e7
Cleanup.
justinkambic Jul 10, 2024
00de2f1
Update unit tests.
justinkambic Jul 11, 2024
9b1209d
Fix types.
justinkambic Jul 11, 2024
0bb07c9
Reduce reliance on `any`.
justinkambic Jul 11, 2024
e9e0612
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 11, 2024
053340f
Merge `main` and fix issues with excess request volume.
justinkambic Aug 26, 2024
32905dc
Fix types.
justinkambic Aug 26, 2024
865a3d8
Simplify.
justinkambic Aug 28, 2024
799b0d3
Merge branch 'main' into ON-WEEK-2024-06
justinkambic Aug 28, 2024
3f36547
Clean up.
justinkambic Aug 28, 2024
ffbca47
Add unit tests to cover batching cycle.
justinkambic Aug 28, 2024
86146db
Add `msearch` helper to Synthetics ES client.
justinkambic Aug 29, 2024
9aa1c0c
Move trend types to common for re-use on server.
justinkambic Aug 29, 2024
a27f99c
Clean up.
justinkambic Aug 29, 2024
6f976f0
Delete unneeded filters from query.
justinkambic Aug 29, 2024
c66e95e
Merge branch 'main' into ON-WEEK-2024-06
justinkambic Aug 29, 2024
60bc9ed
Prefer `<MetricItemExtra />`.
justinkambic Aug 29, 2024
89e5995
Merge branch 'main' into ON-WEEK-2024-06
justinkambic Aug 30, 2024
7d9fc73
Clean up and fix types.
justinkambic Aug 30, 2024
9a16f16
Fix new tests for larger chunk size.
justinkambic Aug 30, 2024
f4e1811
Merge branch 'main' into ON-WEEK-2024-06
justinkambic Aug 30, 2024
51e5160
Simplify.
justinkambic Aug 30, 2024
80f8f88
Simplify.
justinkambic Aug 30, 2024
d5c836d
Prefer histogram over top_hits for building duration chart.
justinkambic Sep 3, 2024
dea9c2e
Remove overly-complex tests.
justinkambic Sep 3, 2024
e4ebfe3
Merge branch 'main' into ON-WEEK-2024-06
justinkambic Sep 3, 2024
57b031f
Rename a function.
justinkambic Sep 3, 2024
bb31242
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Sep 3, 2024
9043613
Merge branch 'main' into ON-WEEK-2024-06
shahzad31 Sep 4, 2024
d20fab4
update types
shahzad31 Sep 4, 2024
8613f37
just one more type
shahzad31 Sep 4, 2024
20551af
Make overview footer only display when user scrolls to end of list.
justinkambic Sep 4, 2024
a9c0336
Merge branch 'ON-WEEK-2024-06' of github.com:justinkambic/kibana into…
justinkambic Sep 4, 2024
d33c9f3
Merge branch 'main' into ON-WEEK-2024-06
justinkambic Sep 4, 2024
5b3b506
Only render footer when we want it to show.
justinkambic Sep 4, 2024
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: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1201,11 +1201,13 @@
"react-use": "^15.3.8",
"react-virtualized": "^9.22.5",
"react-window": "^1.8.10",
"react-window-infinite-loader": "^1.0.9",
"reduce-reducers": "^1.0.4",
"redux": "^4.2.1",
"redux-actions": "^2.6.5",
"redux-devtools-extension": "^2.13.8",
"redux-saga": "^1.1.3",
"redux-saga-testing": "^2.0.2",
"redux-thunk": "^2.4.2",
"redux-thunks": "^1.0.0",
"reflect-metadata": "^0.2.1",
Expand Down Expand Up @@ -1597,6 +1599,7 @@
"@types/react-test-renderer": "^17.0.2",
"@types/react-virtualized": "^9.21.22",
"@types/react-window": "^1.8.8",
"@types/react-window-infinite-loader": "^1.0.9",
"@types/redux-actions": "^2.6.1",
"@types/resolve": "^1.20.1",
"@types/seedrandom": ">=2.0.0 <4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum SYNTHETICS_API_URLS {
SYNTHETICS_OVERVIEW = '/internal/synthetics/overview',
PINGS = '/internal/synthetics/pings',
PING_STATUSES = '/internal/synthetics/ping_statuses',
OVERVIEW_TRENDS = '/internal/synthetics/overview_trends',
OVERVIEW_STATUS = `/internal/synthetics/overview_status`,
INDEX_SIZE = `/internal/synthetics/index_size`,
AGENT_POLICIES = `/internal/synthetics/agent_policies`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ export const MonitorOverviewItemCodec = t.intersection([
schedule: t.string,
}),
t.partial({
status: t.string,
projectId: t.string,
}),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
export * from './synthetics_monitor';
export * from './monitor_validation';
export * from './default_alerts';
export * from './overview';
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.
*/

export interface TrendKey {
configId: string;
locationId: string;
}

export type TrendRequest = TrendKey & { schedule: string };

export interface TrendDatum {
x: number;
y: number;
}

export interface OverviewTrend {
configId: string;
locationId: string;
data: TrendDatum[];
count: number;
min: number;
max: number;
avg: number;
sum: number;
median: number;
}

export type TrendTable = Record<string, OverviewTrend | null>;
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import { useKey } from 'react-use';
import { OverviewLoader } from '../overview_loader';
import { useFilteredGroupMonitors } from './use_filtered_group_monitors';
import { MonitorOverviewItem } from '../../types';
import { FlyoutParamProps, OverviewGridItem } from '../overview_grid_item';
import { selectOverviewStatus } from '../../../../../state/overview_status';
import { MetricItem } from '../metric_item';
import { FlyoutParamProps } from '../types';

const PER_ROW = 4;
const DEFAULT_ROW_SIZE = 2;
Expand Down Expand Up @@ -163,7 +164,7 @@ export const GroupGridItem = ({
key={`${monitor.id}-${monitor.location?.id}`}
data-test-subj="syntheticsOverviewGridItem"
>
<OverviewGridItem monitor={monitor} onClick={setFlyoutConfigCallback} />
<MetricItem monitor={monitor} onClick={setFlyoutConfigCallback} />
</EuiFlexItem>
))}
</EuiFlexGrid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
import { useFilters } from '../../../common/monitor_filters/use_filters';
import { GroupGridItem } from './grid_group_item';
import { ConfigKey, MonitorOverviewItem } from '../../../../../../../../common/runtime_types';
import { FlyoutParamProps } from '../overview_grid_item';
import { selectOverviewState, selectServiceLocationsState } from '../../../../../state';
import { FlyoutParamProps } from '../types';

export const GridItemsByGroup = ({
loaded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
*/
import { i18n } from '@kbn/i18n';
import React, { useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
import { Chart, Settings, Metric, MetricTrendShape } from '@elastic/charts';
import { EuiPanel } from '@elastic/eui';
import { EuiPanel, EuiSpacer } from '@elastic/eui';
import { DARK_THEME } from '@elastic/charts';
import { useTheme } from '@kbn/observability-shared-plugin/public';
import { useDispatch, useSelector } from 'react-redux';
import moment from 'moment';
import { useSelector, useDispatch } from 'react-redux';

import { MetricItemBody } from './metric_item/metric_item_body';
import { MetricItemExtra } from './metric_item/metric_item_extra';
import { selectErrorPopoverState, toggleErrorPopoverOpen } from '../../../../state';
import {
selectErrorPopoverState,
selectOverviewTrends,
toggleErrorPopoverOpen,
} from '../../../../state';
import { useLocationName, useStatusByLocationOverview } from '../../../../hooks';
import { formatDuration } from '../../../../utils/formatting';
import { MonitorOverviewItem } from '../../../../../../../common/runtime_types';
Expand All @@ -26,6 +31,9 @@ import {
toggleTestNowFlyoutAction,
} from '../../../../state/manual_test_runs';
import { MetricItemIcon } from './metric_item_icon';
import { MetricItemExtra } from './metric_item/metric_item_extra';

const METRIC_ITEM_HEIGHT = 160;

export const getColor = (
theme: ReturnType<typeof useTheme>,
Expand All @@ -49,20 +57,14 @@ export const getColor = (

export const MetricItem = ({
monitor,
stats,
data,
onClick,
style,
}: {
monitor: MonitorOverviewItem;
data: Array<{ x: number; y: number }>;
stats: {
medianDuration: number;
avgDuration: number;
minDuration: number;
maxDuration: number;
};
style?: React.CSSProperties;
onClick: (params: { id: string; configId: string; location: string; locationId: string }) => void;
}) => {
const trendData = useSelector(selectOverviewTrends)[monitor.configId + monitor.location.id];
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const isErrorPopoverOpen = useSelector(selectErrorPopoverState);
const locationName = useLocationName(monitor);
Expand All @@ -77,7 +79,10 @@ export const MetricItem = ({
const dispatch = useDispatch();

return (
<div data-test-subj={`${monitor.name}-metric-item`} style={{ height: '160px' }}>
<div
data-test-subj={`${monitor.name}-${monitor.location.id}-metric-item`}
style={style ?? { height: METRIC_ITEM_HEIGHT }}
>
<EuiPanel
data-test-subj={`${monitor.name}-metric-item-${locationName}-${status}`}
paddingSize="none"
Expand Down Expand Up @@ -136,10 +141,26 @@ export const MetricItem = ({
{
title: monitor.name,
subtitle: locationName,
value: stats.medianDuration,
value: trendData?.median ?? 0,
trendShape: MetricTrendShape.Area,
trend: data,
extra: <MetricItemExtra stats={stats} />,
trend: trendData?.data ?? [],
extra: trendData ? (
justinkambic marked this conversation as resolved.
Show resolved Hide resolved
<MetricItemExtra
stats={{
medianDuration: trendData.median,
minDuration: trendData.min,
maxDuration: trendData.max,
avgDuration: trendData.avg,
}}
/>
) : (
<div>
<FormattedMessage
defaultMessage="Loading metrics"
id="xpack.synthetics.overview.metricItem.loadingMessage"
/>
</div>
),
valueFormatter: (d: number) => formatDuration(d),
color: getColor(theme, monitor.isEnabled, status),
body: <MetricItemBody monitor={monitor} />,
Expand Down Expand Up @@ -167,6 +188,7 @@ export const MetricItem = ({
/>
)}
</EuiPanel>
<EuiSpacer size="s" />
</div>
);
};
Loading