Merge pull request #5613 from influxdata/5561/alert_rule

fix(alert rule): warn about unsupported data
pull/5622/head
Pavel Závora 2020-12-02 12:00:57 +01:00 committed by GitHub
commit be6b9e9216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View File

@ -64,6 +64,17 @@ class RuleGraphDygraph extends Component<Props, State> {
if (!timeSeriesToDygraphResult) { if (!timeSeriesToDygraphResult) {
return null return null
} }
if (timeSeriesToDygraphResult.unsupportedValue) {
console.error(
'Unsupported y-axis value, cannot display data',
timeSeriesToDygraphResult
)
return (
<p className="unexpected-error">
Unsupported y-axis value, only numbers are supported.
</p>
)
}
return ( return (
<Dygraph <Dygraph

View File

@ -253,10 +253,10 @@ class FieldList extends PureComponent<Props, State> {
const newFields = _.get(fieldSets, measurement, []).map(f => ({ const newFields = _.get(fieldSets, measurement, []).map(f => ({
value: f, value: f,
type: 'field', type: 'field',
})) })) as Field[]
this.setState({ this.setState({
fields: newFields, fields: _.uniqBy(newFields, 'value'), // do not duplicate items
}) })
}) })
} }

View File

@ -11,6 +11,7 @@ export interface TimeSeriesToDyGraphReturnType {
labels: string[] labels: string[]
timeSeries: DygraphValue[][] timeSeries: DygraphValue[][]
dygraphSeries: DygraphSeries dygraphSeries: DygraphSeries
unsupportedValue?: any
} }
export const timeSeriesToDygraph = async ( export const timeSeriesToDygraph = async (
@ -19,12 +20,18 @@ export const timeSeriesToDygraph = async (
): Promise<TimeSeriesToDyGraphReturnType> => { ): Promise<TimeSeriesToDyGraphReturnType> => {
const result = await manager.timeSeriesToDygraph(raw, pathname) const result = await manager.timeSeriesToDygraph(raw, pathname)
const {timeSeries} = result const {timeSeries} = result
let unsupportedValue: any
const newTimeSeries = fastMap<DygraphValue[], DygraphValue[]>( const newTimeSeries = fastMap<DygraphValue[], DygraphValue[]>(
timeSeries, timeSeries,
([time, ...values]) => [new Date(time), ...values] ([time, ...values]) => {
if (unsupportedValue === undefined) {
unsupportedValue = values.find(x => x !== null && typeof x !== 'number')
}
return [new Date(time), ...values]
}
) )
return {...result, timeSeries: newTimeSeries} return {...result, timeSeries: newTimeSeries, unsupportedValue}
} }
export const timeSeriesToTableGraph = async ( export const timeSeriesToTableGraph = async (