Skip to content

Conversation

axelavargas
Copy link
Member

What is this feature?

This fixes the issue where alert icons were not displayed in library panels when alert rules were configured for them.

When an alert rule is created for a panel, it stores the dashboard.uid and the panel.id. When loading a library panel, the LibraryPanelBehavior retrieves the library panel model and replaces the current panel state in the dashboard. However, the library panel was using its original panel ID instead of the dashboard panel ID, causing a mismatch in the data layer filtering.

The fix ensures that library panels use the dashboard panel ID (extracted from the VizPanel key) for data provider filtering, allowing alert states to be properly matched and displayed.

Before

BeforeFixAlert.mp4

After

AfterFix.mp4

Which issue(s) does this PR fix?:

Fixes #107494

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@axelavargas axelavargas self-assigned this Jul 7, 2025
@axelavargas axelavargas requested a review from a team as a code owner July 7, 2025 16:11
@axelavargas axelavargas requested review from bfmatei, kaydelaney and mdvictor and removed request for a team, bfmatei and kaydelaney July 7, 2025 16:11
@github-actions github-actions bot added this to the 12.1.x milestone Jul 7, 2025
@axelavargas axelavargas requested review from a team, evictorero, nmarrs, CollinFingar and juanicabanas and removed request for a team July 7, 2025 16:12
@@ -50,6 +51,10 @@ export class LibraryPanelBehavior extends SceneObjectBase<LibraryPanelBehaviorSt

const libPanelModel = new PanelModel(libPanel.model);

// Use dashboard panel ID for data layer filtering
// const dashboardPanelId = getPanelIdForVizPanel(vizPanel);
// libPanelModel.id = dashboardPanelId;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these lines be commented out?

Copy link
Member Author

Choose a reason for hiding this comment

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

Lol, I was testing something locally and ended up commenting out these lines, good catch!

@axelavargas axelavargas requested a review from nmarrs July 8, 2025 08:13
@axelavargas axelavargas changed the title Dashboard: Fix alert icon not showing in library panels Dashboard: Add Alert icon in library panels Jul 8, 2025
@axelavargas axelavargas changed the title Dashboard: Add Alert icon in library panels Dashboard: Add Alert icon in library panels Jul 8, 2025
Copy link
Contributor

@evictorero evictorero left a comment

Choose a reason for hiding this comment

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

LGTM!

@axelavargas axelavargas merged commit 2e3c2df into main Jul 8, 2025
89 checks passed
@axelavargas axelavargas deleted the axelav/fix-library-panel-not-showing-alerts branch July 8, 2025 13:08
YannickAlex07 pushed a commit to YannickAlex07/grafana that referenced this pull request Jul 11, 2025
* Use panel.id from the dashboard to filter alterts properly

* add unit test

* Fix linting

* add fix back

* fix betterer in test, use same pattern as DashboardDatasourceBehaviour
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.

Alert heart icon not displayed on dashboard when alert is configured on library panel
3 participants