Skip to content

[SLO] Add dashboard references to SLO saved object#232583

Merged
cesco-f merged 15 commits intoelastic:mainfrom
cesco-f:slo-dashboards-server
Aug 28, 2025
Merged

[SLO] Add dashboard references to SLO saved object#232583
cesco-f merged 15 commits intoelastic:mainfrom
cesco-f:slo-dashboards-server

Conversation

@cesco-f
Copy link
Contributor

@cesco-f cesco-f commented Aug 22, 2025

First part for closing issue #228509.

This update handles only the server-side implementation. The solution follows a similar approach to the one used for attaching dashboards to rules.

Screen.Recording.2025-08-22.at.10.13.50.mov

@cesco-f cesco-f added release_note:enhancement backport:skip This PR does not require backporting labels Aug 22, 2025
@github-actions github-actions bot added the author:obs-ux-management PRs authored by the obs ux management team label Aug 22, 2025
@cesco-f cesco-f force-pushed the slo-dashboards-server branch from d8681c2 to c83a8e7 Compare August 22, 2025 08:31
@cesco-f cesco-f marked this pull request as ready for review August 22, 2025 09:16
@cesco-f cesco-f requested a review from a team as a code owner August 22, 2025 09:16
@botelastic botelastic bot added the Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. label Aug 22, 2025
@elasticmachine
Copy link
Contributor

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

@cesco-f cesco-f force-pushed the slo-dashboards-server branch from 340e840 to 9842d78 Compare August 22, 2025 09:33
@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner August 22, 2025 10:50
… src/core/server/integration_tests/ci_checks'
Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Good job, overall this looks good to me.

I have some basic questions for my own understanding of the need for refId (cf comments)

Another question I have is about the usage: Are we going to display the dashboard name when linking to the dashboard, and if so, are we planning to fetch the name ad-hoc or fetch it when we read the references? Or is there a dashboard "locator" that takes care of rendering the name based on the provided id?

Right now we are storing the dashboard id as part of the SLO Definition, do we think it can be useful to store it as part of the SLO Summary as well? I don't know yet, and this would require a bit of changes so let's maybe delay this decision to later. Just wanted to write my thought down.

One thing I would like to test is the upgrade path (should be fine since everything is optional): creating an SLO on main, and then running this branch and trying to read/edit this SLO. Could you confirm everything is fine on this side? Thanks!

