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] Check if logs-*, metrics-*, apm- empty state workaround is still needed and clean up #127869

Closed
2 of 3 tasks
Dosant opened this issue Mar 16, 2022 · 1 comment
Closed
2 of 3 tasks
Assignees
Labels
Feature:Data Views Data Views code and UI - index patterns before 8.0 impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:medium Medium Level of Effort technical debt Improvement of the software architecture and operational architecture

Comments

@Dosant
Copy link
Contributor

Dosant commented Mar 16, 2022

Summary:

In #108887, #110094 we added a list of hardcoded "default" assets into logic to check if this is a new instance of Kibana to show a welcome screen and present other empty states.

Since #82851 is fixed in 8.1 it is likely that we can clean up that code: remove a list of hardcoded assets completely or at least reduce number of them:

Relevant code:

export const hasUserIndexPattern = async ({ esClient, soClient }: Deps): Promise<boolean> => {
const indexPatterns = await soClient.find<IndexPatternSavedObjectAttrs>({
type: 'index-pattern',
fields: ['title'],
search: `*`,
searchFields: ['title'],
perPage: 100,
});
if (indexPatterns.total === 0) {
return false;
}
// If there are any index patterns that are not the default metrics-* and logs-* ones created by Fleet,
// assume there are user created index patterns
if (
indexPatterns.saved_objects.some(
(ip) =>
ip.attributes.title !== DEFAULT_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN &&
ip.attributes.title !== DEFAULT_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN
)
) {
return true;
}
const resolveResponse = await esClient.indices.resolveIndex({
name: `${DEFAULT_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN},${DEFAULT_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN}`,
});
const hasAnyNonDefaultFleetIndices = resolveResponse.indices.some(
(ds) => ds.name !== DEFAULT_ASSETS_TO_IGNORE.METRICS_ENDPOINT_INDEX_TO_IGNORE
);
if (hasAnyNonDefaultFleetIndices) return true;
const hasAnyNonDefaultFleetDataStreams = resolveResponse.data_streams.some(
(ds) =>
ds.name !== DEFAULT_ASSETS_TO_IGNORE.METRICS_DATA_STREAM_TO_IGNORE &&
ds.name !== DEFAULT_ASSETS_TO_IGNORE.LOGS_DATA_STREAM_TO_IGNORE &&
ds.name !== DEFAULT_ASSETS_TO_IGNORE.ENT_SEARCH_LOGS_DATA_STREAM_TO_IGNORE
);
if (hasAnyNonDefaultFleetDataStreams) return true;
return false;
};

export function isUserDataIndex(source: MatchedItem) {
// filter out indices that start with `.`
if (source.name.startsWith('.')) return false;
// filter out sources from DEFAULT_ASSETS_TO_IGNORE
if (source.name === DEFAULT_ASSETS_TO_IGNORE.LOGS_DATA_STREAM_TO_IGNORE) return false;
if (source.name === DEFAULT_ASSETS_TO_IGNORE.METRICS_DATA_STREAM_TO_IGNORE) return false;
if (source.name === DEFAULT_ASSETS_TO_IGNORE.METRICS_ENDPOINT_INDEX_TO_IGNORE) return false;
if (source.name === DEFAULT_ASSETS_TO_IGNORE.ENT_SEARCH_LOGS_DATA_STREAM_TO_IGNORE) return false;
// filter out empty sources created by apm server
if (source.name.startsWith('apm-')) return false;
return true;
}

Related issues:

#124019

cc @shivindera @mattkime

@Dosant Dosant added technical debt Improvement of the software architecture and operational architecture Feature:Data Views Data Views code and UI - index patterns before 8.0 Team:AppServicesSv labels Mar 16, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServicesSv)

@Dosant Dosant mentioned this issue Mar 16, 2022
3 tasks
@shivindera shivindera self-assigned this Mar 17, 2022
@exalate-issue-sync exalate-issue-sync bot added impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:medium Medium Level of Effort labels Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Data Views Data Views code and UI - index patterns before 8.0 impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:medium Medium Level of Effort technical debt Improvement of the software architecture and operational architecture
Projects
None yet
Development

No branches or pull requests

3 participants