Skip to content

feat(SourceMetrics): knowledge graph single kg annotations POC#1134

Draft
bohandley wants to merge 3 commits intomainfrom
bohandley/knowledge-graph-annotations-POC
Draft

feat(SourceMetrics): knowledge graph single kg annotations POC#1134
bohandley wants to merge 3 commits intomainfrom
bohandley/knowledge-graph-annotations-POC

Conversation

@bohandley
Copy link
Contributor

@bohandley bohandley commented Mar 14, 2026

✨ 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:

  1. Only in the metric graph (preferred, cleaner)
Screenshot 2026-03-14 at 1 54 44 PM
  1. In all metric scene panels (is there any benefit to seeing them in this way? time range, comparison?)
Screenshot 2026-03-14 at 1 57 18 PM

📖 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 topView
MetricScene/MetricScene.tsx -- threads kgEntityConfig through to MetricGraphScene
AppDataTrail/DataTrail.tsx -- stores kgEntityConfig in state, passes it to MetricScene on metric selection
exposedComponents/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

  1. Click Frontend entity
  2. Click the insight with ErrorRatioBreach
  3. Click "metrics"
Screenshot 2026-03-16 at 3 55 56 PM
  1. See the annotations in the Metrics Drilldown Metric Scene panel
Screenshot 2026-03-16 at 3 58 52 PM

@bohandley bohandley changed the title SourceMetrics: knowledge graph single kg annotations POC feat (SourceMetrics): knowledge graph single kg annotations POC Mar 16, 2026
@bohandley bohandley changed the title feat (SourceMetrics): knowledge graph single kg annotations POC feat(SourceMetrics): knowledge graph single kg annotations POC Mar 16, 2026
@github-actions github-actions bot added the feat label Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant