diff --git a/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js b/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js index 86398a57c3a45..69f7635a66032 100644 --- a/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js +++ b/x-pack/plugins/ml/public/application/components/annotations/annotations_table/annotations_table.js @@ -256,7 +256,7 @@ export class AnnotationsTable extends Component { // if the annotation is at the series level // then pass the partitioning field(s) and detector index to the Single Metric Viewer if (_.has(annotation, 'detector_index')) { - mlTimeSeriesExplorer.detector_index = annotation.detector_index; + mlTimeSeriesExplorer.detectorIndex = annotation.detector_index; } if (_.has(annotation, 'partition_field_value')) { entityCondition[annotation.partition_field_name] = annotation.partition_field_value; @@ -523,10 +523,26 @@ export class AnnotationsTable extends Component { const aggregations = this.props.aggregations ?? this.state.aggregations; if (aggregations) { const buckets = aggregations.event.buckets; - const foundUser = buckets.findIndex((d) => d.key === ANNOTATION_EVENT_USER) > -1; - filterOptions = foundUser - ? buckets - : [{ key: ANNOTATION_EVENT_USER, doc_count: 0 }, ...buckets]; + let foundUser = false; + let foundDelayedData = false; + + buckets.forEach((bucket) => { + if (bucket.key === ANNOTATION_EVENT_USER) { + foundUser = true; + } + if (bucket.key === ANNOTATION_EVENT_DELAYED_DATA) { + foundDelayedData = true; + } + }); + const adjustedBuckets = []; + if (!foundUser) { + adjustedBuckets.push({ key: ANNOTATION_EVENT_USER, doc_count: 0 }); + } + if (!foundDelayedData) { + adjustedBuckets.push({ key: ANNOTATION_EVENT_DELAYED_DATA, doc_count: 0 }); + } + + filterOptions = [...adjustedBuckets, ...buckets]; } const filters = [ {