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] Reorganise log rate anomaly table #69516

Merged
merged 39 commits into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f72104c
Remove top level chart
Kerry350 Jun 17, 2020
6ea5ee2
Merge remote-tracking branch 'upstream/master' into 63671-reorganise-…
Kerry350 Jun 18, 2020
b598852
Refactor table columns to accomodate new formatting
Kerry350 Jun 18, 2020
235c398
Tyical vs actual stats in expanded row
Kerry350 Jun 18, 2020
1ad7dd7
Format message based on actual vs typical
Kerry350 Jun 18, 2020
f78d229
Start fleshing out log rate examples endpoint and lib methods
Kerry350 Jun 18, 2020
2b55cd4
Merge remote-tracking branch 'upstream/master' into 63671-reorganise-…
Kerry350 Jun 23, 2020
522366b
Use the real document ID for expanded rows so React doesn't re-render…
Kerry350 Jun 23, 2020
de366dc
Add all data fetching resources for log entry rate examples
Kerry350 Jun 24, 2020
7e9df21
Move log entry example and severity indicator components to a shared …
Kerry350 Jun 24, 2020
5b31c9a
Render examples for log rate
Kerry350 Jun 24, 2020
c3bc1c4
Add severity indicator
Kerry350 Jun 24, 2020
f9b598a
Styling tweaks
Kerry350 Jun 24, 2020
36ddaca
Merge remote-tracking branch 'upstream/master' into 63671-reorganise-…
Kerry350 Jun 25, 2020
f80db59
Move horizontal button popover menu to a shared components so log rat…
Kerry350 Jun 25, 2020
155fe0e
Revert "Move horizontal button popover menu to a shared components so…
Kerry350 Jun 25, 2020
a6bb35b
Add "view in stream" and "view in anomaly explorer" links
Kerry350 Jun 25, 2020
358632e
Merge remote-tracking branch 'upstream/master' into 63671-reorganise-…
Kerry350 Jun 25, 2020
8469d0f
Hook links into the new context menu component
Kerry350 Jun 25, 2020
eb6d271
Add log column headers and add styling tweaks etc
Kerry350 Jun 26, 2020
0e8e361
Fix translations
Kerry350 Jun 29, 2020
abe456d
Tweak comments
Kerry350 Jun 29, 2020
5fc4b34
Merge remote-tracking branch 'upstream/master' into 63671-reorganise-…
Kerry350 Jun 29, 2020
0cbcadb
Merge remote-tracking branch 'upstream/master' into 63671-reorganise-…
Kerry350 Jun 29, 2020
d2e715e
Chart tweaks
Kerry350 Jun 29, 2020
ab5dccf
Merge remote-tracking branch 'upstream/master' into 63671-reorganise-…
Kerry350 Jul 2, 2020
e1a826f
Update x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections…
Kerry350 Jul 2, 2020
4df9d12
PR amendments
Kerry350 Jul 2, 2020
5b73fcc
Merge branch '63671-reorganise-log-rate-table' of github.com:Kerry350…
Kerry350 Jul 2, 2020
fe1cf57
Update x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections…
Kerry350 Jul 2, 2020
1073814
Update x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections…
Kerry350 Jul 2, 2020
feda663
Update x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections…
Kerry350 Jul 2, 2020
e13df39
Update x-pack/plugins/infra/public/pages/logs/log_entry_rate/sections…
Kerry350 Jul 2, 2020
84d0aee
Update x-pack/plugins/infra/server/routes/log_analysis/results/log_en…
Kerry350 Jul 2, 2020
f7a3760
Update x-pack/plugins/infra/server/routes/log_analysis/results/log_en…
Kerry350 Jul 2, 2020
7ef1f83
Update x-pack/plugins/infra/server/routes/log_analysis/results/log_en…
Kerry350 Jul 2, 2020
5b06276
Update x-pack/plugins/infra/server/routes/log_analysis/results/log_en…
Kerry350 Jul 2, 2020
390ecdd
PR amendments
Kerry350 Jul 2, 2020
eea486c
Merge remote-tracking branch 'upstream/master' into 63671-reorganise-…
Kerry350 Jul 3, 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,3 +8,4 @@ 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';
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ export type GetLogEntryRateRequestPayload = rt.TypeOf<typeof getLogEntryRateRequ
*/

export const logEntryRateAnomalyRT = rt.type({
id: rt.string,
actualLogEntryRate: rt.number,
anomalyScore: rt.number,
duration: rt.number,
startTime: rt.number,
typicalLogEntryRate: rt.number,
});

export type LogEntryRateAnomaly = rt.TypeOf<typeof logEntryRateAnomalyRT>;

