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

Filter by namespace the index pattern list #1450

Closed
jesusgn90 opened this issue May 16, 2019 · 2 comments
Closed

Filter by namespace the index pattern list #1450

jesusgn90 opened this issue May 16, 2019 · 2 comments
Assignees
Labels
request/operational Operational requests type/bug Bug issue

Comments

@jesusgn90
Copy link
Contributor

jesusgn90 commented May 16, 2019

Hi team,

Since Kibana added custom spaces, we must filter the index pattern list for the currently active space.

App == 3.7.2 - 6.5.3

The app is working under custom spaces but it shows duplicated index pattern titles because you can have the same title in different namespaces.

Apps >= 3.7.2 - 6.5.4

The app is not working under custom spaces, as we can see in #1234.

Index pattern structure under a custom space

They differ in the _id field as we can see here:

Custom space:

"_id" : "policy:index-pattern:baac56b0-77c5-11e9-87ba-8bd463f63d67",

Default space:

"_id" : "index-pattern:baac56b0-77c5-11e9-87ba-8bd463f63d67",

But the title might be the same for both index patterns, that's why the app may show the same pattern twice, their titles are the same and we are showing the titles.

An index pattern created under a custom space also adds the next field:

"namespace" : "your-space-name",

We must fix this behavior because it generates inconsistencies in complex environments or in segmented environments.

Proposal

  • The incoming request object has all the information we need to properly filter the index pattern list, it's just an extra validation to our current validation.
  • The problem for opening the app under custom spaces probably comes from a breaking change on the Kibana side from 6.5.4 and onwards because it's opening in 6.5.3.
@jesusgn90
Copy link
Contributor Author

Hi team,

Here is how to obtain the namespace of the incoming request:

const spaces = this._server.plugins.spaces;
const namespace =  spaces &&  spaces.getSpaceId(req);

Then, if we have a namespace different from undefined it means it's not the default namespace:

if (namespace !== 'default') {
    data.hits.hits = data.hits.hits.filter(item => (item._id || '').includes(namespace));
}

At this point, index patterns are filtered properly, but the issue is still in progress.

@jesusgn90
Copy link
Contributor Author

Solution for this issue is definitively the next two lines:

const spaces = this._server.plugins.spaces;
const namespace =  spaces &&  spaces.getSpaceId(req);

and then, use the namespace when needed.

I'm going to close this ticket, rest of the custom spaces related fixes will be posted under #1234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request/operational Operational requests type/bug Bug issue
Projects
None yet
Development

No branches or pull requests

1 participant