Skip to content

Conversation

@cesco-f
Copy link
Contributor

@cesco-f cesco-f commented Jul 21, 2025

This PR closes #212125

Acceptance criteria

  • Visualizations included in a dashboard "by reference" can be evaluated and used as criteria for returning the dashboard via our related dashboards API (currently, only "by value" dashboards are searched)
    This evaluation of by reference visualizations should happen in the same related dashboards API request (not a separate one) ✅

@cesco-f cesco-f requested review from a team as code owners July 21, 2025 14:55
@cesco-f cesco-f added release_note:enhancement backport:skip This PR does not require backporting v9.2.0 labels Jul 21, 2025
@botelastic botelastic bot added the Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. label Jul 21, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@github-actions github-actions bot added the author:obs-ux-management PRs authored by the obs ux management team label Jul 21, 2025
@cesco-f cesco-f changed the title [Incident Management] When fetching dashboards referenced panel are also fetched [Incident Management] When fetching dashboards referenced panels are also fetched Jul 21, 2025
@cesco-f cesco-f force-pushed the panel-references branch from b797833 to 9f47052 Compare July 21, 2025 15:31
@cesco-f cesco-f force-pushed the panel-references branch from 73b4582 to e4ba2e7 Compare July 25, 2025 13:59
@cesco-f cesco-f requested review from ThomThomson and nickpeihl July 28, 2025 08:21
Copy link
Contributor

@dominiqueclarke dominiqueclarke left a comment

Choose a reason for hiding this comment

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

I'd ideally like to fetch each panel reference only once.

Currently, if two or more dashboards share the same reference, the reference is fetched multiple times. Tested by saving a relevant lens visualization to the library, and then adding it to multiple dashboards.

Also, I noticed that relevant panels are not considered when added to a dashboard via the "Copy to Dashboard" control. When adding a relevant panel to a different dashboard using the control, the dashboard I copied over to was surfaced as a suggested dashboard
Screenshot 2025-07-28 at 10 14 12 PM

@cesco-f cesco-f requested a review from dominiqueclarke July 29, 2025 08:56
Copy link
Member

@nickpeihl nickpeihl left a comment

Choose a reason for hiding this comment

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

presentation team changes lgtm

code review only

@cesco-f cesco-f removed the request for review from ThomThomson August 4, 2025 09:01
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #56 / InfraOps App Metrics UI Home page with metrics present sort nodes by ascending value

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dashboard 689 690 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/observability-schema 10 8 -2
dashboard 92 94 +2
total -0
Unknown metric groups

API count

id before after diff
@kbn/observability-schema 10 8 -2
dashboard 96 98 +2
total -0

History


import type { DashboardAttributes, DashboardPanel } from '../server/content_management';

export const isDashboardPanel = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Is isDashboardPanel needed? Why not just use existing isDashboardSection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TypeScript doesn’t automatically infer that if a value is not a DashboardSection, then it must be a DashboardPanel. To avoid manual type casting, I created a second type guard function.

// So, if the same saved object panel is referenced in two different dashboards, it will have different panelIndex values in each dashboard, but the same panelId, since they're both referencing the same panel.
private panelsById = new Map<string, ReferencedPanelAttributesWithReferences>();
private panelIndexToId = new Map<string, string>();
private panelsTypeById = new Map<string, string>();
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks great, but I'm just confused a bit again by the variable names. Maybe panelsToFetchById. Maybe not the best. I just don't understand what 'type' means here semantically.

Copy link
Contributor Author

@cesco-f cesco-f Aug 7, 2025

Choose a reason for hiding this comment

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

The key of the map stores the panel ID and the value stores the panel type, I'll need both to fetch the panels.
That's why I called this map panelsTypeById, it follows the valueBykey pattern and reflects what’s stored.

What is you find confusing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. I haven't looked at this domain in a while so I've been getting confused about what each individual piece is and how they all work together

After stepping through the code some more, I see the type is essentially the saved object type. Thank you very much for explaining.

@dominiqueclarke dominiqueclarke self-requested a review August 7, 2025 12:52
Copy link
Contributor

@dominiqueclarke dominiqueclarke left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the work.

@cesco-f cesco-f merged commit a14f553 into elastic:main Aug 8, 2025
12 checks passed
@cesco-f cesco-f deleted the panel-references branch August 8, 2025 08:37
NicholasPeretti pushed a commit to NicholasPeretti/kibana that referenced this pull request Aug 18, 2025
qn895 pushed a commit to qn895/kibana that referenced this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:obs-ux-management PRs authored by the obs ux management team backport:skip This PR does not require backporting release_note:enhancement Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Incident Management] [Alert details] [Related dashboards] handle panel references from the visualization library

6 participants