export const logEntryRatePartitionRT = rt.type({
analysisBucketCount: rt.number,
anomalies: rt.array(logEntryRateAnomalyRT),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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_RATE_EXAMPLES_PATH =
'/api/infra/log_analysis/results/log_entry_rate_examples';

/**
* request
*/

export const getLogEntryRateExamplesRequestPayloadRT = rt.type({
data: rt.type({
// the dataset to fetch the log rate examples from
dataset: rt.string,
// the number of examples to fetch
exampleCount: rt.number,
// the id of the source configuration
sourceId: rt.string,
// the time range to fetch the log rate examples from
timeRange: timeRangeRT,
}),
});

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

/**
* response
*/

const logEntryRateExampleRT = 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 const getLogEntryRateExamplesSuccessReponsePayloadRT = rt.intersection([
rt.type({
data: rt.type({
examples: rt.array(logEntryRateExampleRT),
}),
}),
rt.partial({
timing: routeTimingMetadataRT,
}),
]);

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

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

export type GetLogEntryRateExamplesResponsePayload = rt.TypeOf<
typeof getLogEntryRateExamplesResponsePayloadRT
>;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
formatAnomalyScore,
getSeverityCategoryForScore,
ML_SEVERITY_COLORS,
} from '../../../../../../common/log_analysis';
} from '../../../../common/log_analysis';