const references: SavedObjectReference[] = [];
if (slo.artifacts?.dashboards?.length) {
slo.artifacts.dashboards.forEach(({ id }, index) => {
const refId = `dashboard-${index}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we using index because we want to allow the same dashboard (id) to be referenced multiple time?

Copy link
Contributor Author

@cesco-f cesco-f Aug 25, 2025

Choose a reason for hiding this comment

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

I think it doesn't really matter what we store in the refId as long as it's unique and it's the same as the name property we store in the reference.

Copy link
Contributor

Choose a reason for hiding this comment

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

Exactly point is that refId should be unique and same as the name property in the reference.

return {
storedSLO: storedSloDefinitionSchema.encode({
...slo,
artifacts: { dashboards: dashboardsRef },
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we considered storing the dashboard id directly instead of the refId? I understand we introduce this refId to handle the case where the same dashboard is added many times but should it be a valid use case? Is there other reason for this custom refId?

Also, how will we search across all SLOs for a given dashboard id (use case: find all SLO related to this dashboard)? Is there an API on the saved object service that we can leverage to search all references of a given type (slo) at once? Or do we need to iterate over each SLO? If we store the dashboard id directly, we should be able to search them directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to replicate the approach we’re using to store references for rules, as described in the Kibana developer documentation.

According to the documentation:

Note how dashboard.panels[0].visualization stores the name property of the reference (not the id directly) to be able to uniquely identify this reference. This guarantees that the id the reference points to always remains up to date. If a visualization id was directly stored in dashboard.panels[0].visualization there is a risk that this id gets updated without updating the reference in the references array.

To find SLOs related to a given dashboard, I think we can leverage this property of the find method in the saved objects client:
Screenshot 2025-08-25 at 08 50 34

await transformHelper.assertExist(getSLOSummaryTransformId(sloId, 2));
});

it('updates dashboard artifacts and returns them', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

🍰 nit: can you create two sub describe (one for with revision bump and one without). This test belongs in the without revision bump. I want to make sure we document (by test) the behaviour of updating a dashboard artifacts:

  • only save the definition with the dashboard
  • no revision bump (maybe assert for this)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this what you had in mind?
d757b3c

return response.saved_objects
.map((slo) => this.toSLO(slo))
.filter((slo) => slo !== undefined) as SLODefinition[];
return response.saved_objects.map((so) => this.toSLO(so)).filter(this.isSLO);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻 thanks for the type guard filter

properties: {
dashboards: {
properties: {
refId: { type: 'keyword' },
Copy link
Contributor

Choose a reason for hiding this comment

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

If we were using the dashboard id, we could find every SLO with a specific dashboard id. I guess that's possible with the references also, can you confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can leverage the hasReference property of the find method in the saved objects client.

@cesco-f
Copy link
Contributor Author

cesco-f commented Aug 25, 2025

Another question I have is about the usage: Are we going to display the dashboard name when linking to the dashboard, and if so, are we planning to fetch the name ad-hoc or fetch it when we read the references? Or is there a dashboard "locator" that takes care of rendering the name based on the provided id?

We can discuss this further in the PR for the frontend part, but my idea was to reuse the component we already use to link dashboards to rules. Then, we could create a custom hook that leverages the content management client to fetch the dashboard name based on its ID. I’m not completely sure whether this logic should live in the backend, but I’d suggest handling it in the next PR, when we’ll need to display the dashboard name in the SLO details view.

Right now we are storing the dashboard id as part of the SLO Definition, do we think it can be useful to store it as part of the SLO Summary as well? I don't know yet, and this would require a bit of changes so let's maybe delay this decision to later. Just wanted to write my thought down.

I’m not sure what the SLO Summary is or how we’re using it in Kibana. Is there any documentation I can read to learn more about it?

One thing I would like to test is the upgrade path (should be fine since everything is optional): creating an SLO on main, and then running this branch and trying to read/edit this SLO. Could you confirm everything is fine on this side? Thanks!

I tested this path and I didn't find any issues, all good 👍

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

LGTM. To give us more freedom, I'd remove the mappings addition for now.

@elasticmachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #109 / OneChat Endpoints Builtin Tools internal API POST /internal/chat/tools/_bulk_delete should handle mixed bulk delete with builtin and custom tools
  • [job] [logs] FTR Configs #109 / OneChat Endpoints Builtin Tools internal API POST /internal/chat/tools/_bulk_delete should handle mixed bulk delete with builtin and custom tools

History

@cesco-f cesco-f requested a review from rudolf August 27, 2025 05:15
@cesco-f cesco-f requested a review from a team August 27, 2025 07:30
@mgiota mgiota self-requested a review August 28, 2025 07:34
Copy link
Contributor

@mgiota mgiota left a comment

Choose a reason for hiding this comment

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

Excellent job! Great implementation replicating the approach we’re using to store references for rules!

@cesco-f cesco-f merged commit a0f70df into elastic:main Aug 28, 2025
12 checks passed
@cesco-f cesco-f deleted the slo-dashboards-server branch August 28, 2025 08:18
cesco-f added a commit that referenced this pull request Sep 2, 2025
This PR is a follow-up of #232583
and it closes #228509.

Dashboards can be linked to SLOs.



https://github.com/user-attachments/assets/a9593926-ad01-4c40-be1b-27b44eef81ae

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
ymao1 pushed a commit to ymao1/kibana that referenced this pull request Sep 2, 2025
This PR is a follow-up of elastic#232583
and it closes elastic#228509.

Dashboards can be linked to SLOs.



https://github.com/user-attachments/assets/a9593926-ad01-4c40-be1b-27b44eef81ae

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
MichelLosier pushed a commit to MichelLosier/kibana that referenced this pull request Sep 2, 2025
This PR is a follow-up of elastic#232583
and it closes elastic#228509.

Dashboards can be linked to SLOs.



https://github.com/user-attachments/assets/a9593926-ad01-4c40-be1b-27b44eef81ae

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
qn895 pushed a commit to qn895/kibana that referenced this pull request Sep 2, 2025
First part for closing issue
elastic#228509.

This update handles only the server-side implementation. The solution
follows a similar approach to the one used for attaching dashboards to
rules.


https://github.com/user-attachments/assets/329af612-f84b-426e-99e0-11f82d565079

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
kowalczyk-krzysztof pushed a commit to kowalczyk-krzysztof/kibana that referenced this pull request Sep 3, 2025
This PR is a follow-up of elastic#232583
and it closes elastic#228509.

Dashboards can be linked to SLOs.



https://github.com/user-attachments/assets/a9593926-ad01-4c40-be1b-27b44eef81ae

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
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.

7 participants