-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Custom threshold rule] Use lens chart with annotations in alert details page #175513
Merged
benakansara
merged 21 commits into
elastic:main
from
benakansara:feat/use-lens-chart-for-alert-details
Feb 2, 2024
Merged
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2913a41
reuse lens chart, add annotations
benakansara c50a95c
Merge branch 'main' into feat/use-lens-chart-for-alert-details
benakansara 5dbc95c
resize actions menu
benakansara 54385bc
fix filter query issue, error loading alert details page
benakansara 7a596ad
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine ac70b09
Merge branch 'main' into feat/use-lens-chart-for-alert-details
benakansara a8dd3f9
fix tests, fix bug
benakansara edc8a8f
Merge branch 'main' into feat/use-lens-chart-for-alert-details
benakansara 2ef2081
refactoring
benakansara f24c421
Merge branch 'main' into feat/use-lens-chart-for-alert-details
benakansara f99f5fb
make timerange non-optional
benakansara fd364fa
change xy_annotation_layer to xy_by_value_annotation_layer
benakansara 1bf452a
Merge branch 'main' into feat/use-lens-chart-for-alert-details
benakansara c31fc97
Merge branch 'main' into feat/use-lens-chart-for-alert-details
benakansara a6fb1a7
PR feedback
benakansara 68b92cb
fix annotation issue, refactoring
benakansara 51eadcc
refactoring
benakansara 2de9e0e
typo
benakansara b1d8c91
fix tests
benakansara fa3df0d
pr feedback
benakansara 71753ca
Merge branch 'main' into feat/use-lens-chart-for-alert-details
benakansara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 9 additions & 23 deletions
32
...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
File renamed without changes.
File renamed without changes.
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
attribute_builder
will be deprecated in the future in favor of theconfig_builder
created recently by the visualizations team.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crespocarlos thanks for the heads up. I will create a separate issue to replace
attribute_builder
usage withconfig_builder
in observability plugin.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created #176146
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @benakansara !