Skip to content

Commit

Permalink
Merge branch 'main' into ml-apm-correlations-fix-load-balancing
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Nov 3, 2021
2 parents 2b755d3 + ea7ff29 commit 5310686
Show file tree
Hide file tree
Showing 60 changed files with 845 additions and 523 deletions.
12 changes: 12 additions & 0 deletions docs/user/security/audit-logging.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ Refer to the corresponding {es} logs for potential write errors.
| `unknown` | User is updating a space.
| `failure` | User is not authorized to update a space.

.2+| `alert_update`
| `unknown` | User is updating an alert.
| `failure` | User is not authorized to update an alert.

3+a|
====== Type: deletion

Expand Down Expand Up @@ -214,6 +218,14 @@ Refer to the corresponding {es} logs for potential write errors.
| `success` | User has accessed a space as part of a search operation.
| `failure` | User is not authorized to search for spaces.

.2+| `alert_get`
| `success` | User has accessed an alert.
| `failure` | User is not authorized to access an alert.

.2+| `alert_find`
| `success` | User has accessed an alert as part of a search operation.
| `failure` | User is not authorized to access alerts.

3+a|
===== Category: web

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
import './histogram.scss';
import moment, { unitOfTime } from 'moment-timezone';
import React, { useCallback, useMemo } from 'react';
import { EuiLoadingChart, EuiSpacer, EuiText } from '@elastic/eui';
import {
EuiFlexGroup,
EuiFlexItem,
EuiIconTip,
EuiLoadingChart,
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import dateMath from '@elastic/datemath';
import {
Expand All @@ -25,6 +32,7 @@ import {
XYChartElementEvent,
} from '@elastic/charts';
import { IUiSettingsClient } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import {
CurrentTime,
Endzones,
Expand Down Expand Up @@ -65,7 +73,7 @@ export function DiscoverHistogram({

const uiSettings = services.uiSettings;
const timeZone = getTimezone(uiSettings);
const { chartData, fetchStatus } = dataState;
const { chartData, fetchStatus, bucketInterval } = dataState;

const onBrushEnd = useCallback(
({ x }: XYBrushEvent) => {
Expand Down Expand Up @@ -182,6 +190,47 @@ export function DiscoverHistogram({

const useLegacyTimeAxis = uiSettings.get(LEGACY_TIME_AXIS, false);

const toolTipTitle = i18n.translate('discover.timeIntervalWithValueWarning', {
defaultMessage: 'Warning',
});

const toolTipContent = i18n.translate('discover.bucketIntervalTooltip', {
defaultMessage:
'This interval creates {bucketsDescription} to show in the selected time range, so it has been scaled to {bucketIntervalDescription}.',
values: {
bucketsDescription:
bucketInterval!.scale && bucketInterval!.scale > 1
? i18n.translate('discover.bucketIntervalTooltip.tooLargeBucketsText', {
defaultMessage: 'buckets that are too large',
})
: i18n.translate('discover.bucketIntervalTooltip.tooManyBucketsText', {
defaultMessage: 'too many buckets',
}),
bucketIntervalDescription: bucketInterval?.description,
},
});

let timeRange = (
<EuiText size="xs" className="dscHistogramTimeRange" textAlign="center">
{timeRangeText}
</EuiText>
);
if (bucketInterval?.scaled) {
timeRange = (
<EuiFlexGroup
alignItems="baseline"
justifyContent="center"
gutterSize="none"
responsive={false}
>
<EuiFlexItem grow={false}>{timeRange}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIconTip type="alert" color="warning" title={toolTipTitle} content={toolTipContent} />
</EuiFlexItem>
</EuiFlexGroup>
);
}

return (
<React.Fragment>
<div className="dscHistogram" data-test-subj="discoverChart" data-time-range={timeRangeText}>
Expand Down Expand Up @@ -232,9 +281,7 @@ export function DiscoverHistogram({
/>
</Chart>
</div>
<EuiText size="xs" className="dscHistogramTimeRange" textAlign="center">
{timeRangeText}
</EuiText>
{timeRange}
</React.Fragment>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import type {
} from '@elastic/eui';
import { search } from '../../../../../../../data/public';
import { AppState } from '../../services/discover_state';
import { DataCharts$, DataChartsMessage } from '../../services/use_saved_search';
import { useDataState } from '../../utils/use_data_state';
import { DataCharts$ } from '../../services/use_saved_search';

export function useChartPanels(
state: AppState,
Expand All @@ -22,8 +21,6 @@ export function useChartPanels(
onChangeInterval: (value: string) => void,
closePopover: () => void
) {
const dataState: DataChartsMessage = useDataState(savedSearchDataChart$);
const { bucketInterval } = dataState;
const { interval, hideChart } = state;
const selectedOptionIdx = search.aggs.intervalOptions.findIndex((opt) => opt.val === interval);
const intervalDisplay =
Expand Down Expand Up @@ -56,29 +53,6 @@ export function useChartPanels(
timeInterval: intervalDisplay,
},
}),
icon: bucketInterval?.scaled ? 'alert' : '',
toolTipTitle: bucketInterval?.scaled
? i18n.translate('discover.timeIntervalWithValueWarning', {
defaultMessage: 'Warning',
})
: '',
toolTipContent: bucketInterval?.scaled
? i18n.translate('discover.bucketIntervalTooltip', {
defaultMessage:
'This interval creates {bucketsDescription} to show in the selected time range, so it has been scaled to {bucketIntervalDescription}.',
values: {
bucketsDescription:
bucketInterval!.scale && bucketInterval!.scale > 1
? i18n.translate('discover.bucketIntervalTooltip.tooLargeBucketsText', {
defaultMessage: 'buckets that are too large',
})
: i18n.translate('discover.bucketIntervalTooltip.tooManyBucketsText', {
defaultMessage: 'too many buckets',
}),
bucketIntervalDescription: bucketInterval?.description,
},
})
: '',
panel: 1,
'data-test-subj': 'discoverTimeIntervalPanel',
});
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/share/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
* Side Public License, v 1.
*/

export { LocatorDefinition, LocatorPublic, useLocatorUrl, formatSearchParams } from './url_service';
export { LocatorDefinition, LocatorPublic, useLocatorUrl } from './url_service';
export type { AnonymousAccessServiceContract, AnonymousAccessState } from './anonymous_access';
6 changes: 3 additions & 3 deletions src/plugins/share/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export { CSV_QUOTE_VALUES_SETTING, CSV_SEPARATOR_SETTING } from '../common/const

export { LocatorDefinition, LocatorPublic, KibanaLocation } from '../common/url_service';

export { UrlGeneratorStateMapping } from './url_generators/url_generator_definition';
export type { UrlGeneratorStateMapping } from './url_generators/url_generator_definition';

export { SharePluginSetup, SharePluginStart } from './plugin';
export type { SharePluginSetup, SharePluginStart } from './plugin';

export {
export type {
ShareContext,
ShareMenuProvider,
ShareMenuItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ export interface UrlGeneratorContract<Id extends UrlGeneratorId> {
id: Id;
createUrl(state: UrlGeneratorStateMapping[Id]['State']): Promise<string>;
isDeprecated: boolean;
migrate(state: UrlGeneratorStateMapping[Id]['State']): Promise<{
state: UrlGeneratorStateMapping[Id]['MigratedState'];
id: UrlGeneratorStateMapping[Id]['MigratedId'];
}>;
}
11 changes: 0 additions & 11 deletions src/plugins/share/public/url_generators/url_generator_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ export class UrlGeneratorInternal<Id extends UrlGeneratorId> {
return this.spec.createUrl!(state);
},
isDeprecated: !!this.spec.isDeprecated,
migrate: async (state: UrlGeneratorStateMapping[Id]['State']) => {
if (!this.spec.isDeprecated) {
throw new Error(
i18n.translate('share.urlGenerators.error.migrateCalledNotDeprecated', {
defaultMessage: 'You cannot call migrate on a non-deprecated generator.',
})
);
}

return this.spec.migrate!(state);
},
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ test('Registering and retrieving a generator', async () => {
"createUrl": [Function],
"id": "TEST_GENERATOR",
"isDeprecated": false,
"migrate": [Function],
}
`);
await expect(generator.migrate({})).rejects.toEqual(
new Error('You cannot call migrate on a non-deprecated generator.')
);
expect(await generator.createUrl({})).toBe('myurl');

const retrievedGenerator = start.getUrlGenerator('TEST_GENERATOR');
Expand All @@ -43,12 +39,8 @@ test('Registering and retrieving a generator', async () => {
"createUrl": [Function],
"id": "TEST_GENERATOR",
"isDeprecated": false,
"migrate": [Function],
}
`);
await expect(generator.migrate({})).rejects.toEqual(
new Error('You cannot call migrate on a non-deprecated generator.')
);
expect(await generator.createUrl({})).toBe('myurl');
});

Expand Down Expand Up @@ -124,6 +116,5 @@ test('Generator returns migrated url', async () => {

const generator = start.getUrlGenerator('v1');
expect(generator.isDeprecated).toBe(true);
expect(await generator.migrate({ bar: 'hi' })).toEqual({ id: 'v2', state: { foo: 'hi' } });
expect(await generator.createUrl({ bar: 'hi' })).toEqual('www.hi.com');
});
25 changes: 15 additions & 10 deletions x-pack/plugins/apm/server/lib/helpers/transactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,23 @@ export async function getSearchAggregatedTransactions({
apmEventClient: APMEventClient;
kuery: string;
}): Promise<boolean> {
const searchAggregatedTransactions = config.searchAggregatedTransactions;
switch (config.searchAggregatedTransactions) {
case SearchAggregatedTransactionSetting.always:
return kuery
? getHasAggregatedTransactions({ start, end, apmEventClient, kuery })
: true;

if (
kuery ||
searchAggregatedTransactions === SearchAggregatedTransactionSetting.auto
) {
return getHasAggregatedTransactions({ start, end, apmEventClient, kuery });
}
case SearchAggregatedTransactionSetting.auto:
return getHasAggregatedTransactions({
start,
end,
apmEventClient,
kuery,
});

return (
searchAggregatedTransactions === SearchAggregatedTransactionSetting.always
);
case SearchAggregatedTransactionSetting.never:
return false;
}
}

export function getTransactionDurationFieldForTransactions(
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/cases/common/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,19 @@ export interface SignalEcs {
threshold_result?: unknown;
}

export type SignalEcsAAD = Exclude<SignalEcs, 'rule' | 'status'> & {
rule?: Exclude<RuleEcs, 'id'> & { uuid: string[] };
building_block_type?: string[];
workflow_status?: string[];
};

export interface Ecs {
_id: string;
_index?: string;
signal?: SignalEcs;
kibana?: {
alert: SignalEcsAAD;
};
}

export type CaseActionConnector = ActionConnector;
14 changes: 11 additions & 3 deletions x-pack/plugins/cases/public/components/user_action_tree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import {
EuiCommentList,
EuiCommentProps,
} from '@elastic/eui';
import { ALERT_RULE_NAME, ALERT_RULE_UUID } from '@kbn/rule-data-utils';

import classNames from 'classnames';
import { isEmpty } from 'lodash';
import { get, isEmpty } from 'lodash';
import React, { useCallback, useMemo, useRef, useState, useEffect } from 'react';
import { useParams } from 'react-router-dom';
import styled from 'styled-components';
Expand Down Expand Up @@ -421,9 +423,15 @@ export const UserActionTree = React.memo(
}

const ruleId =
comment?.rule?.id ?? manualAlertsData[alertId]?.signal?.rule?.id?.[0] ?? null;
comment?.rule?.id ??
manualAlertsData[alertId]?.signal?.rule?.id?.[0] ??
get(manualAlertsData[alertId], ALERT_RULE_UUID)[0] ??
null;
const ruleName =
comment?.rule?.name ?? manualAlertsData[alertId]?.signal?.rule?.name?.[0] ?? null;
comment?.rule?.name ??
manualAlertsData[alertId]?.signal?.rule?.name?.[0] ??
get(manualAlertsData[alertId], ALERT_RULE_NAME)[0] ??
null;

return [
...comments,
Expand Down
Loading

0 comments on commit 5310686

Please sign in to comment.