Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import {
ORCHESTRATOR_NAMESPACE_FIELD,
ORCHESTRATOR_RESOURCE_ID_FIELD,
SERVICE_NAME_FIELD,
DataTableRecord,
getFieldValue,
FILTER_OUT_EXACT_FIELDS_FOR_CONTENT,
} from '@kbn/discover-utils';
import { DataTableRecord, getFieldValue } from '@kbn/discover-utils';
import { LogDocument, ResourceFields, getAvailableResourceFields } from '@kbn/discover-utils/src';
import { FieldBadgeWithActions, FieldBadgeWithActionsProps } from '../cell_actions_popover';
import { ServiceNameBadgeWithActions } from '../service_name_badge_with_actions';
Expand Down Expand Up @@ -143,5 +145,11 @@ export const formatJsonDocumentForContent = (row: DataTableRecord) => {
};
};

const isFieldAllowed = (field: string) =>
!FILTER_OUT_FIELDS_PREFIXES_FOR_CONTENT.some((prefix) => field.startsWith(prefix));
export const isFieldAllowed = (field: string): boolean => {
const isExactMatchExcluded = FILTER_OUT_EXACT_FIELDS_FOR_CONTENT.includes(field);
const isPrefixMatchExcluded = FILTER_OUT_FIELDS_PREFIXES_FOR_CONTENT.some((prefix) =>
field.startsWith(prefix)
);

return !isExactMatchExcluded && !isPrefixMatchExcluded;
};
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export const DEFAULT_ROWS_PER_PAGE = 100;

// List of prefixes which needs to be filtered out for Display in Content Column
export const FILTER_OUT_FIELDS_PREFIXES_FOR_CONTENT = [
'_', // Filter fields like '_id', '_score'
'@timestamp',
'agent.',
'elastic_agent.',
Expand All @@ -61,6 +60,18 @@ export const FILTER_OUT_FIELDS_PREFIXES_FOR_CONTENT = [
'log.',
'service.',
];
export const FILTER_OUT_EXACT_FIELDS_FOR_CONTENT = [
'_id',
'_index',
'_source',
'_size',
'_doc_count',
'_field_names',
'_ignored',
'_routing',
'_meta',
'_tier',
];

export const DEFAULT_ALLOWED_DATA_VIEWS = ['logs', 'auditbeat', 'filebeat', 'winlogbeat'];
export const DEFAULT_ALLOWED_LOGS_DATA_VIEWS = ['logs', 'auditbeat', 'filebeat', 'winlogbeat'];
Expand Down