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

[DataViews] GetIndices should allow me to get non-hidden indices #191931

Open
stratoula opened this issue Sep 2, 2024 · 18 comments
Open

[DataViews] GetIndices should allow me to get non-hidden indices #191931

stratoula opened this issue Sep 2, 2024 · 18 comments
Assignees
Labels
Feature:ES|QL ES|QL related features in Kibana Project:OneDiscover Enrich Discover with contextual awareness Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.

Comments

@stratoula
Copy link
Contributor

Describe the feature:

Not sure if this is a bug or a feature but is important for ES|QL.

We are suggestiing indices in the from command using this api

const indices = await dataViews.getIndices({
    showAllIndices: false,
    pattern: '*',
    isRollupIndex: () => false,
  });

and then we mark them as hidden if index.name.startsWith('.') but this is wrong. Not all the indices starting with . are hidden so we need a way to receive all the non-hidden (system indices) and remove the wrong check for the dot.

@stratoula stratoula added Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Project:OneDiscover Enrich Discover with contextual awareness labels Sep 2, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@stratoula stratoula added the Feature:ES|QL ES|QL related features in Kibana label Sep 2, 2024
@stratoula stratoula changed the title [DataViews] Get indices should allow me to get non-hidden indices [DataViews] GetIndices should allow me to get non-hidden indices Sep 2, 2024
@kertal kertal self-assigned this Sep 3, 2024
@kertal
Copy link
Member

kertal commented Sep 3, 2024

I created a hidden index

{
  "settings": {
    "index.hidden": true
  },
  "mappings": {
    "properties": {
      "field1": {
        "type": "text"
      },
      "field2": {
        "type": "keyword"
      }
    }
  }
}

POST /my_hidden_index/_doc/1
{
  "field1": "This is some text data",
  "field2": "keyword_value"
}

and removed the index.name.startsWith('.')

when trying out dataViews.getIndices

if was not part of the returned list, so it might be sufficient to remove this check to get all non-hidden indices?

@stratoula
Copy link
Contributor Author

Hmmm this gives me this list

Image

@ninoslavmiskovic are these indices safe to suggest?

@stratoula
Copy link
Contributor Author

@kertal these are not being suggested in the Index management page so I am not expecting them to be suggested, right?

Image

@jughosta
Copy link
Contributor

jughosta commented Sep 3, 2024

these are not being suggested in the Index management page

They might be on Data Streams tab.

@stratoula
Copy link
Contributor Author

Not all of them Jul

Image

@kertal
Copy link
Member

kertal commented Sep 3, 2024

@kertal these are not being suggested in the Index management page so I am not expecting them to be suggested, right?

I had another look at it, and it seems most of those are tagged alias , e.g. .siem-signals-default

Image

this seems to be an alias for the following index:

.internal.alerts-security.alerts-default-000001

which is appears to be a hidden index?

Image

I'm not sure if this alias should be displayed? In the Index Management, it is not findable?

@stratoula
Copy link
Contributor Author

It should not be suggested if it is an alias to a hidden index. Can the api work like that? Display only indices / aliases that are not hidden (exactly as the Index management page behaves when the Include hidden indices switch is off)

@kertal
Copy link
Member

kertal commented Sep 3, 2024

It should not be suggested if it is an alias to a hidden index. Can the api work like that? Display only indices / aliases that are not hidden (exactly as the Index management page behaves when the Include hidden indices switch is off)

I took a look, but it seems to me, this is currently not supported. If a near term solution is needed a workaround would be for the consumer to filter out those alias to a hidden index. Something like first create a list of not-alias indices, then add alias that point to indices that can be found in the non-alias indices list

@stratoula
Copy link
Contributor Author

@kertal I would like to avoid this in the client side, the api should handle this for performance reasons. So I will wait for this to be prioritized cc @ninoslavmiskovic

@kertal
Copy link
Member

kertal commented Sep 3, 2024

. @kertal I would like to avoid this in the client side, the api should handle this for performance reasons. So I will wait for this to be prioritized cc @ninoslavmiskovic

I do agree that a server side solution is preferable 👍

@ninoslavmiskovic
Copy link
Contributor

++ on not doing it on the client side.

I don't believe it is possible in ES to directly prevent users from creating aliases on hidden indices.

However, as a user, it is possible to be able to control access to hidden indices and alias creation through role-based access control (RBAC). E.g Restrict Index Access:, Aliases Privilege (https://www.elastic.co/guide/en/elasticsearch/reference/current/securing-aliases.html#index-alias-privileges), Custom Roles, Index-Level Security:

Especially the aliases' privileges are interesting

I guess you are a super user @stratoula - perhaps that is why you are able to create aliases with hidden indices.?

@kertal
Copy link
Member

kertal commented Sep 6, 2024

@elastic/kibana-management I'm interested in the logic behind "Include hidden indices" on Index Management, so the whole list is returned, and the filter is applied client side, on the "hidden" property, right? how does it work server side. thx!

Image

@sabarasaba
Copy link
Member

That is correct, we return all indices or datastreams and the pagination happens client side based on the hidden property as you mentioned. This hidden property is computed based on the settings.index.hidden attribute of that given index, you can find the code that deals with creating that response here.

@kertal
Copy link
Member

kertal commented Sep 9, 2024

@sabarasaba thx, this is very helpful!

@kertal
Copy link
Member

kertal commented Sep 9, 2024

No 100% sure, but it might be the case that we are already using the same code under the hood, so in theory the hidden property "just" needs to be made available to the consumers in UI

export const getIndicesViaResolve = async ({
http,
pattern,
showAllIndices,
isRollupIndex,
}: {
http: HttpStart;
pattern: string;
showAllIndices: boolean;
isRollupIndex: (indexName: string) => boolean;
}) => {
const encodedPattern = encodeURIComponent(pattern);
return http
.get<ResolveIndexResponse>(
`/internal/index-pattern-management/resolve_index/${encodedPattern}`,
{
query: showAllIndices ? { expand_wildcards: 'all' } : undefined,
}

FYI @mattkime (once back from PTO)

@mattkime
Copy link
Contributor

mattkime commented Sep 27, 2024

@kertal @stratoula

It should not be suggested if it is an alias to a hidden index. Can the api work like that?

No, thats not how it works and it seems rather purposeful. Our overall state of appropriately marking indices as hidden isn't very thorough - at this point we should be to rely on being marked hidden instead of the leading . but thats not happening in all instances.

If aliases to hidden indices aren't hidden and should be, then the alias should be fixed. Aliases can be marked hidden independent of their underlying indices.

@kertal
Copy link
Member

kertal commented Dec 30, 2024

End of the year, finally time to have a closer look here

I did a quick POC how to simply filter out dot prefixed indices that are alias

#205276

This would enable the selection of dot prefixed indices, that ain't alias, and can be tested here

https://kertal-pr-205276-discover-esql-make-use-of-dot-prefixed-ind.kbndev.co/app/r/s/vFXr6

However this is just a workaround and I agree with @mattkime

If aliases to hidden indices aren't hidden and should be, then the alias should be fixed. Aliases can be marked hidden independent of their underlying indices.

So I think we should remove code that checks index.name.startsWith('.') to determine if an index is hidden. We are using this at many places in Kibana, and it's misleading, since it doesn't mean an index is hidden. And we should cleanup/evaluate indices with . prefix if they were meant to be hidden, and this should be fixed if the intention was so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ES|QL ES|QL related features in Kibana Project:OneDiscover Enrich Discover with contextual awareness Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.
Projects
None yet
Development

No branches or pull requests

7 participants