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

[MD] Concatenate data source name with index pattern name and change delimiter to double colon #5907

Merged
merged 5 commits into from
Feb 23, 2024

Conversation

BionIT
Copy link
Collaborator

@BionIT BionIT commented Feb 21, 2024

Description

This change adds data source name as a prefix to the index pattern name for the index pattern selector. This change also changed the delimiter for the datasource name and index pattern name to be double colons by changing getIndexPatternTitle function which is used by index pattern service(

result.attributes.title = await getIndexPatternTitle(
) and saved object management page( ).

Issues Resolved

Fixes #5900

Screenshot

concatdsnameandindexname.mp4

Testing the changes

The following steps were performed to test the change in the recording:

  1. disable data source, goes to maps plugin page
  2. click add layer, then see the index pattern selector with options populated
  3. go to visualization and select Controls , then click Add, will see index pattern selector with options populated correctly
  4. enable data source, goes to the same visualization page, and will see the options that have data source name prefixed before index pattern name, the delimiter is double colon
  5. go to maps plugin, click add layer, then see the index pattern selector with options populated, data source name is added as prefix before the index pattern name and the delimiter is double colon

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Lu Yu <nluyu@amazon.com>
Signed-off-by: Lu Yu <nluyu@amazon.com>
Copy link

codecov bot commented Feb 21, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 67.01%. Comparing base (4081154) to head (5e30698).

Files Patch % Lines
...lugins/data/common/index_patterns/lib/get_title.ts 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5907      +/-   ##
==========================================
+ Coverage   66.98%   67.01%   +0.02%     
==========================================
  Files        3305     3305              
  Lines       63574    63585      +11     
  Branches    10153    10155       +2     
==========================================
+ Hits        42587    42609      +22     
+ Misses      18520    18506      -14     
- Partials     2467     2470       +3     
Flag Coverage Δ
Linux_1 35.21% <13.33%> (-0.01%) ⬇️
Linux_2 55.09% <13.33%> (-0.02%) ⬇️
Linux_3 43.58% <93.33%> (+0.01%) ⬆️
Linux_4 35.20% <13.33%> (-0.01%) ⬇️
Windows_1 35.27% <13.33%> (+0.02%) ⬆️
Windows_2 55.06% <13.33%> (-0.02%) ⬇️
Windows_3 43.58% <93.33%> (+0.02%) ⬆️
Windows_4 35.20% <13.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Lu Yu <nluyu@amazon.com>
@bandinib-amzn
Copy link
Member

Can we add local cluster prefix for index pattern created from local cluster index for consistent look? cc: @kgcreative

@kgcreative
Copy link
Member

Can we add local cluster prefix for index pattern created from local cluster index for consistent look? cc: @kgcreative

I think that makes sense. What do you think, @BionIT?

@kgcreative
Copy link
Member

With concatenated names, would that also resolve the current bug of not being able to create an index pattern with the same name against two clusters?

Today, if I create an index pattern named sample_logs* on my local cluster, I am forced to get creative and create an index pattern named sample_log* against cluster 2.

We can update the unique names requirement to only check for unique index pattern names against the same data source

@BionIT
Copy link
Collaborator Author

BionIT commented Feb 21, 2024

Can we add local cluster prefix for index pattern created from local cluster index for consistent look? cc: @kgcreative

I think that makes sense. What do you think, @BionIT?

I think that would make it confusing if user doesn't know what does local cluster represents and they have no control of it since it is hard coded there and they might wonder where does this local cluster name came from. The reason we add data source name as prefix is to make it easy to distinguish between index patterns created using different data sources and the data source name was created by user. To keep consistency, I didn't see local cluster being added in the dashboards today to emphasize the index pattern or saved object is from local cluster.

Comment on lines +174 to +193
const dataSourcesToFetch: Array<{ type: string; id: string }> = [];
savedObjects.map((indexPatternSavedObject: SimpleSavedObject<any>) => {
const dataSourceReference = getDataSourceReference(indexPatternSavedObject.references);
if (dataSourceReference && !this.state.dataSourceIdToTitle.has(dataSourceReference.id)) {
dataSourcesToFetch.push({ type: 'data-source', id: dataSourceReference.id });
}
});

const dataSourceIdToTitleToUpdate = new Map();

if (dataSourcesToFetch.length > 0) {
const resp = await savedObjectsClient.bulkGet(dataSourcesToFetch);
resp.savedObjects.map((dataSourceSavedObject: SimpleSavedObject<any>) => {
dataSourceIdToTitleToUpdate.set(
dataSourceSavedObject.id,
dataSourceSavedObject.attributes.title
);
});
}

Copy link
Member

Choose a reason for hiding this comment

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

Can we move this code to getTitle? We have index pattern id, saved object client to find reference, right? We don't have to pass third parameter. Otherwise consumer of getTitle always needs to pass map with data source id and title? Instead can getTitle function handle that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This part of code would perform bulk get index patterns(existing behavior), the added behavior is if the referred data source doesn't exist in the current state, it will fetch the data sources in bulk. Note there is only 2 requests here. The getTitle function is only used for selected index pattern which is a single index pattern, the existing behavior is it use an index pattern id to make individual call to saved object API to get the index pattern title, and if we use this function to handle all index patterns, this would multiple by number of index patterns, then to add data source title would double the requests.
If we want to refactor this, I can extract the logic here to a function to perform bulk operation and to produce the idToTitle map

Copy link
Member

Choose a reason for hiding this comment

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

Got it. No need to extract for now. We need to unify the pickers from all screen and that would be another effort. Thanks for the change.

@bandinib-amzn
Copy link
Member

Can we add local cluster prefix for index pattern created from local cluster index for consistent look? cc: @kgcreative

I think that makes sense. What do you think, @BionIT?

I think that would make it confusing if user doesn't know what does local cluster represents and they have no control of it since it is hard coded there and they might wonder where does this local cluster name came from. The reason we add data source name as prefix is to make it easy to distinguish between index patterns created using different data sources and the data source name was created by user. To keep consistency, I didn't see local cluster being added in the dashboards today to emphasize the index pattern or saved object is from local cluster.

But we do have Local cluster option in cluster selector. Do you mean when multi data source feature is disabled?

@BionIT
Copy link
Collaborator Author

BionIT commented Feb 22, 2024

Can we add local cluster prefix for index pattern created from local cluster index for consistent look? cc: @kgcreative

I think that makes sense. What do you think, @BionIT?

I think that would make it confusing if user doesn't know what does local cluster represents and they have no control of it since it is hard coded there and they might wonder where does this local cluster name came from. The reason we add data source name as prefix is to make it easy to distinguish between index patterns created using different data sources and the data source name was created by user. To keep consistency, I didn't see local cluster being added in the dashboards today to emphasize the index pattern or saved object is from local cluster.

But we do have Local cluster option in cluster selector. Do you mean when multi data source feature is disabled?

That's the place for user to select the source and not for adding to the existing title, if we look at 1) data picker in discover, 2) in index pattern management page, 3) in saved objects management, none of them show the local cluster in the title. If we plan to be explicit about which resource belong to which cluster or local cluster, then I would suggest to make the change in all the pages. If we just need it to distinguish from resources from local cluster, then the current practice of handling is to not have local cluster in the title unless we plan to change the existing behavior which can be done in a separate PR? Any suggestions @kgcreative ?

@kgcreative
Copy link
Member

Let's keep this issue scoped. I would prefer we don't change the way we display local cluster just yet, especially if that will require a lot of additional work and scope. We can have a sepparate conversation about enhancements and ergonomics of index patterns, including potentially a display name and other concepts in order to make this more fully featured in the future.

@bandinib-amzn
Copy link
Member

Approved the change. But can you check why several checks are failing?

@ZilongX ZilongX merged commit 4ab0ca8 into opensearch-project:main Feb 23, 2024
73 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 23, 2024
…delimiter to double colon (#5907)

* concatenate data source name with index pattern name

Signed-off-by: Lu Yu <nluyu@amazon.com>

* add changelog

Signed-off-by: Lu Yu <nluyu@amazon.com>

* add tests

Signed-off-by: Lu Yu <nluyu@amazon.com>

---------

Signed-off-by: Lu Yu <nluyu@amazon.com>
(cherry picked from commit 4ab0ca8)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ZilongX pushed a commit that referenced this pull request Feb 26, 2024
…delimiter to double colon (#5907) (#5930)

* concatenate data source name with index pattern name



* add changelog



* add tests



---------


(cherry picked from commit 4ab0ca8)

Signed-off-by: Lu Yu <nluyu@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
SuZhou-Joe pushed a commit to SuZhou-Joe/OpenSearch-Dashboards that referenced this pull request Mar 4, 2024
…delimiter to double colon (opensearch-project#5907)

* concatenate data source name with index pattern name

Signed-off-by: Lu Yu <nluyu@amazon.com>

* add changelog

Signed-off-by: Lu Yu <nluyu@amazon.com>

* add tests

Signed-off-by: Lu Yu <nluyu@amazon.com>

---------

Signed-off-by: Lu Yu <nluyu@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants