feat(SourceMetrics): knowledge graph single kg annotations POC#1134
Draft
feat(SourceMetrics): knowledge graph single kg annotations POC#1134
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
✨ Description
Related issue(s):
#1037
Companion PR in knowledge graph plugin here https://github.com/grafana/asserts-app-plugin/pull/2949
POC to add single annotations (not multilane which is still being tested) to SoureMetrics component which is consumed by the RCA workbench in the knowledge graph.
We can show the annotations one of two ways:
📖 Summary of the changes
The asserts app passes entity context as primitives (kgDatasourceUid, entityType, entityName, entityScope) to the SourceMetrics exposed component. SourceMetrics builds a KgEntityConfig (plain object) and passes it into newMetricsTrail(). From there it flows down the constructor chain:
DataTrail → MetricScene → MetricGraphScene
MetricGraphScene calls buildKgAnnotationsLayer(kgEntityConfig) in its constructor, producing a fresh SceneDataLayerSet containing an AnnotationsDataLayer. This is set as $data on topView -- the SceneFlexLayout holding only the main chart. When the panel's SceneQueryRunner activates, Grafana Scenes traverses ancestors via sceneGraph.getDataLayers(), finds the layer, and runs it. The layer queries the KG datasource at /api-server/v1/search/assertions and the results render as annotation bands.
Breakdown panels can be unaffected because they live under MetricGraphScene.selectedTab, a separate subtree that doesn't pass through topView.
Files changed
MetricScene/kgAnnotations.ts-- new file containing KgEntityConfig, KgEntityScope types and buildKgAnnotationsLayer()MetricScene/MetricGraphScene.tsx-- accepts kgEntityConfig, builds and sets the annotation layer as $data on topViewMetricScene/MetricScene.tsx-- threads kgEntityConfig through to MetricGraphSceneAppDataTrail/DataTrail.tsx-- stores kgEntityConfig in state, passes it to MetricScene on metric selectionexposedComponents/SourceMetrics/SourceMetrics.tsx-- accepts entity props, builds KgEntityConfig, passes to trail🧪 How to test?
Run the asserts app with the changes here
Confirm that the annotations work in the source metrics component used in the RCA workbench
FrontendentityErrorRatioBreach