Skip to content

Commit

Permalink
Merge branch 'main' into fix-assets-no-data-permission
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Sep 20, 2022
2 parents 6bc0753 + ab0e2fb commit e3a93d6
Show file tree
Hide file tree
Showing 65 changed files with 1,458 additions and 508 deletions.
21 changes: 13 additions & 8 deletions docs/developer/contributing/development-functional-tests.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,23 @@ There are three ways to run the tests depending on your goals:

3. Custom option:
** Description: Runs tests against instances of {es} & {kib} started some other way (like Elastic Cloud, or an instance you are managing in some other way).
** just executes the functional tests
** url, credentials, etc. for {es} and {kib} are specified via environment variables
** Here's an example that runs against an Elastic Cloud instance. Note that you must run the same branch of tests as the version of {kib} you're testing.
** Just executes the functional tests
** URL, credentials, etc. for {es} and {kib} are specified via environment variables
** When running against an Elastic Cloud instance, additional environment variables are required `TEST_CLOUD` and `ES_SECURITY_ENABLED`
** You must run the same branch of tests as the version of {kib} you're testing. To run against a previous minor version use option `--es-version <instance version>`
** To run a specific configuration use option `--config <configuration file>`
** Here's an example that runs against an Elastic Cloud instance
+
["source","shell"]
----------
export TEST_KIBANA_URL=https://kibana:password@my-kibana-instance.internal.net:443
export TEST_KIBANA_URL=https://elastic:password@my-kbn-cluster.elastic-cloud.com:443
export TEST_ES_URL=https://elastic:password@my-es-cluster.elastic-cloud.com:443
export TEST_ES_URL=https://elastic:password@my-es-cluster.internal.net:9200
node scripts/functional_test_runner
----------
export TEST_CLOUD=1
export ES_SECURITY_ENABLED=1
node scripts/functional_test_runner [--config <config>] [--es-version <instance version>]
----------

** Or you can override any or all of these individual parts of the URL and leave the others to the default values.
+
Expand Down Expand Up @@ -527,4 +532,4 @@ If your functional tests are flaky then the Operations team might skip them and

This will take you to Buildkite where your build will run and tell you if it failed in any execution.

