Skip to content

Support exporting dashboards using the saved objects API #1357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 22, 2025

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Jul 14, 2023

Old deprecated API is removed in 9.0. Start using the saved objects API from this version.

@jsoriano jsoriano requested a review from a team July 14, 2023 15:26
@jsoriano jsoriano self-assigned this Jul 14, 2023
logger.Debug("Export dashboards using the Kibana Saved Objects Export API")

exportRequest := exportSavedObjectsRequest{
ExcludeExportDetails: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be needed to set IncludeReferencesDeep to true, to get other references used in the dashboards like tags, searches, maps... ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure, trying to add it.

Comment on lines 38 to 42
if sv.LessThan(semver.MustParse("8.8.0")) {
return c.exportWithDashboardsAPI(dashboardIDs)
}

return c.exportWithSavedObjectsAPI(dashboardIDs)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @jsoriano

dashboards = append(dashboards, dashboard)
}

return dashboards, nil
Copy link
Member Author

Choose a reason for hiding this comment

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

To reuse the code introduced in #1565 if finally merged.

@jsoriano jsoriano marked this pull request as ready for review May 21, 2025 14:40
Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

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

Tested these changes in some packages, and it looks that it works as expected.

Just one note when trying to export a dashboard from aws package (using Elastic stack 9.0.0).

Tested to export [Metrics AWS] ALB Overview (ID: aws-24f3e07a-b5f5-470c-8305-47c9626db37b) dashboard and there was change that I didn't expect:

@@ -1937,10 +1977,8 @@
         "version": 2
     },
     "coreMigrationVersion": "8.8.0",
-    "created_at": "2024-07-23T10:27:18.232Z",
+    "created_at": "2025-05-21T15:28:04.486Z",
     "id": "aws-24f3e07a-b5f5-470c-8305-47c9626db37b",
-    "managed": false,
-    "aws": false,
     "references": [
         {
             "id": "metrics-*"

At least that aws field. I don't know what that it mean. Tested with two other AWS dashboards and that change is not present, that field was not present.

  • [Metrics AWS] EC2 Overview (ID: aws-c5846400-f7fb-11e8-af03-c999c9dea608)
  • [Logs AWS] S3 Server Access Log Overview (ID: aws-4746e000-bacd-11e9-9f70-1f7bda85a5eb)

@jsoriano
Copy link
Member Author

At least that aws field. I don't know what that it mean. Tested with two other AWS dashboards and that change is not present, that field was not present.

No idea where this aws field comes from 🤔 It is committed in the repository, the four appearances that we have come from this PR: https://github.com/elastic/integrations/pull/10444/files#diff-72a671ea70c6cb60a9f9e9fa1c4e125ab30da611219246f9f32d274c914a0426R1300

@anil-elastic do you happen to remember how you exported these dashboards?

I think we can ignore this, if this field is not being exported it is likely being ignored by Kibana.

@mrodm
Copy link
Contributor

mrodm commented May 22, 2025

At least that aws field. I don't know what that it mean. Tested with two other AWS dashboards and that change is not present, that field was not present.

No idea where this aws field comes from 🤔 It is committed in the repository, the four appearances that we have come from this PR: https://github.com/elastic/integrations/pull/10444/files#diff-72a671ea70c6cb60a9f9e9fa1c4e125ab30da611219246f9f32d274c914a0426R1300

@anil-elastic do you happen to remember how you exported these dashboards?

I think we can ignore this, if this field is not being exported it is likely being ignored by Kibana.

Just tried with elastic-package v0.111.0 with stack 8.18.1, and that aws field is removed too.
But I detected another difference, in this PR managed field is removed. At least with the example I tested:

elastic-package stack up -v -d --version 8.18.1
cd /path/to/repo/integrations/packages/aws
elastic-package install -v
elsatic-package export dashboards --id aws-24f3e07a-b5f5-470c-8305-47c9626db37b

As the stack is 8.18.1 version, they both should be using the same API and it is shown in the debug output (there is an extra &, but it is working):

2025/05/22 09:47:36 DEBUG GET https://127.0.0.1:5601/api/kibana/dashboards/export?dashboard=aws-24f3e07a-b5f5-470c-8305-47c9626db37b&

There are other differences in the diff, I just show here the ones related to managed

  • Running with v0.111.0:
@@ -1937,10 +1977,9 @@
         "version": 2
     },
     "coreMigrationVersion": "8.8.0",
-    "created_at": "2024-07-23T10:27:18.232Z",
+    "created_at": "2025-05-22T07:38:34.414Z",
     "id": "aws-24f3e07a-b5f5-470c-8305-47c9626db37b",
-    "managed": false,
-    "aws": false,
+    "managed": true,
     "references": [
         {
             "id": "metrics-*",
  • Running this PR:
@@ -1937,10 +1977,8 @@
         "version": 2
     },
     "coreMigrationVersion": "8.8.0",
-    "created_at": "2024-07-23T10:27:18.232Z",
+    "created_at": "2025-05-22T07:38:34.414Z",
     "id": "aws-24f3e07a-b5f5-470c-8305-47c9626db37b",
-    "managed": false,
-    "aws": false,
     "references": [
         {
             "id": "metrics-*",

I cannot tell why that managed field is removed when using the changes in this PR when stack used is 8.18.1. It looks like that it is not changed how dashboards are exported before 9.0.0.

@jsoriano
Copy link
Member Author

But I detected another difference, in this PR managed field is removed.

This field is explicitly removed by elastic-package, and managed by Fleet on installation.

Maybe this dashboard was exported without elastic-package, or with an older version.

@mrodm
Copy link
Contributor

mrodm commented May 22, 2025

This field is explicitly removed by elastic-package, and managed by Fleet on installation.

Ah! Got it. I missed that PR, thanks!

Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

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

👍

@jsoriano jsoriano merged commit a62cb9f into elastic:main May 22, 2025
3 checks passed
@jsoriano jsoriano deleted the export-dashboards-saved-objects-api branch May 22, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants