Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
54ec71a
[Logs UI][Metrics UI] Remove deprecated config fields from APIs
Zacqary Oct 20, 2021
9f4847d
Fix typecheck
Zacqary Oct 20, 2021
00bdeaf
Fix typecheck
Zacqary Oct 21, 2021
ae36941
Fix typecheck
Zacqary Oct 21, 2021
0a2c206
Fix jest
Zacqary Oct 21, 2021
c0f907f
Fix functional test
Zacqary Oct 21, 2021
b2de461
Merge remote-tracking branch 'upstream/master' into 115257-deprecated…
Zacqary Oct 21, 2021
d305db0
Merge remote-tracking branch 'upstream/master' into 115257-deprecated…
Zacqary Oct 25, 2021
417fe50
Merge remote-tracking branch 'upstream/master' into 115257-deprecated…
Zacqary Oct 26, 2021
015793c
Remove extraneous timeField args
Zacqary Oct 26, 2021
7a65545
Typecheck fix
Zacqary Oct 26, 2021
2c8addf
Consolidate log file changes to ResolvedLogSourceConfiguration
Zacqary Oct 27, 2021
38c6a1b
Fix merge
Zacqary Oct 27, 2021
9b54051
Merge remote-tracking branch 'upstream/master' into 115257-deprecated…
Zacqary Oct 27, 2021
bddc9ca
Revert additional logs files
Zacqary Oct 27, 2021
f91a05e
Revert inventory models
Zacqary Oct 27, 2021
bd2f062
Revert log_analysis api
Zacqary Oct 27, 2021
951160e
Fix timefield reference in process list
Zacqary Oct 27, 2021
077f9c1
Restore logs page files, fix typecheck on mock
Zacqary Oct 27, 2021
ed5825a
Fix functional test
Zacqary Oct 27, 2021
c3d5af7
Restore inventory models index
Zacqary Oct 27, 2021
245ef33
Fix typecheck on getFilteredMetrics
Zacqary Oct 27, 2021
8e8350a
Look CI if you don't tell me all the type errors at once I can't fix …
Zacqary Oct 27, 2021
2b01e7f
Maybe this is the last typecheck fix who knows
Zacqary Oct 27, 2021
facdac6
Merge remote-tracking branch 'upstream/main' into 115257-deprecated-f…
Zacqary Oct 28, 2021
31bd144
Merge remote-tracking branch 'upstream/main' into 115257-deprecated-f…
Zacqary Nov 1, 2021
7488a40
Merge branch 'main' into 115257-deprecated-fields-removal
kibanamachine Nov 4, 2021
f362f84
Restore reading timestamp field from data view
Zacqary Nov 4, 2021
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
7 changes: 6 additions & 1 deletion x-pack/plugins/infra/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
export const DEFAULT_SOURCE_ID = 'default';
export const METRICS_INDEX_PATTERN = 'metrics-*,metricbeat-*';
export const LOGS_INDEX_PATTERN = 'logs-*,filebeat-*,kibana_sample_data_logs*';
export const TIMESTAMP_FIELD = '@timestamp';
export const METRICS_APP = 'metrics';
export const LOGS_APP = 'logs';

export const METRICS_FEATURE_ID = 'infrastructure';
export const LOGS_FEATURE_ID = 'logs';

export type InfraFeatureId = typeof METRICS_FEATURE_ID | typeof LOGS_FEATURE_ID;

