Skip to content

Commit 56a7c58

Browse files
[Uptime] Improve duration chart (#58404) (#59548)
* use differential colors for duration chart * remove duration chart gql * update type * type fix * fix tyoe * update translation * update test * update conflicts * type checking * update snaps * PR feedback * PR feedback Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent bb8c4d6 commit 56a7c58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+824
-4963
lines changed

x-pack/legacy/plugins/uptime/common/graphql/introspection.json

Lines changed: 0 additions & 4032 deletions
This file was deleted.

x-pack/legacy/plugins/uptime/common/graphql/types.ts

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// Scalars
99
// ====================================================
1010

11+
1112
export type UnsignedInteger = any;
1213

1314
// ====================================================
@@ -18,14 +19,6 @@ export interface Query {
1819
/** Get a list of all recorded pings for all monitors */
1920
allPings: PingResults;
2021

21-
getMonitors?: LatestMonitorsResult | null;
22-
23-
getSnapshot?: Snapshot | null;
24-
25-
getMonitorChartsData?: MonitorChart | null;
26-
/** Fetch the most recent event data for a monitor ID, date range, location. */
27-
getLatestMonitors: Ping[];
28-
2922
/** Fetches the current state of Uptime monitors for the given parameters. */
3023
getMonitorStates?: MonitorSummaryResult | null;
3124
/** Fetches details about the uptime index. */
@@ -376,32 +369,6 @@ export interface DocCount {
376369
count: UnsignedInteger;
377370
}
378371

379-
export interface LatestMonitorsResult {
380-
monitors?: LatestMonitor[] | null;
381-
}
382-
/** Represents the latest recorded information about a monitor. */
383-
export interface LatestMonitor {
384-
/** The ID of the monitor represented by this data. */
385-
id: MonitorKey;
386-
/** Information from the latest document. */
387-
ping?: Ping | null;
388-
/** Buckets of recent up count status data. */
389-
upSeries?: MonitorSeriesPoint[] | null;
390-
/** Buckets of recent down count status data. */
391-
downSeries?: MonitorSeriesPoint[] | null;
392-
}
393-
394-
export interface MonitorKey {
395-
key: string;
396-
397-
url?: string | null;
398-
}
399-
400-
export interface MonitorSeriesPoint {
401-
x?: UnsignedInteger | null;
402-
403-
y?: number | null;
404-
}
405372

406373
export interface Snapshot {
407374
counts: SnapshotCount;
@@ -416,42 +383,6 @@ export interface SnapshotCount {
416383
}
417384

418385

419-
/** The data used to populate the monitor charts. */
420-
export interface MonitorChart {
421-
/** The average values for the monitor duration. */
422-
locationDurationLines: LocationDurationLine[];
423-
/** The counts of up/down checks for the monitor. */
424-
status: StatusData[];
425-
/** The maximum status doc count in this chart. */
426-
statusMaxCount: number;
427-
/** The maximum duration value in this chart. */
428-
durationMaxValue: number;
429-
}
430-
431-
export interface LocationDurationLine {
432-
name: string;
433-
434-
line: MonitorDurationAveragePoint[];
435-
}
436-
/** Represents the average monitor duration ms at a point in time. */
437-
export interface MonitorDurationAveragePoint {
438-
/** The timeseries value for this point. */
439-
x: UnsignedInteger;
440-
/** The average duration ms for the monitor. */
441-
y?: number | null;
442-
}
443-
/** Represents a bucket of monitor status information. */
444-
export interface StatusData {
445-
/** The timeseries point for this status data. */
446-
x: UnsignedInteger;
447-
/** The value of up counts for this point. */
448-
up?: number | null;
449-
/** The value for down counts for this point. */
450-
down?: number | null;
451-
/** The total down counts for this point. */
452-
total?: number | null;
453-
}
454-
455386
/** The primary object returned for monitor states. */
456387
export interface MonitorSummaryResult {
457388
/** Used to go to the next page of results */
@@ -619,16 +550,6 @@ export interface AllPingsQueryArgs {
619550
location?: string | null;
620551
}
621552

622-
export interface GetMonitorChartsDataQueryArgs {
623-
monitorId: string;
624-
625-
dateRangeStart: string;
626-
627-
dateRangeEnd: string;
628-
629-
location?: string | null;
630-
}
631-
632553
export interface GetMonitorStatesQueryArgs {
633554
dateRangeStart: string;
634555

x-pack/legacy/plugins/uptime/common/types/index.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,42 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
/** Represents a bucket of monitor status information. */
8+
export interface StatusData {
9+
/** The timeseries point for this status data. */
10+
x: number;
11+
/** The value of up counts for this point. */
12+
up?: number | null;
13+
/** The value for down counts for this point. */
14+
down?: number | null;
15+
/** The total down counts for this point. */
16+
total?: number | null;
17+
}
18+
19+
/** Represents the average monitor duration ms at a point in time. */
20+
export interface MonitorDurationAveragePoint {
21+
/** The timeseries value for this point. */
22+
x: number;
23+
/** The average duration ms for the monitor. */
24+
y?: number | null;
25+
}
26+
27+
export interface LocationDurationLine {
28+
name: string;
29+
30+
line: MonitorDurationAveragePoint[];
31+
}
32+
33+
/** The data used to populate the monitor charts. */
34+
export interface MonitorDurationResult {
35+
/** The average values for the monitor duration. */
36+
locationDurationLines: LocationDurationLine[];
37+
/** The counts of up/down checks for the monitor. */
38+
status: StatusData[];
39+
/** The maximum status doc count in this chart. */
40+
statusMaxCount: number;
41+
/** The maximum duration value in this chart. */
42+
durationMaxValue: number;
43+
}
44+
745
export * from './ping/histogram';

x-pack/legacy/plugins/uptime/common/types/ping/histogram.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
export type UnsignedInteger = any;
8-
97
export interface HistogramDataPoint {
108
upCount?: number | null;
119

1210
downCount?: number | null;
1311

14-
x?: UnsignedInteger | null;
12+
x?: number | null;
1513

16-
x0?: UnsignedInteger | null;
14+
x0?: number | null;
1715

18-
y?: UnsignedInteger | null;
16+
y?: number | null;
1917
}
2018

2119
export interface GetPingHistogramParams {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import React, { useContext, useEffect } from 'react';
8+
import { useDispatch, useSelector } from 'react-redux';
9+
import { useUrlParams } from '../../../hooks';
10+
import { getMonitorDurationAction } from '../../../state/actions';
11+
import { DurationChartComponent } from '../../functional/charts';
12+
import { selectDurationLines } from '../../../state/selectors';
13+
import { UptimeRefreshContext } from '../../../contexts';
14+
15+
interface Props {
16+
monitorId: string;
17+
}
18+
19+
export const DurationChart: React.FC<Props> = ({ monitorId }: Props) => {
20+
const [getUrlParams] = useUrlParams();
21+
const { dateRangeStart, dateRangeEnd } = getUrlParams();
22+
23+
const { monitor_duration, loading } = useSelector(selectDurationLines);
24+
25+
const dispatch = useDispatch();
26+
27+
const { lastRefresh } = useContext(UptimeRefreshContext);
28+
29+
useEffect(() => {
30+
dispatch(
31+
getMonitorDurationAction({ monitorId, dateStart: dateRangeStart, dateEnd: dateRangeEnd })
32+
);
33+
}, [dateRangeStart, dateRangeEnd, dispatch, lastRefresh, monitorId]);
34+
35+
return (
36+
<DurationChartComponent
37+
locationDurationLines={monitor_duration?.locationDurationLines ?? []}
38+
loading={loading}
39+
/>
40+
);
41+
};

x-pack/legacy/plugins/uptime/public/components/connected/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export { MonitorStatusDetails } from './monitor/status_details_container';
1212
export { MonitorStatusBar } from './monitor/status_bar_container';
1313
export { MonitorListDrawer } from './monitor/list_drawer_container';
1414
export { MonitorListActionsPopover } from './monitor/drawer_popover_container';
15+
export { DurationChart } from './charts/monitor_duration';

x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/monitor_charts.test.tsx.snap

Lines changed: 1 addition & 133 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)