Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logs UI] Anomalies page dataset filtering #71110

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fbed94b
Add category anomalies to anomalies page
Kerry350 Jun 30, 2020
f585973
node scripts/i18n_check --fix
Kerry350 Jul 8, 2020
216cc9e
Add dataset filtering to the anomalies page
Kerry350 Jul 8, 2020
55f6d3f
Fix typecheck issues
Kerry350 Jul 9, 2020
9ab603f
Update x-pack/plugins/infra/common/http_api/log_analysis/results/log_…
Kerry350 Jul 9, 2020
27b63a2
Update x-pack/plugins/infra/common/http_api/log_analysis/results/log_…
Kerry350 Jul 9, 2020
ce78758
Update x-pack/plugins/infra/common/http_api/log_analysis/results/log_…
Kerry350 Jul 9, 2020
96ef88b
Update x-pack/plugins/infra/common/http_api/log_analysis/results/log_…
Kerry350 Jul 9, 2020
926feed
Update x-pack/plugins/infra/common/http_api/log_analysis/results/log_…
Kerry350 Jul 9, 2020
9cc61f2
Update x-pack/plugins/infra/common/http_api/log_analysis/results/log_…
Kerry350 Jul 9, 2020
c700591
Update x-pack/plugins/infra/common/http_api/log_analysis/results/log_…
Kerry350 Jul 9, 2020
0f919ee
Add aria labels
Kerry350 Jul 9, 2020
23346a3
Amend pluralisation on variables and fix useEffect dependency
Kerry350 Jul 9, 2020
c540e33
Ensure category anomlies fetch examples relevant to the category
Kerry350 Jul 9, 2020
d84a7f9
Refine loading states etc
Kerry350 Jul 9, 2020
0686810
Update x-pack/plugins/infra/public/components/loading_overlay_wrapper…
weltenwort Jul 10, 2020
4ff5799
Merge branch 'master' into 64755-expand-anomalies-page-to-add-categories
elasticmachine Jul 10, 2020
9d919fd
Merge remote-tracking branch 'upstream/master' into 64755-expand-anom…
Kerry350 Jul 13, 2020
9a95520
Move anomalies hook state over to a reducer for better clarity and bu…
Kerry350 Jul 13, 2020
0453295
Merge branch '64755-expand-anomalies-page-to-add-categories' of githu…
Kerry350 Jul 13, 2020
27ef241
Change conditional handling
Kerry350 Jul 13, 2020
578f80c
Account for the fact dataset may not exist
Kerry350 Jul 13, 2020
53eff11
Update x-pack/plugins/infra/server/routes/log_analysis/results/log_en…
Kerry350 Jul 13, 2020
34e92a9
Merge branch '64755-expand-anomalies-page-to-add-categories' of githu…
Kerry350 Jul 13, 2020
f2e44e6
Extract variable from common
Kerry350 Jul 13, 2020
1dd7c03
Update x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomali…
Kerry350 Jul 13, 2020
c4f8725
Merge branch '64755-expand-anomalies-page-to-add-categories' of githu…
Kerry350 Jul 13, 2020
fbf5c09
Update x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomali…
Kerry350 Jul 13, 2020
0e5441b
Merge branch '64755-expand-anomalies-page-to-add-categories' of githu…
Kerry350 Jul 13, 2020
a2c1d2f
Update x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections…
Kerry350 Jul 13, 2020
9198baf
Merge branch '64755-expand-anomalies-page-to-add-categories' of githu…
Kerry350 Jul 13, 2020
51a1936
Amend message handling
Kerry350 Jul 13, 2020
ec0152c
Wrap no data state with a loading overlay wrapper
Kerry350 Jul 13, 2020
751ae96
Merge remote-tracking branch 'upstream/master' into 64755-expand-anom…
Kerry350 Jul 13, 2020
706239b
Ensure expanded rows extract their job id from the anomaly record
Kerry350 Jul 13, 2020
c5b2243
Update variable naming
Kerry350 Jul 13, 2020
f95947b
Amend i18n syntax
Kerry350 Jul 13, 2020
99a3e50
Ensure category is passed to category links
Kerry350 Jul 13, 2020
298b66d
Commit
Kerry350 Jul 13, 2020
6cc04bb
Appease eslint
Kerry350 Jul 13, 2020
2524277
Merge branch '64755-expand-anomalies-page-to-add-categories' into 710…
Kerry350 Jul 13, 2020
d3a9380
Change conditional syntax
Kerry350 Jul 13, 2020
47b17de
Add LoadingOverlayContent back for improved accessbility
Kerry350 Jul 13, 2020
667f9c9
node scripts/i18n_check --fix
Kerry350 Jul 13, 2020
f159057
Merge branch '64755-expand-anomalies-page-to-add-categories' into 710…
Kerry350 Jul 13, 2020
cc546d3
Use decodeOrThrow
Kerry350 Jul 13, 2020
0ec814e
Rework dataset filtering in with new reducer based hook state
Kerry350 Jul 13, 2020
2aef2f5
Merge remote-tracking branch 'upstream/master' into 71063-add-dataset…
Kerry350 Jul 13, 2020
2a7e384
Merge branch 'master' into 71063-add-dataset-filtering-to-anomalies-page
elasticmachine Jul 13, 2020
56cd384
i18n --fix
Kerry350 Jul 13, 2020
916ae3d
Merge branch '71063-add-dataset-filtering-to-anomalies-page' of githu…
Kerry350 Jul 13, 2020
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 @@ -8,4 +8,6 @@ export * from './log_entry_categories';
export * from './log_entry_category_datasets';
export * from './log_entry_category_examples';
export * from './log_entry_rate';
export * from './log_entry_rate_examples';
export * from './log_entry_examples';
export * from './log_entry_anomalies';
export * from './log_entry_anomalies_datasets';
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import * as rt from 'io-ts';

