[SecuritySolution] Add same family data to telemetry (#170565)

## Summary

1. Added `sameFamilyFields`, `numberOfSameFamily` field to `Data Quality
Index Checked`

<img width="2546" alt="Screenshot 2023-11-03 at 18 23 27"
src="a56a74fd-13a1-4489-9e29-367ff3754cbe">

2. Added `numberOfSameFamily` field to `Data Quality Check All
Completed`

<img width="2557" alt="Screenshot 2023-11-03 at 18 24 39"
src="e1ff3497-3dd0-4352-a8c0-92c0ed588863">
This commit is contained in:
Angela Chuang 2023-11-07 09:00:24 +00:00 committed by GitHub
parent 26428202e5
commit 375236f6b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 2 deletions

View file

@ -36,6 +36,7 @@ import {
getAllIncompatibleMarkdownComments,
getIncompatibleValuesFields,
getIncompatibleMappingsFields,
getSameFamilyFields,
} from '../tabs/incompatible_tab/helpers';
import * as i18n from './translations';
import type { EcsMetadata, IlmPhase, PartitionedFieldMetadata, PatternRollup } from '../../types';
@ -278,8 +279,10 @@ const IndexPropertiesComponent: React.FC<Props> = ({
numberOfIncompatibleFields: indexIncompatible,
numberOfIndices: 1,
numberOfIndicesChecked: 1,
numberOfSameFamily: indexSameFamily,
sizeInBytes: getSizeInBytes({ stats: patternRollup.stats, indexName }),
timeConsumedMs: requestTime,
sameFamilyFields: getSameFamilyFields(partitionedFieldMetadata.sameFamily),
unallowedMappingFields: getIncompatibleMappingsFields(
partitionedFieldMetadata.incompatible
),

View file

@ -65,7 +65,22 @@ export const getIncompatibleMappingsFields = (
enrichedFieldMetadata: EnrichedFieldMetadata[]
): string[] =>
enrichedFieldMetadata.reduce<string[]>((acc, x) => {
if (!x.isEcsCompliant && x.type !== x.indexFieldType) {
if (
!x.isEcsCompliant &&
x.type !== x.indexFieldType &&
!getIsInSameFamily({ ecsExpectedType: x.type, type: x.indexFieldType })
) {
const field = escape(x.indexFieldName);
if (field != null) {
return [...acc, field];
}
}
return acc;
}, []);
export const getSameFamilyFields = (enrichedFieldMetadata: EnrichedFieldMetadata[]): string[] =>
enrichedFieldMetadata.reduce<string[]>((acc, x) => {
if (!x.isEcsCompliant && x.type !== x.indexFieldType && x.isInSameFamily) {
const field = escape(x.indexFieldName);
if (field != null) {
return [...acc, field];

View file

@ -191,6 +191,7 @@ export type DataQualityIndexCheckedParams = DataQualityCheckAllCompletedParams &
ilmPhase?: string;
indexId: string;
indexName: string;
sameFamilyFields?: string[];
unallowedMappingFields?: string[];
unallowedValueFields?: string[];
};
@ -203,6 +204,7 @@ export interface DataQualityCheckAllCompletedParams {
numberOfIncompatibleFields?: number;
numberOfIndices?: number;
numberOfIndicesChecked?: number;
numberOfSameFamily?: number;
sizeInBytes?: number;
timeConsumedMs?: number;
}

View file

@ -20,12 +20,13 @@ import {
} from './helpers';
import type { OnCheckCompleted, PatternRollup } from '../types';
import { getDocsCount, getIndexId, getSizeInBytes } from '../helpers';
import { getDocsCount, getIndexId, getSizeInBytes, getTotalPatternSameFamily } from '../helpers';
import { getIlmPhase, getIndexIncompatible } from '../data_quality_panel/pattern/helpers';
import { useDataQualityContext } from '../data_quality_panel/data_quality_context';
import {
getIncompatibleMappingsFields,
getIncompatibleValuesFields,
getSameFamilyFields,
} from '../data_quality_panel/tabs/incompatible_tab/helpers';
interface Props {
@ -134,6 +135,8 @@ export const useResultsRollup = ({ ilmPhases, patterns }: Props): UseResultsRoll
}),
numberOfIndices: 1,
numberOfIndicesChecked: 1,
numberOfSameFamily: getTotalPatternSameFamily(updated[pattern].results),
sameFamilyFields: getSameFamilyFields(partitionedFieldMetadata.sameFamily),
sizeInBytes: getSizeInBytes({ stats: updated[pattern].stats, indexName }),
timeConsumedMs: requestTime,
unallowedMappingFields: getIncompatibleMappingsFields(
@ -154,6 +157,7 @@ export const useResultsRollup = ({ ilmPhases, patterns }: Props): UseResultsRoll
numberOfIncompatibleFields: getTotalIncompatible(updated),
numberOfIndices: getTotalIndices(updated),
numberOfIndicesChecked: getTotalIndicesChecked(updated),
numberOfSameFamily: getTotalSameFamily(updated),
sizeInBytes: getTotalSizeInBytes(updated),
timeConsumedMs: Date.now() - checkAllStartTime,
});

View file

@ -49,6 +49,13 @@ export const dataQualityIndexCheckedEvent: DataQualityTelemetryIndexCheckedEvent
optional: true,
},
},
numberOfSameFamily: {
type: 'integer',
_meta: {
description: 'Number of same family',
optional: true,
},
},
timeConsumedMs: {
type: 'integer',
_meta: {
@ -98,6 +105,15 @@ export const dataQualityIndexCheckedEvent: DataQualityTelemetryIndexCheckedEvent
optional: true,
},
},
sameFamilyFields: {
type: 'array',
items: {
type: 'keyword',
_meta: {
description: 'Same Family fields',
},
},
},
unallowedMappingFields: {
type: 'array',
items: {
@ -150,6 +166,13 @@ export const dataQualityCheckAllClickedEvent: DataQualityTelemetryCheckAllComple
optional: true,
},
},
numberOfSameFamily: {
type: 'integer',
_meta: {
description: 'Number of same family',
optional: true,
},
},
timeConsumedMs: {
type: 'integer',
_meta: {

View file

@ -13,6 +13,7 @@ export type ReportDataQualityIndexCheckedParams = ReportDataQualityCheckAllCompl
ilmPhase?: string;
indexId: string;
indexName: string;
sameFamilyFields?: string[];
unallowedMappingFields?: string[];
unallowedValueFields?: string[];
};
@ -25,6 +26,7 @@ export interface ReportDataQualityCheckAllCompletedParams {
numberOfIncompatibleFields?: number;
numberOfIndices?: number;
numberOfIndicesChecked?: number;
numberOfSameFamily?: number;
sizeInBytes?: number;
timeConsumedMs?: number;
}