export const AnomalySeverityIndicator: React.FunctionComponent<{
anomalyScore: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 React from 'react';

import { euiStyled } from '../../../../../observability/public';
import { LogEntryExampleMessagesEmptyIndicator } from './log_entry_examples_empty_indicator';
import { LogEntryExampleMessagesFailureIndicator } from './log_entry_examples_failure_indicator';
import { LogEntryExampleMessagesLoadingIndicator } from './log_entry_examples_loading_indicator';

interface Props {
isLoading: boolean;
hasFailedLoading: boolean;
hasResults: boolean;
exampleCount: number;
onReload: () => void;
}
export const LogEntryExampleMessages: React.FunctionComponent<Props> = ({
isLoading,
hasFailedLoading,
exampleCount,
hasResults,
onReload,
children,
}) => {
return (
<Wrapper>
{isLoading ? (
<LogEntryExampleMessagesLoadingIndicator exampleCount={exampleCount} />
) : hasFailedLoading ? (
<LogEntryExampleMessagesFailureIndicator onRetry={onReload} />
) : !hasResults ? (
<LogEntryExampleMessagesEmptyIndicator onReload={onReload} />
) : (
children
)}
</Wrapper>
);
};

const Wrapper = euiStyled.div`
align-items: stretch;
flex-direction: column;
flex: 1 0 0%;
overflow: hidden;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';

export const CategoryExampleMessagesEmptyIndicator: React.FunctionComponent<{
export const LogEntryExampleMessagesEmptyIndicator: React.FunctionComponent<{
onReload: () => void;
}> = ({ onReload }) => (
<EuiFlexGroup alignItems="center" justifyContent="center">
<EuiFlexItem grow={false} className="eui-textNoWrap">
<FormattedMessage
id="xpack.infra.logs.logEntryCategories.exampleEmptyDescription"
id="xpack.infra.logs.logEntryExamples.exampleEmptyDescription"
defaultMessage="No examples found within the selected time range. Increase the log entry retention period to improve message sample availability."
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton onClick={onReload} size="s">
<FormattedMessage
id="xpack.infra.logs.logEntryCategories.exampleEmptyReloadButtonLabel"
id="xpack.infra.logs.logEntryExamples.exampleEmptyReloadButtonLabel"
defaultMessage="Reload"
/>
</EuiButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiTextColor } from '@elastic/eui
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';

export const CategoryExampleMessagesFailureIndicator: React.FunctionComponent<{
export const LogEntryExampleMessagesFailureIndicator: React.FunctionComponent<{
onRetry: () => void;
}> = ({ onRetry }) => (
<EuiFlexGroup alignItems="center" justifyContent="center">
<EuiFlexItem grow={false} className="eui-textNoWrap">
<EuiTextColor color="danger">
<FormattedMessage
id="xpack.infra.logs.logEntryCategories.exampleLoadingFailureDescription"
defaultMessage="Failed to load category examples."
id="xpack.infra.logs.logEntryExamples.exampleLoadingFailureDescription"
defaultMessage="Failed to load examples."
/>
</EuiTextColor>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton onClick={onRetry} size="s">
<FormattedMessage
id="xpack.infra.logs.logEntryCategories.exampleLoadingFailureRetryButtonLabel"
id="xpack.infra.logs.logEntryExamples.exampleLoadingFailureRetryButtonLabel"
defaultMessage="Retry"
/>
</EuiButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { EuiLoadingContent } from '@elastic/eui';
import React from 'react';

export const CategoryExampleMessagesLoadingIndicator: React.FunctionComponent<{
export const LogEntryExampleMessagesLoadingIndicator: React.FunctionComponent<{
exampleCount: number;
}> = ({ exampleCount }) => (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const LogColumnHeaders: React.FunctionComponent<{
);
};

const LogColumnHeader: React.FunctionComponent<{
export const LogColumnHeader: React.FunctionComponent<{
columnWidth: LogEntryColumnWidth;
'data-test-subj'?: string;
}> = ({ children, columnWidth, 'data-test-subj': dataTestSubj }) => (
Expand All @@ -77,7 +77,7 @@ const LogColumnHeader: React.FunctionComponent<{
</LogColumnHeaderWrapper>
);

const LogColumnHeadersWrapper = euiStyled.div.attrs((props) => ({
export const LogColumnHeadersWrapper = euiStyled.div.attrs((props) => ({
role: props.role ?? 'row',
}))`
align-items: stretch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { LogEntryColumn, LogEntryColumnWidths, useColumnWidths } from './log_entry_column';
export {
LogEntryColumn,
LogEntryColumnWidths,
useColumnWidths,
iconColumnId,
} from './log_entry_column';
export { LogEntryFieldColumn } from './log_entry_field_column';
export { LogEntryMessageColumn } from './log_entry_message_column';
export { LogEntryRowWrapper } from './log_entry_row';
export { LogEntryTimestampColumn } from './log_entry_timestamp_column';
export { ScrollableLogTextStreamView } from './scrollable_log_text_stream_view';
export { LogEntryContextMenu } from './log_entry_context_menu';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { LogEntryColumnContent } from './log_entry_column';

interface LogEntryContextMenuItem {
label: string;
onClick: () => void;
onClick: (e: React.MouseEvent) => void;
href?: string;
}

interface LogEntryContextMenuProps {
Expand All @@ -40,9 +41,9 @@ export const LogEntryContextMenu: React.FC<LogEntryContextMenuProps> = ({
}) => {
const closeMenuAndCall = useMemo(() => {
return (callback: LogEntryContextMenuItem['onClick']) => {
return () => {
return (e: React.MouseEvent) => {
onClose();
callback();
callback(e);
};
};
}, [onClose]);
Expand All @@ -60,7 +61,7 @@ export const LogEntryContextMenu: React.FC<LogEntryContextMenuProps> = ({

const wrappedItems = useMemo(() => {
return items.map((item, i) => (
<EuiContextMenuItem key={i} onClick={closeMenuAndCall(item.onClick)}>
<EuiContextMenuItem key={i} onClick={closeMenuAndCall(item.onClick)} href={item.href}>
{item.label}
</EuiContextMenuItem>
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react';

import { LogEntryCategoryDataset } from '../../../../../../common/http_api/log_analysis';
import { getFriendlyNameForPartitionId } from '../../../../../../common/log_analysis';
import { AnomalySeverityIndicator } from './anomaly_severity_indicator';
import { AnomalySeverityIndicator } from '../../../../../components/logging/log_analysis_results/anomaly_severity_indicator';

export const AnomalySeverityIndicatorList: React.FunctionComponent<{
datasets: LogEntryCategoryDataset[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
*/

import React, { useEffect } from 'react';

import { euiStyled } from '../../../../../../../observability/public';
import { TimeRange } from '../../../../../../common/http_api/shared';
import { useLogEntryCategoryExamples } from '../../use_log_entry_category_examples';
import { LogEntryExampleMessages } from '../../../../../components/logging/log_entry_examples/log_entry_examples';
import { TimeRange } from '../../../../../../common/http_api/shared';
import { CategoryExampleMessage } from './category_example_message';
import { CategoryExampleMessagesEmptyIndicator } from './category_example_messages_empty_indicator';
import { CategoryExampleMessagesFailureIndicator } from './category_example_messages_failure_indicator';
import { CategoryExampleMessagesLoadingIndicator } from './category_example_messages_loading_indicator';

const exampleCount = 5;

Expand All @@ -39,30 +35,21 @@ export const CategoryDetailsRow: React.FunctionComponent<{
}, [getLogEntryCategoryExamples]);

return (
<CategoryExampleMessages>
{isLoadingLogEntryCategoryExamples ? (
<CategoryExampleMessagesLoadingIndicator exampleCount={exampleCount} />
) : hasFailedLoadingLogEntryCategoryExamples ? (
<CategoryExampleMessagesFailureIndicator onRetry={getLogEntryCategoryExamples} />
) : logEntryCategoryExamples.length === 0 ? (
<CategoryExampleMessagesEmptyIndicator onReload={getLogEntryCategoryExamples} />
) : (
logEntryCategoryExamples.map((categoryExample, categoryExampleIndex) => (
<CategoryExampleMessage
dataset={categoryExample.dataset}
key={categoryExampleIndex}
message={categoryExample.message}
timestamp={categoryExample.timestamp}
/>
))
)}
</CategoryExampleMessages>
<LogEntryExampleMessages
isLoading={isLoadingLogEntryCategoryExamples}
hasFailedLoading={hasFailedLoadingLogEntryCategoryExamples}
hasResults={logEntryCategoryExamples.length > 0}
exampleCount={exampleCount}
onReload={getLogEntryCategoryExamples}
>
{logEntryCategoryExamples.map((example, exampleIndex) => (
<CategoryExampleMessage
key={exampleIndex}
dataset={example.dataset}
message={example.message}
timestamp={example.timestamp}
/>
))}
</LogEntryExampleMessages>
);
};

const CategoryExampleMessages = euiStyled.div`
align-items: stretch;
flex-direction: column;
flex: 1 0 0%;
overflow: hidden;
`;
Loading