import { timeRangeRT, routeTimingMetadataRT } from '../../shared';

export const LOG_ANALYSIS_GET_LOG_ENTRY_ANOMALIES_PATH =
'/api/infra/log_analysis/results/log_entry_anomalies';

// [Sort field value, tiebreaker value]
const paginationCursorRT = rt.tuple([
rt.union([rt.string, rt.number]),
rt.union([rt.string, rt.number]),
]);

export type PaginationCursor = rt.TypeOf<typeof paginationCursorRT>;

const logRateAnomalyTypeRT = rt.literal('logRate');
const logCategorisationAnomalyTypeRT = rt.literal('logCategory');
export const anomalyTypeRT = rt.union([logRateAnomalyTypeRT, logCategorisationAnomalyTypeRT]);

const logEntryAnomalyRT = rt.type({
id: rt.string,
anomalyScore: rt.number,
dataset: rt.string,
typical: rt.number,
actual: rt.number,
type: anomalyTypeRT,
duration: rt.number,
startTime: rt.number,
});

export type LogEntryAnomaly = rt.TypeOf<typeof logEntryAnomalyRT>;

export const getLogEntryAnomaliesSuccessReponsePayloadRT = rt.intersection([
rt.type({
data: rt.intersection([
rt.type({
anomalies: rt.array(logEntryAnomalyRT),
// Signifies there are more entries backwards or forwards. If this was a request
// for a previous page, there are more previous pages, if this was a request for a next page,
// there are more next pages.
hasMoreEntries: rt.boolean,
}),
rt.partial({
paginationCursors: rt.type({
// The cursor to use to fetch the previous page
previousPageCursor: paginationCursorRT,
// The cursor to use to fetch the next page
nextPageCursor: paginationCursorRT,
}),
}),
]),
}),
rt.partial({
timing: routeTimingMetadataRT,
}),
]);

export type GetLogEntryAnomaliesSuccessResponsePayload = rt.TypeOf<
typeof getLogEntryAnomaliesSuccessReponsePayloadRT
>;

