mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Co-authored-by: Kerry Gallagher <471693+Kerry350@users.noreply.github.com>
This commit is contained in:
parent
5d1707a101
commit
fcab4fd040
3 changed files with 37 additions and 11 deletions
|
@ -40,7 +40,7 @@ const logSourceMessageColumnConfigurationRT = rt.strict({
|
|||
messageColumn: logSourceCommonColumnConfigurationRT,
|
||||
});
|
||||
|
||||
const logSourceFieldColumnConfigurationRT = rt.strict({
|
||||
export const logSourceFieldColumnConfigurationRT = rt.strict({
|
||||
fieldColumn: rt.intersection([
|
||||
logSourceCommonColumnConfigurationRT,
|
||||
rt.strict({
|
||||
|
|
|
@ -18,7 +18,11 @@ import type {
|
|||
ISearchStrategy,
|
||||
PluginStart as DataPluginStart,
|
||||
} from '../../../../../../src/plugins/data/server';
|
||||
import { LogSourceColumnConfiguration } from '../../../common/http_api/log_sources';
|
||||
import {
|
||||
LogSourceColumnConfiguration,
|
||||
LogSourceConfigurationProperties,
|
||||
logSourceFieldColumnConfigurationRT,
|
||||
} from '../../../common/http_api/log_sources';
|
||||
import {
|
||||
getLogEntryCursorFromHit,
|
||||
LogColumn,
|
||||
|
@ -103,7 +107,7 @@ export const logEntriesSearchStrategyProvider = ({
|
|||
params.size + 1,
|
||||
configuration.fields.timestamp,
|
||||
configuration.fields.tiebreaker,
|
||||
messageFormattingRules.requiredFields,
|
||||
getRequiredFields(configuration, messageFormattingRules, params.columns),
|
||||
params.query,
|
||||
params.highlightPhrase
|
||||
),
|
||||
|
@ -125,7 +129,12 @@ export const logEntriesSearchStrategyProvider = ({
|
|||
|
||||
const entries = rawResponse.hits.hits
|
||||
.slice(0, request.params.size)
|
||||
.map(getLogEntryFromHit(configuration.logColumns, messageFormattingRules));
|
||||
.map(
|
||||
getLogEntryFromHit(
|
||||
request.params.columns ? request.params.columns : configuration.logColumns,
|
||||
messageFormattingRules
|
||||
)
|
||||
);
|
||||
|
||||
const sortDirection = getSortDirection(pickRequestCursor(request.params));
|
||||
|
||||
|
@ -244,3 +253,26 @@ function getResponseCursors(entries: LogEntry[]) {
|
|||
|
||||
return { topCursor, bottomCursor };
|
||||
}
|
||||
|
||||
const VIEW_IN_CONTEXT_FIELDS = ['log.file.path', 'host.name', 'container.id'];
|
||||
|
||||
const getRequiredFields = (
|
||||
configuration: LogSourceConfigurationProperties,
|
||||
messageFormattingRules: CompiledLogMessageFormattingRule,
|
||||
columnOverrides?: LogSourceColumnConfiguration[]
|
||||
): string[] => {
|
||||
const columns = columnOverrides ? columnOverrides : configuration.logColumns;
|
||||
|
||||
const fieldsFromColumns = columns.reduce<string[]>((accumulatedFields, logColumn) => {
|
||||
if (logSourceFieldColumnConfigurationRT.is(logColumn)) {
|
||||
return [...accumulatedFields, logColumn.fieldColumn.field];
|
||||
}
|
||||
return accumulatedFields;
|
||||
}, []);
|
||||
|
||||
const fieldsFromFormattingRules = messageFormattingRules.requiredFields;
|
||||
|
||||
return Array.from(
|
||||
new Set([...fieldsFromColumns, ...fieldsFromFormattingRules, ...VIEW_IN_CONTEXT_FIELDS])
|
||||
);
|
||||
};
|
||||
|
|
|
@ -20,8 +20,6 @@ import {
|
|||
} from '../../../utils/elasticsearch_runtime_types';
|
||||
import { createSortClause, createTimeRangeFilterClauses } from './common';
|
||||
|
||||
const CONTEXT_FIELDS = ['log.file.path', 'host.name', 'container.id'];
|
||||
|
||||
export const createGetLogEntriesQuery = (
|
||||
logEntriesIndex: string,
|
||||
startTimestamp: number,
|
||||
|
@ -36,7 +34,6 @@ export const createGetLogEntriesQuery = (
|
|||
): RequestParams.AsyncSearchSubmit<Record<string, any>> => {
|
||||
const sortDirection = getSortDirection(cursor);
|
||||
const highlightQuery = createHighlightQuery(highlightTerm, fields);
|
||||
const fieldsWithContext = createFieldsWithContext(fields);
|
||||
|
||||
return {
|
||||
index: logEntriesIndex,
|
||||
|
@ -54,7 +51,7 @@ export const createGetLogEntriesQuery = (
|
|||
],
|
||||
},
|
||||
},
|
||||
fields: fieldsWithContext,
|
||||
fields,
|
||||
_source: false,
|
||||
...createSortClause(sortDirection, timestampField, tiebreakerField),
|
||||
...createSearchAfterClause(cursor),
|
||||
|
@ -120,9 +117,6 @@ const createHighlightQuery = (
|
|||
}
|
||||
};
|
||||
|
||||
const createFieldsWithContext = (fields: string[]): string[] =>
|
||||
Array.from(new Set([...fields, ...CONTEXT_FIELDS]));
|
||||
|
||||
export const logEntryHitRT = rt.intersection([
|
||||
commonHitFieldsRT,
|
||||
rt.type({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue