Skip to content

feat: surface Knowledge Graph insights and service linking on checks - #1736

Open
VikaCep wants to merge 14 commits into
mainfrom
feat/knowledge-graph-integration
Open

feat: surface Knowledge Graph insights and service linking on checks#1736
VikaCep wants to merge 14 commits into
mainfrom
feat/knowledge-graph-integration

Conversation

@VikaCep

@VikaCep VikaCep commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Part of #1615

Problem

Synthetic Monitoring checks are disconnected from the rest of a user's observability stack. When a check is failing or slow, there is no path inside the product from the check to the service it monitors, that service's dependencies, or its current health. Users have to jump between Synthetic Monitoring and other tools (Application Observability, Kubernetes Monitoring, alerts) to understand why. There is also no way, from within Synthetic Monitoring, to tell the Knowledge Graph which service a check is actually monitoring.

Solution

This PR adds the Synthetic Monitoring side of the Knowledge Graph (KG) integration, in three places:

1. Knowledge Graph insights on the check dashboard. The check page embeds the KG assertions widget (the health rings), scoped to the check's SyntheticCheck entity and the current time range. Users get error, latency and health insights for the check inline, without leaving Synthetic Monitoring.

image

2. Linking a check to a Knowledge Graph service. The Labels section of the check form gains optional service name and namespace fields. Suggestions are fetched live from the Knowledge Graph, and the values are stored as the service_name and namespace labels on the check. This is what lets the Knowledge Graph draw the MONITORED_BY relationship between the service and the check. A live indicator shows whether the selected pair matches a known Service entity. When these labels are declared as cost attribution labels, both surfaces edit the same values and stay in sync.

image

3. Connected services graph on the check dashboard. A "Connected services" section renders the check's Knowledge Graph neighbourhood as an inline graph: the service the check monitors, plus that service's immediate callers and dependencies. Nodes carry the KG insight rings, so an unhealthy neighbour surfaces as a root cause hint right on the check page. Hovering a node shows its insights with a link to the entity in the Knowledge Graph. The data comes from a Cypher query against the KG datasource that walks MONITORED_BY to the linked check and one hop of CALLS in both directions. The section is expanded by default. When the check is not linked to a service yet, it shows a zero state whose button links straight to the Labels section of the edit form. An "Open in Knowledge Graph" link opens the full entity graph.

image image

Feature flag and rollout

All three surfaces render only when both of these are true:

  • the Knowledge Graph app (grafana-asserts-app) is installed on the stack, and
  • the synthetic-monitoring-knowledge-graph feature flag is enabled.

The flag exists because the Knowledge Graph app has a large installed base that predates this integration. SyntheticCheck entities only start appearing once the entity discovery rules land in the KG platform (the asserts-adi side of this project), so without a flag those stacks would see empty sections. With the flag, this PR is safe to merge as soon as it is approved: everything stays dormant until we enable the flag per stack, and the flag also works as a kill switch if anything misbehaves.

Review guide

The diff is large, but more than half of it has already been reviewed:

  • Connected services graph (ConnectedServices.*, ConnectedServicesGraph.tsx, useKGDS.ts and the KG test fixtures, about 1,600 lines): reviewed and approved separately in feat: add Connected services graph to the check dashboard #1774, then merged into this branch unchanged.
  • Service link in the check form (KnowledgeGraphServiceLink.*, KnowledgeGraphValueCombobox.tsx, knowledgeGraphApi.ts and the changes to the label form components, about 1,100 lines, roughly half of it tests): this is the main part to review.
  • Insights widget (KnowledgeGraphInsights.tsx plus two lines in each scene dashboard): small.
  • Feature flag (knowledgeGraph.hooks.ts, types.ts): the shared gate described above.

Design doc

This is the Synthetic Monitoring side of the Design Doc: Synthetic Monitoring × Knowledge Graph Integration (v2), covering work units 2.5, 2.6 and 2.7. The doc is approved.

Additional context