const sortOptions = rt.union([
rt.literal('anomalyScore'),
rt.literal('dataset'),
rt.literal('startTime'),
]);

const sortDirections = rt.union([rt.literal('asc'), rt.literal('desc')]);

const paginationPreviousPageCursor = rt.type({
searchBefore: paginationCursorRT,
});

const paginationNextPageCursor = rt.type({
searchAfter: paginationCursorRT,
});

const paginationRT = rt.intersection([
rt.type({
pageSize: rt.number,
}),
rt.partial({
cursor: rt.union([paginationPreviousPageCursor, paginationNextPageCursor]),
}),
]);

export type Pagination = rt.TypeOf<typeof paginationRT>;

const sortRT = rt.type({
field: sortOptions,
direction: sortDirections,
});

export type Sort = rt.TypeOf<typeof sortRT>;

export const getLogEntryAnomaliesRequestPayloadRT = rt.type({
data: rt.intersection([
rt.type({
// the ID of the source configuration
sourceId: rt.string,
// the time range to fetch the log entry anomalies from
timeRange: timeRangeRT,
}),
rt.partial({
// Pagination properties
pagination: paginationRT,
// Sort properties
sort: sortRT,
// Dataset filters
datasets: rt.array(rt.string),
}),
]),
});

export type GetLogEntryAnomaliesRequestPayload = rt.TypeOf<
typeof getLogEntryAnomaliesRequestPayloadRT
>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import * as rt from 'io-ts';

import {
badRequestErrorRT,
forbiddenErrorRT,
timeRangeRT,
routeTimingMetadataRT,
} from '../../shared';

export const LOG_ANALYSIS_GET_LOG_ENTRY_ANOMALIES_DATASETS_PATH =
'/api/infra/log_analysis/results/log_entry_anomalies_datasets';

/**
* request
*/

export const getLogEntryAnomaliesDatasetsRequestPayloadRT = rt.type({
data: rt.type({
// the id of the source configuration
sourceId: rt.string,
// the time range to fetch the anomalies datasets from
timeRange: timeRangeRT,
}),
});

export type GetLogEntryAnomaliesDatasetsRequestPayload = rt.TypeOf<
typeof getLogEntryAnomaliesDatasetsRequestPayloadRT
>;

/**
* response
*/

export const getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT = rt.intersection([
rt.type({
data: rt.type({
datasets: rt.array(rt.string),
}),
}),
rt.partial({
timing: routeTimingMetadataRT,
}),
]);

export type GetLogEntryAnomaliesDatasetsSuccessResponsePayload = rt.TypeOf<
typeof getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT
>;

export const getLogEntryAnomaliesDatasetsResponsePayloadRT = rt.union([
getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT,
badRequestErrorRT,
forbiddenErrorRT,
]);

export type GetLogEntryAnomaliesDatasetsReponsePayload = rt.TypeOf<
typeof getLogEntryAnomaliesDatasetsResponsePayloadRT
>;
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import {
} from '../../shared';

export const LOG_ANALYSIS_GET_LOG_ENTRY_RATE_EXAMPLES_PATH =
'/api/infra/log_analysis/results/log_entry_rate_examples';
'/api/infra/log_analysis/results/log_entry_examples';

/**
* request
*/

