Skip to content

Commit

Permalink
[Synthetics] Summary page duration trends (#135809)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Jul 11, 2022
1 parent c3c41c9 commit 7ba2e63
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const PERCENTILE_RANKS = [
'90th' as OperationType,
'75th' as OperationType,
'50th' as OperationType,
'25th' as OperationType,
];
export const LABEL_FIELDS_FILTER = 'LABEL_FIELDS_FILTER';
export const LABEL_FIELDS_BREAKDOWN = 'LABEL_FIELDS_BREAKDOWN';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {
XYState,
FormulaPublicApi,
YAxisMode,
MinIndexPatternColumn,
MaxIndexPatternColumn,
} from '@kbn/lens-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/common';
import { PersistableFilter } from '@kbn/lens-plugin/common';
Expand All @@ -51,6 +53,7 @@ import {
MetricOption,
ParamFilter,
SeriesConfig,
SupportedOperations,
UrlFilter,
URLReportDefinition,
} from '../types';
Expand Down Expand Up @@ -287,20 +290,18 @@ export class LensAttributes {
sourceField: string;
columnType?: string;
columnFilter?: ColumnFilter;
operationType?: string;
operationType?: SupportedOperations | 'last_value';
label?: string;
seriesConfig: SeriesConfig;
}) {
if (columnType === 'operation' || operationType) {
if (
operationType === 'median' ||
operationType === 'average' ||
operationType === 'sum' ||
operationType === 'unique_count'
operationType &&
['median', 'average', 'sum', 'min', 'max', 'unique_count'].includes(operationType)
) {
return this.getNumberOperationColumn({
sourceField,
operationType,
operationType: operationType as SupportedOperations,
label,
seriesConfig,
columnFilter,
Expand Down Expand Up @@ -361,11 +362,13 @@ export class LensAttributes {
columnFilter,
}: {
sourceField: string;
operationType: 'average' | 'median' | 'sum' | 'unique_count';
operationType: SupportedOperations;
label?: string;
seriesConfig: SeriesConfig;
columnFilter?: ColumnFilter;
}):
| MinIndexPatternColumn
| MaxIndexPatternColumn
| AvgIndexPatternColumn
| MedianIndexPatternColumn
| SumIndexPatternColumn
Expand Down Expand Up @@ -398,7 +401,7 @@ export class LensAttributes {
lensColumns[`y-axis-column-${i}`] = {
...this.getColumnBasedOnType({
sourceField: mainSourceField!,
operationType: PERCENTILE_RANKS[i],
operationType: PERCENTILE_RANKS[i] as SupportedOperations,
label: mainLabel,
layerConfig,
layerId,
Expand Down Expand Up @@ -499,7 +502,7 @@ export class LensAttributes {
layerId,
}: {
sourceField: string;
operationType?: OperationType;
operationType?: SupportedOperations;
label?: string;
layerId: string;
layerConfig: LayerConfig;
Expand Down Expand Up @@ -637,7 +640,9 @@ export class LensAttributes {
label,
layerConfig,
colIndex: 0,
operationType: breakdown === PERCENTILE ? PERCENTILE_RANKS[0] : operationType,
operationType: (breakdown === PERCENTILE
? PERCENTILE_RANKS[0]
: operationType) as SupportedOperations,
layerId,
});
}
Expand Down Expand Up @@ -677,7 +682,7 @@ export class LensAttributes {

lensColumns[`y-axis-column-${i}`] = this.getColumnBasedOnType({
sourceField: sourceField!,
operationType,
operationType: operationType as SupportedOperations,
label,
layerConfig,
colIndex: i,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ export function OperationTypeComponent({
onChange: (value: OperationType) => void;
}) {
const options = [
{
value: 'min' as OperationType,
inputDisplay: i18n.translate('xpack.observability.expView.operationType.min', {
defaultMessage: 'Min',
}),
},
{
value: 'max' as OperationType,
inputDisplay: i18n.translate('xpack.observability.expView.operationType.max', {
defaultMessage: 'Max',
}),
},
{
value: 'average' as OperationType,
inputDisplay: i18n.translate('xpack.observability.expView.operationType.average', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,5 @@ export interface BuilderItem {
series: SeriesUrl;
seriesConfig?: SeriesConfig;
}

export type SupportedOperations = 'average' | 'median' | 'sum' | 'unique_count' | 'min' | 'max';
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const MonitorSummaryTitle = () => {
const { monitorId } = useParams<{ monitorId: string }>();

useEffect(() => {
dispatch(getMonitorStatusAction.get({ monitorId, dateStart: 'now-15m', dateEnd: 'now' }));
dispatch(getMonitorStatusAction.get({ monitorId, dateStart: 'now-30d', dateEnd: 'now' }));
}, [dispatch, monitorId]);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.
*/

import React from 'react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { useParams } from 'react-router-dom';
import { ClientPluginsStart } from '../../../../../plugin';

export const MonitorDurationTrend = () => {
const { observability } = useKibana<ClientPluginsStart>().services;

const { ExploratoryViewEmbeddable } = observability;

const { monitorId } = useParams<{ monitorId: string }>();

const metricsToShow = ['min', 'max', 'median', '25th', '75th'];

return (
<ExploratoryViewEmbeddable
customHeight={'300px'}
reportType="kpi-over-time"
attributes={metricsToShow.map((metric) => ({
dataType: 'synthetics',
time: {
from: 'now-30d/d',
to: 'now',
},
name: metric + ' Series',
selectedMetricField: 'monitor.duration.us',
reportDefinitions: {
'monitor.id': [monitorId],
},
seriesType: 'line',
operationType: metric,
}))}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
*/

import React from 'react';
import { EuiTitle, EuiPanel, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui';
import { EuiTitle, EuiPanel, EuiFlexGroup, EuiFlexItem, EuiText, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { MonitorDurationTrend } from './duration_trend';
import { StepDurationPanel } from './step_duration_panel';
import { MonitorDetailsPanel } from './monitor_details_panel';

Expand All @@ -25,7 +26,25 @@ export const SummaryTabContent = () => {
</EuiPanel>
</EuiFlexItem>
<EuiFlexItem grow={2}>
<EuiPanel />
<EuiFlexGroup>
<EuiFlexItem>
<EuiPanel>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}>
<EuiTitle size="s">
<h3>{DURATION_TREND_LABEL}</h3>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
<EuiText color="subdued" size="s">
{LAST_30_DAYS_LABEL}
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
<MonitorDurationTrend />
</EuiPanel>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="s" />
Expand All @@ -46,3 +65,11 @@ export const SummaryTabContent = () => {
const MONITOR_DETAILS_LABEL = i18n.translate('xpack.synthetics.detailsPanel.monitorDetails', {
defaultMessage: 'Monitor details',
});

const DURATION_TREND_LABEL = i18n.translate('xpack.synthetics.detailsPanel.durationTrends', {
defaultMessage: 'Duration trends',
});

const LAST_30_DAYS_LABEL = i18n.translate('xpack.synthetics.detailsPanel.last30Days', {
defaultMessage: 'Last 30 days',
});

0 comments on commit 7ba2e63

Please sign in to comment.