A flaky test may only fail once in 1000 runs, so keep this in mind and make sure you use enough executions to really prove that a test isn't flaky anymore.
A flaky test may only fail once in 1000 runs, so keep this in mind and make sure you use enough executions to really prove that a test isn't flaky anymore.
1 change: 1 addition & 0 deletions x-pack/packages/ml/agg_utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type {
AggCardinality,
ChangePoint,
ChangePointGroup,
ChangePointGroupHistogram,
ChangePointHistogram,
ChangePointHistogramItem,
HistogramField,
Expand Down
10 changes: 10 additions & 0 deletions x-pack/packages/ml/agg_utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ export interface ChangePointHistogram extends FieldValuePair {
histogram: ChangePointHistogramItem[];
}

/**
* Change point histogram data for a group of field/value pairs.
*/
export interface ChangePointGroupHistogram {
id: string;
histogram: ChangePointHistogramItem[];
}

interface ChangePointGroupItem extends FieldValuePair {
duplicate?: boolean;
}
Expand All @@ -95,7 +103,9 @@ interface ChangePointGroupItem extends FieldValuePair {
* Tree leaves
*/
export interface ChangePointGroup {
id: string;
group: ChangePointGroupItem[];
docCount: number;
pValue: number | null;
histogram?: ChangePointHistogramItem[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
* 2.0.
*/

import type { ChangePoint, ChangePointHistogram, ChangePointGroup } from '@kbn/ml-agg-utils';
import type {
ChangePoint,
ChangePointHistogram,
ChangePointGroup,
ChangePointGroupHistogram,
} from '@kbn/ml-agg-utils';

export const API_ACTION_NAME = {
ADD_CHANGE_POINTS: 'add_change_points',
ADD_CHANGE_POINTS_HISTOGRAM: 'add_change_points_histogram',
ADD_CHANGE_POINTS_GROUP: 'add_change_point_group',
ADD_CHANGE_POINTS_GROUP_HISTOGRAM: 'add_change_point_group_histogram',
ADD_ERROR: 'add_error',
RESET: 'reset',
UPDATE_LOADING_STATE: 'update_loading_state',
Expand Down Expand Up @@ -57,6 +63,20 @@ export function addChangePointsGroupAction(payload: ApiActionAddChangePointsGrou
};
}

interface ApiActionAddChangePointsGroupHistogram {
type: typeof API_ACTION_NAME.ADD_CHANGE_POINTS_GROUP_HISTOGRAM;
payload: ChangePointGroupHistogram[];
}

export function addChangePointsGroupHistogramAction(
payload: ApiActionAddChangePointsGroupHistogram['payload']
): ApiActionAddChangePointsGroupHistogram {
return {
type: API_ACTION_NAME.ADD_CHANGE_POINTS_GROUP_HISTOGRAM,
payload,
};
}

interface ApiActionAddError {
type: typeof API_ACTION_NAME.ADD_ERROR;
payload: string;
Expand Down Expand Up @@ -99,6 +119,7 @@ export type AiopsExplainLogRateSpikesApiAction =
| ApiActionAddChangePoints
| ApiActionAddChangePointsGroup
| ApiActionAddChangePointsHistogram
| ApiActionAddChangePointsGroupHistogram
| ApiActionAddError
| ApiActionReset
| ApiActionUpdateLoadingState;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export {
addChangePointsAction,
addChangePointsGroupAction,
addChangePointsGroupHistogramAction,
addChangePointsHistogramAction,
addErrorAction,
resetAction,
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/aiops/common/api/stream_reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ export function streamReducer(
return { ...state, changePoints };
case API_ACTION_NAME.ADD_CHANGE_POINTS_GROUP:
return { ...state, changePointsGroups: action.payload };
case API_ACTION_NAME.ADD_CHANGE_POINTS_GROUP_HISTOGRAM:
const changePointsGroups = state.changePointsGroups.map((cpg) => {
const cpHistogram = action.payload.find((h) => h.id === cpg.id);
if (cpHistogram) {
cpg.histogram = cpHistogram.histogram;
}
return cpg;
});
return { ...state, changePointsGroups };
case API_ACTION_NAME.ADD_ERROR:
return { ...state, errors: [...state.errors, action.payload] };
case API_ACTION_NAME.RESET:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const ExplainLogRateSpikesAnalysis: FC<ExplainLogRateSpikesAnalysisProps>
}, []);

const groupTableItems = useMemo(() => {
const tableItems = data.changePointsGroups.map(({ group, docCount, pValue }, index) => {
const tableItems = data.changePointsGroups.map(({ id, group, docCount, histogram, pValue }) => {
const sortedGroup = group.sort((a, b) =>
a.fieldName > b.fieldName ? 1 : b.fieldName > a.fieldName ? -1 : 0
);
Expand All @@ -144,11 +144,12 @@ export const ExplainLogRateSpikesAnalysis: FC<ExplainLogRateSpikesAnalysisProps>
});

return {
id: index,
id,
docCount,
pValue,
group: dedupedGroup,
repeatedValues,
histogram,
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import type { ChangePoint } from '@kbn/ml-agg-utils';

import { useEuiTheme } from '../../hooks/use_eui_theme';

import { MiniHistogram } from '../mini_histogram';

import { SpikeAnalysisTable } from './spike_analysis_table';

const NARROW_COLUMN_WIDTH = '120px';
Expand All @@ -36,11 +40,12 @@ const DEFAULT_SORT_FIELD = 'pValue';
const DEFAULT_SORT_DIRECTION = 'asc';

interface GroupTableItem {
id: number;
id: string;
docCount: number;
pValue: number | null;
group: Record<string, any>;
repeatedValues: Record<string, any>;
histogram: ChangePoint['histogram'];
}

interface SpikeAnalysisTableProps {
Expand Down Expand Up @@ -196,6 +201,39 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({
sortable: false,
textOnly: true,
},
{
'data-test-subj': 'aiopsSpikeAnalysisGroupsTableColumnLogRate',
width: NARROW_COLUMN_WIDTH,
field: 'pValue',
name: (
<EuiToolTip
position="top"
content={i18n.translate(
'xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.logRateColumnTooltip',
{
defaultMessage:
'A visual representation of the impact of the field on the message rate difference',
}
)}
>
<>
<FormattedMessage
id="xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.logRateLabel"
defaultMessage="Log rate"
/>
<EuiIcon size="s" color="subdued" type="questionInCircle" className="eui-alignTop" />
</>
</EuiToolTip>
),
render: (_, { histogram, id }) => (
<MiniHistogram
chartData={histogram}
isLoading={loading && histogram === undefined}
label="Group x"
/>
),
sortable: false,
},
{
'data-test-subj': 'aiopsSpikeAnalysisGroupsTableColumnPValue',
width: NARROW_COLUMN_WIDTH,
Expand Down Expand Up @@ -226,9 +264,12 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({
{
'data-test-subj': 'aiopsSpikeAnalysisGroupsTableColumnDocCount',
field: 'docCount',
name: i18n.translate('xpack.aiops.correlations.spikeAnalysisTableGroups.docCountLabel', {
defaultMessage: 'Doc count',
}),
name: i18n.translate(
'xpack.aiops.explainLogRateSpikes.spikeAnalysisTableGroups.docCountLabel',
{
defaultMessage: 'Doc count',
}
),
sortable: true,
width: '20%',
},
Expand Down Expand Up @@ -281,6 +322,7 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({
compressed
columns={columns}
items={pageOfItems}
itemId="id"
itemIdToExpandedRowMap={itemIdToExpandedRowMap}
onChange={onChange}
pagination={pagination}
Expand Down
Loading

0 comments on commit e3a93d6

Please sign in to comment.