forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Custom threshold rule] Use lens chart with annotations in alert deta…
…ils page (elastic#175513) Resolves elastic#174075, elastic#155691 - Using same chart in alert details page as in rule flyout for preview - Group by info is applied as filter on chart data - Added annotations - For active alerts, added point annotation with alert start time and range annotation with range from alert start time till current time - For recovered alerts, added range annotation for alert duration ### Active alert <img width="1257" alt="Screenshot 2024-01-26 at 15 05 26" src="https://github.com/elastic/kibana/assets/69037875/d548b529-7811-4e3e-996d-aa4d259327b9"> <img width="1265" alt="Screenshot 2024-01-26 at 15 09 44" src="https://github.com/elastic/kibana/assets/69037875/a01d0cdf-5254-484d-91b3-c45a846790a9"> ### Recovered alert <img width="1250" alt="Screenshot 2024-01-26 at 14 53 08" src="https://github.com/elastic/kibana/assets/69037875/521a69a2-6a4a-4b9e-a886-3477c92d63ac"> --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
Showing
17 changed files
with
276 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...ddable-utils/attribute_builder/visualization_types/layers/xy_by_value_annotation_layer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { SavedObjectReference } from '@kbn/core/server'; | ||
import type { DataView } from '@kbn/data-views-plugin/common'; | ||
import { EventAnnotationConfig } from '@kbn/event-annotation-common'; | ||
import type { FormBasedPersistedState, PersistedIndexPatternLayer } from '@kbn/lens-plugin/public'; | ||
import type { XYByValueAnnotationLayerConfig } from '@kbn/lens-plugin/public/visualizations/xy/types'; | ||
import type { ChartLayer } from '../../types'; | ||
import { getDefaultReferences } from '../../utils'; | ||
import { XY_ANNOTATIONS_ID } from '../constants'; | ||
|
||
export interface XYByValueAnnotationsLayerConfig { | ||
annotations: EventAnnotationConfig[]; | ||
layerType?: typeof XY_ANNOTATIONS_ID; | ||
/** | ||
* It is possible to define a specific dataView for the layer. It will override the global chart one | ||
**/ | ||
dataView?: DataView; | ||
ignoreGlobalFilters?: boolean; | ||
} | ||
|
||
export class XYByValueAnnotationsLayer implements ChartLayer<XYByValueAnnotationLayerConfig> { | ||
private layerConfig: XYByValueAnnotationsLayerConfig; | ||
|
||
constructor(layerConfig: XYByValueAnnotationsLayerConfig) { | ||
this.layerConfig = { | ||
...layerConfig, | ||
layerType: layerConfig.layerType ?? 'annotations', | ||
}; | ||
} | ||
|
||
getName(): string | undefined { | ||
return this.layerConfig.annotations[0].label; | ||
} | ||
|
||
getLayer(layerId: string): FormBasedPersistedState['layers'] { | ||
const baseLayer = { columnOrder: [], columns: {} } as PersistedIndexPatternLayer; | ||
return { | ||
[`${layerId}_annotation`]: baseLayer, | ||
}; | ||
} | ||
|
||
getReference(layerId: string, chartDataView: DataView): SavedObjectReference[] { | ||
return getDefaultReferences(this.layerConfig.dataView ?? chartDataView, `${layerId}_reference`); | ||
} | ||
|
||
getLayerConfig(layerId: string): XYByValueAnnotationLayerConfig { | ||
return { | ||
layerId: `${layerId}_annotation`, | ||
layerType: 'annotations', | ||
annotations: this.layerConfig.annotations, | ||
ignoreGlobalFilters: this.layerConfig.ignoreGlobalFilters || false, | ||
indexPatternId: this.layerConfig.dataView?.id || '', | ||
}; | ||
} | ||
|
||
getDataView(): DataView | undefined { | ||
return this.layerConfig.dataView; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 29 additions & 22 deletions
51
...omponents/alert_details_app_section/__snapshots__/alert_details_app_section.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.