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

[ML] Explain log rate spikes: Page setup #132121

Merged
merged 22 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
13f00df
[ML] Update menu structure.
walterra May 11, 2022
da6ddf3
[ML] Fix props.
walterra May 11, 2022
a51fc5a
[ML] Simplify shared components.
walterra May 11, 2022
3359ab4
[ML] Small lazy loading refactor.
walterra May 11, 2022
837c3d1
[ML] Refactor routes. Add new route for explaining log rate spikes.
walterra May 11, 2022
bec93fd
[ML] Improve stream fetch types. Fix actionBuffer. Restructure compon…
walterra May 12, 2022
d321c18
[ML] Fix lazy loading indicator.
walterra May 12, 2022
579a9df
[ML] Move reducer to its own file.
walterra May 12, 2022
c0d2e6c
[ML] Add index/saved-search chooser to explain log rate spikes page.
walterra May 12, 2022
c729619
[ML] API integration test for explain log rate spikes.
walterra May 12, 2022
6c8e89c
[ML] Fix cancelling request support after timeout.
walterra May 12, 2022
8492e81
[ML] Fix page title.
walterra May 12, 2022
c8eaa0a
[ML] Add support for gzip compressed streams.
walterra May 16, 2022
da5a423
[ML] Add comments to exports.
walterra May 16, 2022
b39c970
[ML] Fix breadcrumbs.
walterra May 16, 2022
3336818
[ML] Fix exports.
walterra May 16, 2022
c8e95df
Merge branch 'main' into ml-aiops-plugin-api
walterra May 16, 2022
08c920d
[ML] Add comments to lib functions.
walterra May 16, 2022
b7eadb4
[ML] Fix leading slash.
walterra May 16, 2022
d9dcba3
Merge branch 'main' into ml-aiops-plugin-api
walterra May 17, 2022
a6abf0e
[ML] Improve comments.
walterra May 17, 2022
bc2fe32
Merge branch 'main' into ml-aiops-plugin-api
walterra May 20, 2022
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
5 changes: 4 additions & 1 deletion x-pack/plugins/aiops/common/api/example_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ export function deleteEntityAction(payload: string): ApiActionDeleteEntity {
};
}

export type ApiAction = ApiActionUpdateProgress | ApiActionAddToEntity | ApiActionDeleteEntity;
export type AiopsExampleStreamApiAction =
| ApiActionUpdateProgress
| ApiActionAddToEntity
| ApiActionDeleteEntity;
34 changes: 34 additions & 0 deletions x-pack/plugins/aiops/common/api/explain_log_rate_spikes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { schema, TypeOf } from '@kbn/config-schema';

export const aiopsExplainLogRateSpikesSchema = schema.object({
/** The index to query for log rate spikes */
index: schema.string(),
});

export type AiopsExplainLogRateSpikesSchema = TypeOf<typeof aiopsExplainLogRateSpikesSchema>;

export const API_ACTION_NAME = {
ADD_FIELDS: 'add_fields',
} as const;
export type ApiActionName = typeof API_ACTION_NAME[keyof typeof API_ACTION_NAME];

interface ApiActionAddFields {
type: typeof API_ACTION_NAME.ADD_FIELDS;
payload: string[];
}

export function addFieldsAction(payload: string[]): ApiActionAddFields {
return {
type: API_ACTION_NAME.ADD_FIELDS,
payload,
};
}

export type AiopsExplainLogRateSpikesApiAction = ApiActionAddFields;
15 changes: 12 additions & 3 deletions x-pack/plugins/aiops/common/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@
* 2.0.
*/

import type { AiopsExampleStreamSchema } from './example_stream';
import type {
AiopsExplainLogRateSpikesSchema,
AiopsExplainLogRateSpikesApiAction,
} from './explain_log_rate_spikes';
import type { AiopsExampleStreamSchema, AiopsExampleStreamApiAction } from './example_stream';

export const API_ENDPOINT = {
EXAMPLE_STREAM: '/internal/aiops/example_stream',
ANOTHER: '/internal/aiops/another',
EXPLAIN_LOG_RATE_SPIKES: '/internal/aiops/explain_log_rate_spikes',
} as const;
export type ApiEndpoint = typeof API_ENDPOINT[keyof typeof API_ENDPOINT];

export interface ApiEndpointOptions {
[API_ENDPOINT.EXAMPLE_STREAM]: AiopsExampleStreamSchema;
[API_ENDPOINT.ANOTHER]: { anotherOption: string };
[API_ENDPOINT.EXPLAIN_LOG_RATE_SPIKES]: AiopsExplainLogRateSpikesSchema;
}

export interface ApiEndpointActions {
[API_ENDPOINT.EXAMPLE_STREAM]: AiopsExampleStreamApiAction;
[API_ENDPOINT.EXPLAIN_LOG_RATE_SPIKES]: AiopsExplainLogRateSpikesApiAction;
}
2 changes: 1 addition & 1 deletion x-pack/plugins/aiops/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"description": "AIOps plugin maintained by ML team.",
"server": true,
"ui": true,
"requiredPlugins": [],
"requiredPlugins": ["data"],
"optionalPlugins": [],
"requiredBundles": ["kibanaReact"],
"extraPublicDirs": ["common"]
Expand Down
15 changes: 0 additions & 15 deletions x-pack/plugins/aiops/public/api/index.ts

This file was deleted.

167 changes: 0 additions & 167 deletions x-pack/plugins/aiops/public/components/app.tsx

This file was deleted.

This file was deleted.

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
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React, { useEffect, FC } from 'react';

import { EuiBadge, EuiSpacer, EuiText } from '@elastic/eui';

import type { DataView } from '@kbn/data-views-plugin/public';

import { useStreamFetchReducer } from '../../hooks/use_stream_fetch_reducer';

import { initialState, streamReducer } from './stream_reducer';

/**
* ExplainLogRateSpikes props require a data view.
*/
export interface ExplainLogRateSpikesProps {
/** The data view to analyze. */
dataView: DataView;
peteharverson marked this conversation as resolved.
Show resolved Hide resolved
}

export const ExplainLogRateSpikes: FC<ExplainLogRateSpikesProps> = ({ dataView }) => {
const { start, data, isRunning } = useStreamFetchReducer(
'/internal/aiops/explain_log_rate_spikes',
streamReducer,
initialState,
{ index: dataView.title }
);

useEffect(() => {
start();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<EuiText>
<h2>{dataView.title}</h2>
<p>{isRunning ? 'Loading fields ...' : 'Loaded all fields.'}</p>
<EuiSpacer size="xs" />
{data.fields.map((field) => (
<EuiBadge>{field}</EuiBadge>
))}
</EuiText>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export type { ExplainLogRateSpikesProps } from './explain_log_rate_spikes';
import { ExplainLogRateSpikes } from './explain_log_rate_spikes';

// required for dynamic import using React.lazy()
// eslint-disable-next-line import/no-default-export
export default ExplainLogRateSpikes;
Loading