export const getLogEntryRateExamplesRequestPayloadRT = rt.type({
export const getLogEntryExamplesRequestPayloadRT = rt.type({
data: rt.type({
// the dataset to fetch the log rate examples from
dataset: rt.string,
Expand All @@ -33,45 +33,45 @@ export const getLogEntryRateExamplesRequestPayloadRT = rt.type({
}),
});

export type GetLogEntryRateExamplesRequestPayload = rt.TypeOf<
typeof getLogEntryRateExamplesRequestPayloadRT
export type GetLogEntryExamplesRequestPayload = rt.TypeOf<
typeof getLogEntryExamplesRequestPayloadRT
>;

/**
* response
*/

const logEntryRateExampleRT = rt.type({
const logEntryExampleRT = rt.type({
id: rt.string,
dataset: rt.string,
message: rt.string,
timestamp: rt.number,
tiebreaker: rt.number,
});

export type LogEntryRateExample = rt.TypeOf<typeof logEntryRateExampleRT>;
export type LogEntryExample = rt.TypeOf<typeof logEntryExampleRT>;

export const getLogEntryRateExamplesSuccessReponsePayloadRT = rt.intersection([
export const getLogEntryExamplesSuccessReponsePayloadRT = rt.intersection([
rt.type({
data: rt.type({
examples: rt.array(logEntryRateExampleRT),
examples: rt.array(logEntryExampleRT),
}),
}),
rt.partial({
timing: routeTimingMetadataRT,
}),
]);

export type GetLogEntryRateExamplesSuccessReponsePayload = rt.TypeOf<
typeof getLogEntryRateExamplesSuccessReponsePayloadRT
export type GetLogEntryExamplesSuccessReponsePayload = rt.TypeOf<
typeof getLogEntryExamplesSuccessReponsePayloadRT
>;

export const getLogEntryRateExamplesResponsePayloadRT = rt.union([
getLogEntryRateExamplesSuccessReponsePayloadRT,
export const getLogEntryExamplesResponsePayloadRT = rt.union([
getLogEntryExamplesSuccessReponsePayloadRT,
badRequestErrorRT,
forbiddenErrorRT,
]);

export type GetLogEntryRateExamplesResponsePayload = rt.TypeOf<
typeof getLogEntryRateExamplesResponsePayloadRT
export type GetLogEntryExamplesResponsePayload = rt.TypeOf<
typeof getLogEntryExamplesResponsePayloadRT
>;
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ export const LOG_ANALYSIS_GET_LOG_ENTRY_RATE_PATH =
*/

export const getLogEntryRateRequestPayloadRT = rt.type({
data: rt.type({
bucketDuration: rt.number,
sourceId: rt.string,
timeRange: timeRangeRT,
}),
data: rt.intersection([
rt.type({
bucketDuration: rt.number,
sourceId: rt.string,
timeRange: timeRangeRT,
}),
rt.partial({
datasets: rt.array(rt.string),
}),
]),
});

export type GetLogEntryRateRequestPayload = rt.TypeOf<typeof getLogEntryRateRequestPayloadRT>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const formatAnomalyScore = (score: number) => {
return Math.round(score);
};

export const formatOneDecimalPlace = (number: number) => {
return Math.round(number * 10) / 10;
};

export const getFriendlyNameForPartitionId = (partitionId: string) => {
return partitionId !== '' ? partitionId : 'unknown';
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useCallback, useMemo } from 'react';

import { getFriendlyNameForPartitionId } from '../../../../../../common/log_analysis';
import { getFriendlyNameForPartitionId } from '../../../../common/log_analysis';

type DatasetOptionProps = EuiComboBoxOptionOption<string>;

Expand Down Expand Up @@ -51,7 +51,7 @@ export const DatasetsSelector: React.FunctionComponent<{
};

const datasetFilterPlaceholder = i18n.translate(
'xpack.infra.logs.logEntryCategories.datasetFilterPlaceholder',
'xpack.infra.logs.analysis.datasetFilterPlaceholder',
{
defaultMessage: 'Filter by datasets',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { BetaBadge } from '../../../../../components/beta_badge';
import { LoadingOverlayWrapper } from '../../../../../components/loading_overlay_wrapper';
import { RecreateJobButton } from '../../../../../components/logging/log_analysis_job_status';
import { AnalyzeInMlButton } from '../../../../../components/logging/log_analysis_results';
import { DatasetsSelector } from './datasets_selector';
import { DatasetsSelector } from '../../../../../components/logging/log_analysis_results/datasets_selector';
import { TopCategoriesTable } from './top_categories_table';

export const TopCategoriesSection: React.FunctionComponent<{
Expand Down
Loading