kibana icon indicating copy to clipboard operation
kibana copied to clipboard

[Infra] Add endpoints to manage Custom Dashboards

Open mykolaharmash opened this issue 1 year ago • 8 comments
trafficstars

Closes https://github.com/elastic/kibana/issues/176069

Summary

This adds the logic to register a new Saved Object type to store custom dashboards for Asset Details and adds endpoints to fetch and save custom dashboards.

Changes highlights:

  • Renamed the enableInfrastructureHostsCustomDashboards to enableInfrastructureAssetCustomDashboards to make it more generic and support additional asset types in the future
  • Added a new Saved Object type
  • Moved initialization of all Infra endpoints to plugin's start. This one one of the points on the BE tech debt ticket. Having endpoint initialization in start makes it more convenient to access start dependencies which almost all endpoints require.
  • Added savedObjectClient and uiSettingsClient to the custom request context (also one of the ideas for endpoints improvement). Right now infra endpoints use custom libs object with all dependencies required for routes, the idea is to rely on the request context instead because it automatically available for every route handler and by default includes some useful things like scoped service clients.
  • Added a wrapper handleRouteErrors to avoid error handling duplication which we now have in a few routes. In the future we could do something similar right within registerRoutes framework function, but this would require a bit of refactoring.

Hot to Test

  1. Toggle the UI setting off in Advanced Settings CleanShot 2024-02-13 at 16 01 36@2x
  2. Go to the Dev Tools and try the endpoints, both should respond with 403
GET kbn:api/infra/custom-dashboards/host

POST kbn:api/infra/custom-dashboards
{
  "assetType": "host",
  "dashboardSavedObjectIdList": ["0", "1"]
}
  1. Toggle the UI setting on
  2. Try the endpoints again, now they should work as expected

mykolaharmash avatar Feb 09 '24 16:02 mykolaharmash

/ci

mykolaharmash avatar Feb 09 '24 16:02 mykolaharmash

:robot: GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

apmmachine avatar Feb 09 '24 16:02 apmmachine

/ci

mykolaharmash avatar Feb 13 '24 14:02 mykolaharmash

/ci

mykolaharmash avatar Feb 13 '24 15:02 mykolaharmash

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

elasticmachine avatar Feb 13 '24 15:02 elasticmachine

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

elasticmachine avatar Feb 13 '24 15:02 elasticmachine

@elasticmachine merge upstream

mykolaharmash avatar Feb 15 '24 13:02 mykolaharmash

@elasticmachine merge upstream

mykolaharmash avatar Feb 19 '24 10:02 mykolaharmash

I get bad request for the second query, with both enabled and disabled setting:

image

Sorry @maryam-saeidi, the field name was updated in the process of code review but I forgot to update the description, the new field name is dashboardIdList instead of dashboardSavedObjectIdList

The description is now up to day.

mykolaharmash avatar Feb 19 '24 14:02 mykolaharmash

@elasticmachine merge upstream

mykolaharmash avatar Feb 21 '24 13:02 mykolaharmash

:green_heart: Build Succeeded

Metrics [docs]

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
infra 29 34 +5

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
infra 8 6 -2

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/saved-objects-service.html#_mappings

id before after diff
infra-custom-dashboards - 4 +4
Unknown metric groups

API count

id before after diff
infra 32 37 +5

History

  • :yellow_heart: Build #194119 was flaky 1acb44a165e7ce8afc5d8ec3c7ef063b666a3ef1
  • :green_heart: Build #193825 succeeded 172881d3ad167f12edc4cad09e905ee140f984f4
  • :broken_heart: Build #193760 failed b01e41aa782e4efe8f960d6c067cd2ec50d41399
  • :broken_heart: Build #193640 failed ab2de78c8d9d98c8ccf6ba340f2788ef5c8be186
  • :broken_heart: Build #193351 failed 881c5b9c66e1e7cd00b1bf6d3431f3134a4c1c57
  • :broken_heart: Build #193319 failed 517846ae6485d545a117a8d6afc9c56192b45c7f

To update your PR or re-run it, just comment with: @elasticmachine merge upstream

kibana-ci avatar Feb 21 '24 14:02 kibana-ci

💚 All backports created successfully

Status Branch Result
8.13

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine avatar Feb 22 '24 11:02 kibanamachine