export const TIMESTAMP_FIELD = '@timestamp';
export const TIEBREAKER_FIELD = '_doc';
export const HOST_FIELD = 'host.name';
export const CONTAINER_FIELD = 'container.id';
export const POD_FIELD = 'kubernetes.pod.uid';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const AggValueRT = rt.type({

export const ProcessListAPIRequestRT = rt.type({
hostTerm: rt.record(rt.string, rt.string),
timefield: rt.string,
indexPattern: rt.string,
to: rt.number,
sortBy: rt.type({
Expand Down Expand Up @@ -102,7 +101,6 @@ export type ProcessListAPIResponse = rt.TypeOf<typeof ProcessListAPIResponseRT>;

export const ProcessListAPIChartRequestRT = rt.type({
hostTerm: rt.record(rt.string, rt.string),
timefield: rt.string,
indexPattern: rt.string,
to: rt.number,
command: rt.string,
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/infra/common/http_api/metrics_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { MetricsUIAggregationRT } from '../inventory_models/types';
import { afterKeyObjectRT } from './metrics_explorer';

export const MetricsAPITimerangeRT = rt.type({
field: rt.string,
from: rt.number,
to: rt.number,
interval: rt.string,
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/infra/common/http_api/metrics_explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const metricsExplorerMetricRT = rt.intersection([
]);

export const timeRangeRT = rt.type({
field: rt.string,
from: rt.number,
to: rt.number,
interval: rt.string,
Expand Down
23 changes: 8 additions & 15 deletions x-pack/plugins/infra/common/inventory_models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { POD_FIELD, HOST_FIELD, CONTAINER_FIELD } from '../constants';
import { host } from './host';
import { pod } from './pod';
import { awsEC2 } from './aws_ec2';
Expand All @@ -30,31 +31,23 @@ export const findInventoryModel = (type: InventoryItemType) => {
return model;
};

interface InventoryFields {
host: string;
pod: string;
container: string;
timestamp: string;
tiebreaker: string;
}

const LEGACY_TYPES = ['host', 'pod', 'container'];

const getFieldByType = (type: InventoryItemType, fields: InventoryFields) => {
export const getFieldByType = (type: InventoryItemType) => {
switch (type) {
case 'pod':
return fields.pod;
return POD_FIELD;
case 'host':
return fields.host;
return HOST_FIELD;
case 'container':
return fields.container;
return CONTAINER_FIELD;
}
};

export const findInventoryFields = (type: InventoryItemType, fields?: InventoryFields) => {
export const findInventoryFields = (type: InventoryItemType) => {
const inventoryModel = findInventoryModel(type);
if (fields && LEGACY_TYPES.includes(type)) {
const id = getFieldByType(type, fields) || inventoryModel.fields.id;
if (LEGACY_TYPES.includes(type)) {
const id = getFieldByType(type) || inventoryModel.fields.id;
return {
...inventoryModel.fields,
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ export const logSourceConfigurationOriginRT = rt.keyof({
export type LogSourceConfigurationOrigin = rt.TypeOf<typeof logSourceConfigurationOriginRT>;

const logSourceFieldsConfigurationRT = rt.strict({
container: rt.string,
host: rt.string,
pod: rt.string,
timestamp: rt.string,
tiebreaker: rt.string,
message: rt.array(rt.string),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { DataView, DataViewsContract } from '../../../../../src/plugins/data_views/common';
import { ObjectEntries } from '../utility_types';
import { TIMESTAMP_FIELD, TIEBREAKER_FIELD } from '../constants';
import { ResolveLogSourceConfigurationError } from './errors';
import {
LogSourceColumnConfiguration,
Expand Down Expand Up @@ -61,8 +62,8 @@ const resolveLegacyReference = async (

return {
indices: sourceConfiguration.logIndices.indexName,
timestampField: sourceConfiguration.fields.timestamp,
tiebreakerField: sourceConfiguration.fields.tiebreaker,
timestampField: TIMESTAMP_FIELD,
tiebreakerField: TIEBREAKER_FIELD,
messageField: sourceConfiguration.fields.message,
fields,
runtimeMappings: {},
Expand Down Expand Up @@ -91,8 +92,8 @@ const resolveKibanaIndexPatternReference = async (

return {
indices: indexPattern.title,
timestampField: indexPattern.timeFieldName ?? '@timestamp',
tiebreakerField: '_doc',
timestampField: indexPattern.timeFieldName ?? TIMESTAMP_FIELD,
tiebreakerField: TIEBREAKER_FIELD,
messageField: ['message'],
fields: indexPattern.fields,
runtimeMappings: resolveRuntimeMappings(indexPattern),
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/infra/common/metrics_sources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import * as rt from 'io-ts';
import { omit } from 'lodash';
import {
SourceConfigurationRT,
SourceStatusRuntimeType,
Expand All @@ -22,7 +21,6 @@ export const metricsSourceConfigurationPropertiesRT = rt.strict({
metricAlias: SourceConfigurationRT.props.metricAlias,
inventoryDefaultView: SourceConfigurationRT.props.inventoryDefaultView,
metricsExplorerDefaultView: SourceConfigurationRT.props.metricsExplorerDefaultView,
fields: rt.strict(omit(SourceConfigurationRT.props.fields.props, 'message')),
anomalyThreshold: rt.number,
});

Expand All @@ -32,9 +30,6 @@ export type MetricsSourceConfigurationProperties = rt.TypeOf<

export const partialMetricsSourceConfigurationPropertiesRT = rt.partial({
...metricsSourceConfigurationPropertiesRT.type.props,
fields: rt.partial({
...metricsSourceConfigurationPropertiesRT.type.props.fields.type.props,
}),
});

export type PartialMetricsSourceConfigurationProperties = rt.TypeOf<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ export const sourceConfigurationConfigFilePropertiesRT = rt.type({
sources: rt.type({
default: rt.partial({
fields: rt.partial({
timestamp: rt.string,
message: rt.array(rt.string),
tiebreaker: rt.string,
host: rt.string,
container: rt.string,
pod: rt.string,
}),
}),
}),
Expand Down Expand Up @@ -113,11 +108,6 @@ export type InfraSourceConfigurationColumn = rt.TypeOf<typeof SourceConfiguratio
*/

const SourceConfigurationFieldsRT = rt.type({
container: rt.string,
host: rt.string,
pod: rt.string,
tiebreaker: rt.string,
timestamp: rt.string,
message: rt.array(rt.string),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ describe('ExpressionChart', () => {
metricAlias: 'metricbeat-*',
inventoryDefaultView: 'host',
metricsExplorerDefaultView: 'host',
// @ts-ignore
fields: {
timestamp: '@timestamp',
container: 'container.id',
host: 'host.name',
pod: 'kubernetes.pod.uid',
tiebreaker: '_doc',
},
anomalyThreshold: 20,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ export const createBasicSourceConfiguration = (sourceId: string): LogSourceConfi
},
logColumns: [],
fields: {
container: 'CONTAINER_FIELD',
host: 'HOST_FIELD',
pod: 'POD_FIELD',
tiebreaker: 'TIEBREAKER_FIELD',
timestamp: 'TIMESTAMP_FIELD',
message: ['MESSAGE_FIELD'],
},
name: sourceId,
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/infra/public/containers/ml/infra_ml_module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const useInfraMLModule = <JobType extends string>({
moduleDescriptor: ModuleDescriptor<JobType>;
}) => {
const { services } = useKibanaContextForPlugin();
const { spaceId, sourceId, timestampField } = sourceConfiguration;
const { spaceId, sourceId } = sourceConfiguration;
const [moduleStatus, dispatchModuleStatus] = useModuleStatus(moduleDescriptor.jobTypes);

const [, fetchJobStatus] = useTrackedPromise(
Expand Down Expand Up @@ -64,7 +64,6 @@ export const useInfraMLModule = <JobType extends string>({
indices: selectedIndices,
sourceId,
spaceId,
timestampField,
},
partitionField,
},
Expand All @@ -91,7 +90,7 @@ export const useInfraMLModule = <JobType extends string>({
dispatchModuleStatus({ type: 'failedSetup' });
},
},
[moduleDescriptor.setUpModule, spaceId, sourceId, timestampField]
[moduleDescriptor.setUpModule, spaceId, sourceId]
);

const [cleanUpModuleRequest, cleanUpModule] = useTrackedPromise(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export const isJobConfigurationOutdated =
isSubset(
new Set(jobConfiguration.indexPattern.split(',')),
new Set(currentSourceConfiguration.indices)
) &&
jobConfiguration.timestampField === currentSourceConfiguration.timestampField
)
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ export interface ModuleDescriptor<JobType extends string> {
) => Promise<DeleteJobsResponsePayload>;
validateSetupIndices?: (
indices: string[],
timestampField: string,
fetch: HttpHandler
) => Promise<ValidationIndicesResponsePayload>;
validateSetupDatasets?: (
indices: string[],
timestampField: string,
startTime: number,
endTime: number,
fetch: HttpHandler
Expand All @@ -65,7 +63,6 @@ export interface ModuleSourceConfiguration {
indices: string[];
sourceId: string;
spaceId: string;
timestampField: string;
}

interface ManyCategoriesWarningReason {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ export const useMetricHostsModule = ({
indexPattern,
sourceId,
spaceId,
timestampField,
}: {
indexPattern: string;
sourceId: string;
spaceId: string;
timestampField: string;
}) => {
const sourceConfiguration: ModuleSourceConfiguration = useMemo(
() => ({
indices: indexPattern.split(','),
sourceId,
spaceId,
timestampField,
}),
[indexPattern, sourceId, spaceId, timestampField]
[indexPattern, sourceId, spaceId]
);

const infraMLModule = useInfraMLModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
MetricsHostsJobType,
bucketSpan,
} from '../../../../../common/infra_ml';
import { TIMESTAMP_FIELD } from '../../../../../common/constants';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import MemoryJob from '../../../../../../ml/server/models/data_recognizer/modules/metrics_ui_hosts/ml/hosts_memory_usage.json';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
Expand Down Expand Up @@ -68,7 +69,7 @@ const setUpModule = async (setUpModuleArgs: SetUpModuleArgs, fetch: HttpHandler)
start,
end,
filter,
moduleSourceConfiguration: { spaceId, sourceId, indices, timestampField },
moduleSourceConfiguration: { spaceId, sourceId, indices },
partitionField,
} = setUpModuleArgs;

Expand All @@ -93,13 +94,13 @@ const setUpModule = async (setUpModuleArgs: SetUpModuleArgs, fetch: HttpHandler)
return {
job_id: id,
data_description: {
time_field: timestampField,
time_field: TIMESTAMP_FIELD,
},
analysis_config,
custom_settings: {
metrics_source_config: {
indexPattern: indexNamePattern,
timestampField,
timestampField: TIMESTAMP_FIELD,
bucketSpan,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ export const useMetricK8sModule = ({
indexPattern,
sourceId,
spaceId,
timestampField,
}: {
indexPattern: string;
sourceId: string;
spaceId: string;
timestampField: string;
}) => {
const sourceConfiguration: ModuleSourceConfiguration = useMemo(
() => ({
indices: indexPattern.split(','),
sourceId,
spaceId,
timestampField,
}),
[indexPattern, sourceId, spaceId, timestampField]
[indexPattern, sourceId, spaceId]
);

const infraMLModule = useInfraMLModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
MetricK8sJobType,
bucketSpan,
} from '../../../../../common/infra_ml';
import { TIMESTAMP_FIELD } from '../../../../../common/constants';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import MemoryJob from '../../../../../../ml/server/models/data_recognizer/modules/metrics_ui_k8s/ml/k8s_memory_usage.json';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
Expand Down Expand Up @@ -69,7 +70,7 @@ const setUpModule = async (setUpModuleArgs: SetUpModuleArgs, fetch: HttpHandler)
start,
end,
filter,
moduleSourceConfiguration: { spaceId, sourceId, indices, timestampField },
moduleSourceConfiguration: { spaceId, sourceId, indices },
partitionField,
} = setUpModuleArgs;

Expand All @@ -93,13 +94,13 @@ const setUpModule = async (setUpModuleArgs: SetUpModuleArgs, fetch: HttpHandler)
return {
job_id: id,
data_description: {
time_field: timestampField,
time_field: TIMESTAMP_FIELD,
},
analysis_config,
custom_settings: {
metrics_source_config: {
indexPattern: indexNamePattern,
timestampField,
timestampField: TIMESTAMP_FIELD,
bucketSpan,
},
},
Expand Down
Loading