File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed
x-pack/plugins/infra/public
alerting/metric_threshold/components
components/alerting/inventory Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -265,8 +265,8 @@ export const ExpressionChart: React.FC<Props> = ({
265265 < EuiText size = "xs" color = "subdued" >
266266 < FormattedMessage
267267 id = "xpack.infra.metrics.alerts.dataTimeRangeLabel"
268- defaultMessage = "Last 20 {timeLabel}"
269- values = { { timeLabel } }
268+ defaultMessage = "Last {lookback} {timeLabel}"
269+ values = { { timeLabel, lookback : timeSize * 20 } }
270270 />
271271 </ EuiText >
272272 ) }
Original file line number Diff line number Diff line change 55 */
66
77import { i18n } from '@kbn/i18n' ;
8+ import { isNumber } from 'lodash' ;
89import {
910 MetricExpressionParams ,
1011 Comparator ,
@@ -63,6 +64,21 @@ export function validateMetricThreshold({
6364 ) ;
6465 }
6566
67+ // The Threshold component returns an empty array with a length ([empty]) because it's using delete newThreshold[i].
68+ // We need to use [...c.threshold] to convert it to an array with an undefined value ([undefined]) so we can test each element.
69+ if ( c . threshold && c . threshold . length && ! [ ...c . threshold ] . every ( isNumber ) ) {
70+ [ ...c . threshold ] . forEach ( ( v , i ) => {
71+ if ( ! isNumber ( v ) ) {
72+ const key = i === 0 ? 'threshold0' : 'threshold1' ;
73+ errors [ id ] [ key ] . push (
74+ i18n . translate ( 'xpack.infra.metrics.alertFlyout.error.thresholdTypeRequired' , {
75+ defaultMessage : 'Thresholds must contain a valid number.' ,
76+ } )
77+ ) ;
78+ }
79+ } ) ;
80+ }
81+
6682 if ( c . comparator === Comparator . BETWEEN && ( ! c . threshold || c . threshold . length < 2 ) ) {
6783 errors [ id ] . threshold1 . push (
6884 i18n . translate ( 'xpack.infra.metrics.alertFlyout.error.thresholdRequired' , {
Original file line number Diff line number Diff line change 66
77import { i18n } from '@kbn/i18n' ;
88// eslint-disable-next-line @kbn/eslint/no-restricted-paths
9+ import { isNumber } from 'lodash' ;
10+ // eslint-disable-next-line @kbn/eslint/no-restricted-paths
911import { MetricExpressionParams } from '../../../../server/lib/alerting/metric_threshold/types' ;
1012// eslint-disable-next-line @kbn/eslint/no-restricted-paths
1113import { ValidationResult } from '../../../../../triggers_actions_ui/public/types' ;
@@ -51,6 +53,21 @@ export function validateMetricThreshold({
5153 ) ;
5254 }
5355
56+ // The Threshold component returns an empty array with a length ([empty]) because it's using delete newThreshold[i].
57+ // We need to use [...c.threshold] to convert it to an array with an undefined value ([undefined]) so we can test each element.
58+ if ( c . threshold && c . threshold . length && ! [ ...c . threshold ] . every ( isNumber ) ) {
59+ [ ...c . threshold ] . forEach ( ( v , i ) => {
60+ if ( ! isNumber ( v ) ) {
61+ const key = i === 0 ? 'threshold0' : 'threshold1' ;
62+ errors [ id ] [ key ] . push (
63+ i18n . translate ( 'xpack.infra.metrics.alertFlyout.error.thresholdTypeRequired' , {
64+ defaultMessage : 'Thresholds must contain a valid number.' ,
65+ } )
66+ ) ;
67+ }
68+ } ) ;
69+ }
70+
5471 if ( c . comparator === 'between' && ( ! c . threshold || c . threshold . length < 2 ) ) {
5572 errors [ id ] . threshold1 . push (
5673 i18n . translate ( 'xpack.infra.metrics.alertFlyout.error.thresholdRequired' , {
You can’t perform that action at this time.
0 commit comments