Skip to content

Commit

Permalink
add last check date column
Browse files Browse the repository at this point in the history
  • Loading branch information
semd committed Jan 29, 2024
1 parent 984f6d0 commit 199ea53
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ const IndexPropertiesComponent: React.FC<Props> = ({
markdownComments,
pattern,
sameFamily: indexSameFamily,
checkedAt: Date.now(),
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export const getSummaryTableItems = ({
pattern,
patternDocsCount,
sizeInBytes: getSizeInBytes({ stats, indexName }),
checkedAt: results?.[indexName]?.checkedAt,
}));

return orderBy([sortByColumn], [sortByDirection], summaryTableItems);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ describe('helpers', () => {
pattern: 'auditbeat-*',
patternDocsCount: 57410,
sizeInBytes: 103344068,
checkedAt: Date.now(),
};

const hasIncompatible: IndexSummaryTableItem = {
Expand Down Expand Up @@ -188,6 +189,7 @@ describe('helpers', () => {
},
{ field: 'ilmPhase', name: 'ILM Phase', sortable: true, truncateText: false },
{ field: 'sizeInBytes', name: 'Size', sortable: true, truncateText: false },
{ field: 'checkedAt', name: 'Last check', sortable: true, truncateText: false },
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* 2.0.
*/

import type { EuiBasicTableColumn } from '@elastic/eui';
import {
EuiBasicTableColumn,
EuiText,
EuiBadge,
EuiButtonIcon,
EuiIcon,
Expand All @@ -17,6 +18,7 @@ import {
RIGHT_ALIGNMENT,
} from '@elastic/eui';
import React from 'react';
import moment from 'moment';
import styled from 'styled-components';

import { EMPTY_STAT, getIlmPhaseDescription, getIncompatibleStatColor } from '../../helpers';
Expand All @@ -41,6 +43,7 @@ export interface IndexSummaryTableItem {
pattern: string;
patternDocsCount: number;
sizeInBytes: number;
checkedAt: number | undefined;
}

export const getResultToolTip = (incompatible: number | undefined): string => {
Expand Down Expand Up @@ -237,6 +240,17 @@ export const getSummaryTableColumns = ({
sortable: true,
truncateText: false,
},
{
field: 'checkedAt',
name: i18n.LAST_CHECK,
render: (_, { checkedAt }) => (
<EuiText size="xs">
{moment(checkedAt).isValid() ? moment(checkedAt).fromNow() : EMPTY_STAT}
</EuiText>
),
sortable: true,
truncateText: false,
},
];

export const getShowPagination = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export const SIZE = i18n.translate(
}
);

export const LAST_CHECK = i18n.translate(
'securitySolutionPackages.ecsDataQualityDashboard.summaryTable.lastCheckColumn',
{
defaultMessage: 'Last check',
}
);

export const THIS_INDEX_HAS_NOT_BEEN_CHECKED = i18n.translate(
'securitySolutionPackages.ecsDataQualityDashboard.summaryTable.thisIndexHasNotBeenCheckedTooltip',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe('helpers', () => {
],
pattern: 'auditbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
};

it('returns undefined when results is undefined', () => {
Expand Down Expand Up @@ -1193,6 +1194,7 @@ describe('helpers', () => {
markdownComments: ['foo', 'bar', 'baz'],
pattern: 'packetbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
},
'.ds-packetbeat-8.6.1-2023.02.04-000001': {
docsCount: 1628343,
Expand All @@ -1203,6 +1205,7 @@ describe('helpers', () => {
markdownComments: ['foo', 'bar', 'baz'],
pattern: 'packetbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
},
};

Expand All @@ -1220,6 +1223,7 @@ describe('helpers', () => {
markdownComments: ['foo', 'bar', 'baz'],
pattern: 'auditbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
},
'auditbeat-custom-index-1': {
docsCount: 4,
Expand All @@ -1230,6 +1234,7 @@ describe('helpers', () => {
markdownComments: ['foo', 'bar', 'baz'],
pattern: 'auditbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
},
'auditbeat-custom-empty-index-1': {
docsCount: 0,
Expand All @@ -1240,6 +1245,7 @@ describe('helpers', () => {
markdownComments: ['foo', 'bar', 'baz'],
pattern: 'auditbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
},
};

Expand All @@ -1257,6 +1263,7 @@ describe('helpers', () => {
markdownComments: ['foo', 'bar', 'baz'],
pattern: 'auditbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
},
'auditbeat-custom-index-1': {
docsCount: 4,
Expand All @@ -1267,6 +1274,7 @@ describe('helpers', () => {
markdownComments: ['foo', 'bar', 'baz'],
pattern: 'auditbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
},
'auditbeat-custom-empty-index-1': {
docsCount: 0,
Expand All @@ -1277,6 +1285,7 @@ describe('helpers', () => {
markdownComments: ['foo', 'bar', 'baz'],
pattern: 'auditbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
},
};

Expand Down Expand Up @@ -1342,6 +1351,7 @@ describe('helpers', () => {
markdownComments: ['foo', 'bar', 'baz'],
pattern: 'packetbeat-*',
sameFamily: 0,
checkedAt: Date.now(),
};

expect(getErrorSummary(resultWithError)).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export interface StorageResult {
batchId: string;
indexName: string;
isCheckAll: boolean;
checkedAt: number;
docsCount: number;
totalFieldCount: number;
ecsFieldCount: number;
Expand Down Expand Up @@ -483,6 +484,7 @@ export const formatStorageResult = ({
batchId: report.batchId,
indexName: result.indexName,
isCheckAll: report.isCheckAll,
checkedAt: result.checkedAt,
docsCount: result.docsCount ?? 0,
totalFieldCount: partitionedFieldMetadata.all.length,
ecsFieldCount: partitionedFieldMetadata.ecsCompliant.length,
Expand Down Expand Up @@ -514,6 +516,7 @@ export const formatResultFromStorage = ({
indexName: storageResult.indexName,
markdownComments: storageResult.markdownComments,
sameFamily: storageResult.sameFamilyFieldCount,
checkedAt: storageResult.checkedAt,
pattern,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export interface DataQualityCheckResult {
markdownComments: string[];
sameFamily: number | undefined;
pattern: string;
checkedAt: number;
}

export interface PatternRollup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const updateResultOnCheckCompleted = ({
markdownComments,
pattern,
sameFamily,
checkedAt: Date.now(),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const resultsFieldMap: FieldMap = {
batchId: { type: 'keyword', required: true },
indexName: { type: 'keyword', required: true },
isCheckAll: { type: 'boolean', required: true },
checkedAt: { type: 'date', required: true },
docsCount: { type: 'long', required: true },
totalFieldCount: { type: 'long', required: true },
ecsFieldCount: { type: 'long', required: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const resultDocument: ResultDocument = {
batchId: '33d95427-1fd3-43c3-bdeb-74324533a31e',
indexName: '.ds-logs-endpoint.alerts-default-2023.11.23-000001',
isCheckAll: false,
checkedAt: 1637673600000,
docsCount: 100,
totalFieldCount: 1582,
ecsFieldCount: 677,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const ResultDocument = t.type({
batchId: t.string,
indexName: t.string,
isCheckAll: t.boolean,
checkedAt: t.number,
docsCount: t.number,
totalFieldCount: t.number,
ecsFieldCount: t.number,
Expand Down

0 comments on commit 199ea53

Please sign in to comment.