-
Notifications
You must be signed in to change notification settings - Fork 127
Allow to export dashboards from Serverless environments #3007
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
base: main
Are you sure you want to change the base?
Conversation
Use this command to download selected dashboards and other associated saved objects from Kibana. This command adjusts the downloaded saved objects according to package naming conventions (prefixes, unique IDs) and writes them locally into folders corresponding to saved object types (dashboard, visualization, map, etc.).` | ||
|
||
newDashboardOption = "New dashboard" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title for the option to be selected in order to show all the dashboards from the Serverless instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option is shown the first one in the list.
Example:
$ elastic-package -C ../integrations-main/packages/nginx export dashboards
Export Kibana dashboards
Which packages would you like to export dashboards from? (nginx-2.3.2)
> New dashboard
elastic_package_registry-0.3.1
fleet_server-1.6.0
nginx-2.3.2
synthetics-1.4.2
func promptDashboardIDs(ctx context.Context, kibanaClient *kibana.Client) ([]string, error) { | ||
savedDashboards, err := kibanaClient.FindDashboards(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kibana.FindDashboards
has been updated in order to show all dashboards also in Serverless via the export
API.
if installedPackage == newDashboardOption { | ||
dashboardIDs, err := promptDashboardIDs(cmd.Context(), kibanaClient) | ||
if err != nil { | ||
return nil, fmt.Errorf("prompt for dashboard selection failed: %w", err) | ||
} | ||
return dashboardIDs, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used here the same method as in local instances to show all dashboards in the selector.
This function uses kibana.FindDashboards()
that has been updated in order to show all dashboards also in Serverless via the export
API.
// These fields are not expected to be part of responses from APIs | ||
DataStream string `json:"-"` | ||
SourcePath string `json:"-"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find any usage of these two fields in APIs.
It looks like that they are used in test asset
and they are filled programmatically.
elastic-package/internal/packages/assets.go
Line 139 in fc03bdf
DataStream: dsManifest.Name, |
elastic-package/internal/packages/assets.go
Line 171 in fc03bdf
DataStream: dsManifest.Name, |
elastic-package/internal/packages/assets.go
Line 207 in fc03bdf
SourcePath: assetPath, |
If the json:"-"
tag is not added to the fields, queries with this struct fail with the error of those fields being not available/undefined.
func (c *Client) exportAllDashboards(ctx context.Context) ([]common.MapStr, error) { | ||
logger.Debug("Export dashboards using the Kibana Saved Objects Export API") | ||
|
||
request := ExportSavedObjectsRequest{ | ||
ExcludeExportDetails: true, | ||
IncludeReferencesDeep: false, | ||
Type: "dashboard", | ||
} | ||
|
||
return c.ExportSavedObjects(ctx, request) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method would return all the dashboards available in the Kibana Instance.
According to the documentation, the number of assets that will be exported depend on savedObjects.maxImportExportSize
setting (link):
NOTE: The savedObjects.maxImportExportSize configuration setting limits the number of saved objects which may be exported.
By default that setting is 10000 elements (savedObjects.maxImportExportSize setting):
The maximum count of saved objects that can be imported or exported. This setting exists to prevent the Kibana server from running out of memory when handling large numbers of saved objects. It is recommended to only raise this setting if you are confident your server can hold this many objects in memory. Default: 10000
💔 Build Failed
Failed CI Steps
History
cc @mrodm |
Closes #2949
This PR allows to export dashboards in Serverless environments.
For Serverless environments, a new set of APIs from Elastic Package Manager have been used:
Author's checklist
elastic-package export dashboards
in Serverlesselastic-package export dashboards
in local stackselastic-package edit dashboards
in Serverlesselastic-package edit dashboards
in local stacksBoth commands require the same changes to list dashboards.
Example of usage
First step all installed packages are shown:
If the user selects a package, it will be shown all the dashboards related to that package (e.g. nginx):
If the user is developing a new dashboard (and therefore not related to any package), they should choose
New dashboard
option, and all the dashboards available in the Serverless instance will be shown: