Skip to content
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

POC - Sharing index patterns #95958

Closed
wants to merge 4 commits into from

Conversation

jportner
Copy link
Contributor

@jportner jportner commented Mar 31, 2021

[skip-ci]

🚨 Notice 2021-08-19 🚨

This POC is out of date! See #107256 instead.


Note: see each commit message for more details

Overview

This PR is a proof-of-concept to:

  1. Convert index patterns to namespaceType 'multiple-isolated' ("share-capable" objects, planned for the 8.0 release) -- this will regenerate index pattern IDs to prepare them to be shareable; it requires that the index pattern management page uses the SavedObjectsClient's resolve API, and display some extra UI elements in case of issues with the newly introduced Legacy URL aliases
  2. Convert index patterns to namespaceType 'multiple' ("shareable" objects, planned for some 8.x release) -- this will allow index patterns to be shared between multiple spaces; it updates the index pattern management page to display a list of spaces and the "Change shared spaces" flyout

It also includes some preliminary commits to add support for the SOC resolve API in the SOC abstractions that the index_pattern_management plugin utilizes.


Not included

This PR is intended to demonstrate the steps it will take for a plugin author to convert a saved object to become share-capable and subsequently to become shareable. It does not include other changes such as:

  • Updates to unit tests
  • Updates to docs

How to test

  1. Start Kibana

  2. Using Dev Tools, load staging data

    Staging data
    POST .kibana/_bulk
    { "index": { "_id" : "index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f" } }
    {"index-pattern":{"fieldFormatMap":"{\"taxful_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}}}","fields":"[]","timeFieldName":"order_date","title":"kibana_sample_data_ecommerce"},"type":"index-pattern","references":[],"namespaces":["default", "bravo"],"migrationVersion":{"index-pattern":"8.0.0"},"coreMigrationVersion":"8.0.0","updated_at":"2021-03-30T13:30:10.244Z"}
    { "index": { "_id" : "index-pattern:b75d094a-3b91-5d44-848c-4ccbe1338cf7" } }
    {"index-pattern":{"fieldFormatMap":"{\"taxful_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}}}","fields":"[]","timeFieldName":"order_date","title":"kibana_sample_data_ecommerce"},"type":"index-pattern","references":[],"namespaces":["alpha"],"originId":"ff959d40-b880-11e8-a6d9-e546fe2bba5f","migrationVersion":{"index-pattern":"8.0.0"},"coreMigrationVersion":"8.0.0","updated_at":"2021-03-30T13:31:09.236Z"}
    { "index": { "_id" : "index-pattern:cc855cd9-7c1b-526c-89f8-eacad4e2b799" } }
    {"index-pattern":{"fieldFormatMap":"{\"taxful_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}}}","fields":"[]","timeFieldName":"order_date","title":"kibana_sample_data_ecommerce"},"type":"index-pattern","references":[],"namespaces":["bravo"],"originId":"ff959d40-b880-11e8-a6d9-e546fe2bba5f","migrationVersion":{"index-pattern":"8.0.0"},"coreMigrationVersion":"8.0.0","updated_at":"2021-03-30T13:31:09.476Z"}
    { "index": { "_id" : "index-pattern:87ffef05-4fd1-5f00-9751-fb28ce6d391c" } }
    {"index-pattern":{"fieldFormatMap":"{\"taxful_total_price\":{\"id\":\"number\",\"params\":{\"pattern\":\"$0,0.[00]\"}}}","fields":"[]","timeFieldName":"order_date","title":"kibana_sample_data_ecommerce"},"type":"index-pattern","references":[],"namespaces":["*"],"originId":"ff959d40-b880-11e8-a6d9-e546fe2bba5f","migrationVersion":{"index-pattern":"8.0.0"},"coreMigrationVersion":"8.0.0","updated_at":"2021-03-30T13:31:09.236Z"}
    { "index": { "_id" : "legacy-url-alias:alpha:index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f" } }
    {"legacy-url-alias":{"targetNamespace":"alpha","targetType":"index-pattern","targetId":"b75d094a-3b91-5d44-848c-4ccbe1338cf7"},"type":"legacy-url-alias","references":[],"migrationVersion":{},"coreMigrationVersion":"8.0.0"}
    { "index": { "_id" : "legacy-url-alias:bravo:index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f" } }
    {"legacy-url-alias":{"targetNamespace":"bravo","targetType":"index-pattern","targetId":"cc855cd9-7c1b-526c-89f8-eacad4e2b799"},"type":"legacy-url-alias","references":[],"migrationVersion":{},"coreMigrationVersion":"8.0.0"}
    { "index": { "_id" : "legacy-url-alias:charlie:index-pattern:ff959d40-b880-11e8-a6d9-e546fe2bba5f" } }
    {"legacy-url-alias":{"targetNamespace":"charlie","targetType":"index-pattern","targetId":"87ffef05-4fd1-5f00-9751-fb28ce6d391c"},"type":"legacy-url-alias","references":[],"migrationVersion":{},"coreMigrationVersion":"8.0.0"}
    { "index": { "_id" : "space:alpha" } }
    {"space":{"name":"Alpha","disabledFeatures":[]},"type":"space","references":[],"migrationVersion":{"space":"6.6.0"},"coreMigrationVersion":"8.0.0","updated_at":"2021-03-30T13:30:35.109Z"}
    { "index": { "_id" : "space:bravo" } }
    {"space":{"name":"Bravo","disabledFeatures":[]},"type":"space","references":[],"migrationVersion":{"space":"6.6.0"},"coreMigrationVersion":"8.0.0","updated_at":"2021-03-30T13:30:41.088Z"}
    { "index": { "_id" : "space:charlie" } }
    {"space":{"name":"Charlie","disabledFeatures":[]},"type":"space","references":[],"migrationVersion":{"space":"6.6.0"},"coreMigrationVersion":"8.0.0","updated_at":"2021-03-30T13:31:00.820Z"}
    
  3. Navigate to Home, then load "Sample eCommerce orders" data

  4. Navigate to Stack Management > Index Patterns to observe two index patterns that are visible in the Default space

    Index Patterns page screenshot

    image

The staging data simulates the following scenario:

  • With Kibana 7.12, the user created three new spaces: Alpha, Bravo, and Charlie
  • Then, the user added eCommerce sample data to the Default space, then copied it to the A/B/C spaces (so there are four copies of the same index pattern)
  • Then, the user has bookmarked the URLs to the index pattern in each space
  • Then, the user upgraded Kibana to 8.0+, which converted the index patterns and regenerated their IDs in the A/B/C spaces (creating new Legacy URL aliases for any object ID that was regenerated)
  • Then, the user: a. shared the index pattern from the Default space to the Bravo space, and b. shared the index pattern from the Charlie space to All spaces

Now you can load the following URLs to test how index pattern IDs are resolved:

  1. Default space: /app/management/kibana/indexPatterns/patterns/ff959d40-b880-11e8-a6d9-e546fe2bba5f#/?_a=(tab:indexedFields) -- this will result in outcome: "exactMatch", with no changes in the UI

  2. Alpha space: /s/alpha/app/management/kibana/indexPatterns/patterns/ff959d40-b880-11e8-a6d9-e546fe2bba5f#/?_a=(tab:indexedFields) -- this will result in outcome: "aliasMatch", and it will redirect the user to the new URL for the updated object ID (b75d094a-3b91-5d44-848c-4ccbe1338cf7) and display a toast message

    Toast screenshot

    image

  3. Bravo space: /s/bravo/app/management/kibana/indexPatterns/patterns/ff959d40-b880-11e8-a6d9-e546fe2bba5f#/?_a=(tab:indexedFields) -- this will result in outcome: "conflict", and it will show a callout to the user at the top of the page with an appropriate warning message

    Callout screenshot

    image

If you go back to the Index Patterns page and share an object, you can observe that the index pattern is refreshed and the "Shared spaces" column is updated accordingly.

@jportner jportner force-pushed the sharing-index-patterns branch from f20e0c0 to b2d6556 Compare March 31, 2021 18:20
@jportner jportner force-pushed the sharing-index-patterns branch 2 times, most recently from 1149978 to 9273ee1 Compare April 26, 2021 17:55
Add support for `resolve` method to the public SOC client abstraction.
This was overlooked in Sharing Saved Objects Phase 2, but it will be
added in Phase 3.
Splitting this out into a separate commit as it is a prerequisite for
converting index patterns to namespaceType 'multiple-isolated' but it
is really a separate change in a different plugin.
This will happen in the 8.0 release. It requires that index patterns are
retrieved with the `resolve` API, and that the various resolve outcomes
are handled appropriately on the client side using the appropriate
Spaces APIs.
This will happen in an 8.x release. It allows index patterns to be
shared to multiple spaces. This commit also changes the index pattern UI
to add a spaces list column and a share to space action.
@LeeDr
Copy link

LeeDr commented Sep 21, 2021

  • Then, the user: a. shared the index pattern from the Default space to the Bravo space

It seems like this should error and offer to replace the previously copied index pattern with the shared index pattern. Then there wouldn't be a conflict case.

@jportner
Copy link
Contributor Author

jportner commented Sep 27, 2021

It seems like this should error and offer to replace the previously copied index pattern with the shared index pattern. Then there wouldn't be a conflict case.

This is an old POC that has been superseded by #107256 😄

Since this was created, we did add an extra check at share time to prevent legacy URL conflicts from occurring (see #100424).
Now, if you try to share an object that would result in a conflict scenario, the UI forces you to disable the problematic alias(es) first.

@jportner jportner deleted the sharing-index-patterns branch January 19, 2022 20:45
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.

2 participants