This PR pairs with the KG platform changes in asserts-adi (the SyntheticCheck entity type, the entity discovery rules and the MONITORED_BY relationship) and the asserts-app-plugin changes that add the entity Metrics tab and the link back to Synthetic Monitoring (#3461). Until those rules are deployed and SyntheticCheck entities exist in the graph, everything in this PR stays dormant behind the feature flag.

@VikaCep VikaCep self-assigned this Jun 19, 2026
@github-actions github-actions Bot added the feature A feature added to the application. label Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

Script size changes

Name +/- Main This PR Outcome
[702.js] = 6,689.61 kB 6,689.61 kB
[87.js] +3.04% 3,588.58 kB 3,697.52 kB
[469.js] = 506.85 kB 506.85 kB
[datasource/module.js] +0.06% 119.00 kB 119.08 kB
[9.js] = 99.10 kB 99.10 kB
[692.js] +0.11% 67.50 kB 67.57 kB
[398.js] = 48.57 kB 48.57 kB
[module.js] = 35.04 kB 35.04 kB
[294.js] = 22.06 kB 22.06 kB
[466.js] = 5.15 kB 5.15 kB
[131.js] = 5.00 kB 5.00 kB
[845.js] = 3.25 kB 3.25 kB
[295.js] = 2.79 kB 2.79 kB

Totals

Name +/- Main This PR Outcome
[Scripts] +0.97% 11,192.49 kB 11,301.58 kB
[Non-script Assets] = 1,469.61 kB 1,469.61 kB
[All] +0.86% 12,662.10 kB 12,771.19 kB

Generated by 🚫 dangerJS against 111eb63

@VikaCep VikaCep mentioned this pull request Jun 19, 2026
4 tasks
@VikaCep
VikaCep force-pushed the feat/knowledge-graph-integration branch from d15d3c0 to 63acbf1 Compare June 26, 2026 18:13
@VikaCep
VikaCep force-pushed the feat/knowledge-graph-integration branch from 63acbf1 to 2426fb6 Compare July 8, 2026 18:35
VikaCep added 9 commits July 29, 2026 17:10
Signed-off-by: Virginia Cepeda <virginia.cepeda@grafana.com>
Replace the on/off switch with a collapsible "Add service link" section.
service_name/namespace are resolved through a single CAL-aware hook, so the
KG section and the cost attribution label rows edit the same values and stay
in sync. CAL rows for those labels upgrade to a combobox with KG service
suggestions, and a live indicator shows whether the pair matches a known
Service entity.
…s query

The KG relation was flipped from SyntheticCheck -MONITORS-> Service to
Service -MONITORED_BY-> SyntheticCheck so alertBackPropagate carries a
failing check's insight onto the monitored service. Updates the Cypher
neighbourhood query, its test, and the form help text to match.
…fields

Show the service name and namespace rows directly instead of behind a
"+ Service link" button, and drop the remove action — each value is cleared
through its own combobox, with no validation on either field.
Hide service_name/namespace from the custom labels when the Knowledge Graph
app is installed (they previously showed twice), and redirect anyone typing
either key back to the service link section.
@VikaCep
VikaCep force-pushed the feat/knowledge-graph-integration branch from 8c3fa5f to eabe41a Compare July 29, 2026 20:22
VikaCep and others added 2 commits July 31, 2026 17:45
* feat: replace scenes nodegraph with custom KG-style Connected services graph

Renders the check's neighbourhood with a bespoke SVG renderer matching the
Knowledge Graph's entity graph design: layered layout, insight rings, SM logo
on check nodes, insights popup on node hover with a KG deep link, curved
sibling edges, and edge hover highlighting with connection tooltips. Data
comes straight from the Cypher query via react-query instead of scenes.

* fix: make connected services be expanded by default

* fix: refetch the connected services graph on the standard dashboard interval

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
@VikaCep

VikaCep commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

bugbot review

Comment thread src/features/knowledgeGraph/KnowledgeGraphInsights.tsx
@VikaCep

VikaCep commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b641708. Configure here.

Comment thread src/features/knowledgeGraph/KnowledgeGraphServiceLink.tsx Outdated
uid: 'grafanacloud-knowledgegraph',
type: 'grafana-knowledgegraph-datasource',
name: 'Knowledge Graph',
} as DataSourceInstanceSettings;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial datasource test cast

Low Severity

KG_DATASOURCE is a partial object asserted with as DataSourceInstanceSettings, which violates the project rule to use typed fixture factories instead of casts in tests. Existing datasource fixtures in src/test/fixtures/datasources.ts already follow the full typed-literal pattern.

Fix in Cursor Fix in Web

Triggered by learned rule: Use typed factory functions for test fixtures instead of as any / as unknown as Type casts

Reviewed by Cursor Bugbot for commit b641708. Configure here.

@VikaCep
VikaCep marked this pull request as ready for review August 3, 2026 18:51
@VikaCep
VikaCep requested a review from a team as a code owner August 3, 2026 18:51
@VikaCep
VikaCep requested review from ckbedwell and g3john August 3, 2026 18:51

@ckbedwell ckbedwell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few questions and nits -- the main one is looking at the syncing of the dashboard time range with the KG query.

Comment thread src/features/knowledgeGraph/ConnectedServices.constants.ts Outdated
Comment thread src/features/knowledgeGraph/ConnectedServices.hooks.ts Outdated
Comment thread src/features/knowledgeGraph/ConnectedServices.hooks.ts Outdated
Comment thread src/features/knowledgeGraph/ConnectedServices.tsx Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we recreating the graph view here? Do they not expose their own component?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I asked about this but unfortunately this is not available as an exposed component. Perhaps we can move this out as a shared utility between consumers as Russ mentioned in the conversation.

@VikaCep
VikaCep requested a review from ckbedwell August 5, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A feature added to the application.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants