Skip to content

Commit

Permalink
Merge branch 'master' into retry-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored May 15, 2020
2 parents e21634e + 07e57fb commit 32a7031
Show file tree
Hide file tree
Showing 61 changed files with 1,006 additions and 592 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ module.exports = {
* Licence headers
*/
{
files: ['**/*.{js,ts,tsx}'],
files: ['**/*.{js,ts,tsx}', '!plugins/**/*'],
rules: {
'@kbn/eslint/require-license-header': [
'error',
Expand Down
18 changes: 12 additions & 6 deletions docs/settings/reporting-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,22 @@ control the capturing process.
[cols="2*<"]
|===
| `xpack.reporting.capture.timeouts.openUrl`
| How long to allow the Reporting browser to wait for the initial data of the
{kib} page to load. Defaults to `30000` (30 seconds).
| Specify how long to allow the Reporting browser to wait for the "Loading..." screen
to dismiss and find the initial data for the Kibana page. If the time is
exceeded, a page screenshot is captured showing the current state, and the download link shows a warning message.
Defaults to `30000` (30 seconds).

| `xpack.reporting.capture.timeouts.waitForElements`
| How long to allow the Reporting browser to wait for the visualization panels to
load on the {kib} page. Defaults to `30000` (30 seconds).
| Specify how long to allow the Reporting browser to wait for all visualization
panels to load on the Kibana page. If the time is exceeded, a page screenshot
is captured showing the current state, and the download link shows a warning message. Defaults to `30000` (30
seconds).

| `xpack.reporting.capture.timeouts.renderComplete`
| How long to allow the Reporting browser to wait for each visualization to
signal that it is done renderings. Defaults to `30000` (30 seconds).
| Specify how long to allow the Reporting browser to wait for all visualizations to
fetch and render the data. If the time is exceeded, a
page screenshot is captured showing the current state, and the download link shows a warning message. Defaults to
`30000` (30 seconds).

|===

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function Cytoscape({
};

const dataHandler: cytoscape.EventHandler = event => {
if (cy) {
if (cy && cy.elements().length > 0) {
if (serviceName) {
resetConnectedEdgeStyle(cy.getElementById(serviceName));
// Add the "primary" class to the node if its id matches the serviceName.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ export const METRIC_FORMATTERS: MetricFormatters = {
formatter: InfraFormatterType.number,
template: '{{value}} seconds',
},
['rdsLatency']: {
formatter: InfraFormatterType.number,
template: '{{value}} ms',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ export const Expressions: React.FC<Props> = props => {

const addExpression = useCallback(() => {
const exp = alertParams.criteria?.slice() || [];
exp.push(defaultExpression);
exp.push({
...defaultExpression,
timeSize: timeSize ?? defaultExpression.timeSize,
timeUnit: timeUnit ?? defaultExpression.timeUnit,
});
setAlertParams('criteria', exp);
}, [setAlertParams, alertParams.criteria]);
}, [setAlertParams, alertParams.criteria, timeSize, timeUnit]);

const removeExpression = useCallback(
(id: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ export const Expressions: React.FC<Props> = props => {
);

const addExpression = useCallback(() => {
const exp = alertParams.criteria.slice();
exp.push(defaultExpression);
const exp = alertParams.criteria?.slice() || [];
exp.push({
...defaultExpression,
timeSize: timeSize ?? defaultExpression.timeSize,
timeUnit: timeUnit ?? defaultExpression.timeUnit,
});
setAlertParams('criteria', exp);
}, [setAlertParams, alertParams.criteria]);
}, [setAlertParams, alertParams.criteria, timeSize, timeUnit]);

const removeExpression = useCallback(
(id: number) => {
Expand Down Expand Up @@ -185,6 +189,31 @@ export const Expressions: React.FC<Props> = props => {
[onFilterChange]
);

const preFillAlertCriteria = useCallback(() => {
const md = alertsContext.metadata;
if (md && md.options) {
setAlertParams('criteria', [
{
...defaultExpression,
metric: md.options.metric!.type,
} as InventoryMetricConditions,
]);
} else {
setAlertParams('criteria', [defaultExpression]);
}
}, [alertsContext.metadata, setAlertParams]);

const preFillAlertFilter = useCallback(() => {
const md = alertsContext.metadata;
if (md && md.filter) {
setAlertParams('filterQueryText', md.filter);
setAlertParams(
'filterQuery',
convertKueryToElasticSearchQuery(md.filter, derivedIndexPattern) || ''
);
}
}, [alertsContext.metadata, derivedIndexPattern, setAlertParams]);

useEffect(() => {
const md = alertsContext.metadata;
if (!alertParams.nodeType) {
Expand All @@ -195,31 +224,19 @@ export const Expressions: React.FC<Props> = props => {
}
}

if (!alertParams.criteria) {
if (md && md.options) {
setAlertParams('criteria', [
{
...defaultExpression,
metric: md.options.metric!.type,
} as InventoryMetricConditions,
]);
} else {
setAlertParams('criteria', [defaultExpression]);
}
if (alertParams.criteria && alertParams.criteria.length) {
setTimeSize(alertParams.criteria[0].timeSize);
setTimeUnit(alertParams.criteria[0].timeUnit);
} else {
preFillAlertCriteria();
}

if (!alertParams.filterQuery) {
if (md && md.filter) {
setAlertParams('filterQueryText', md.filter);
setAlertParams(
'filterQuery',
convertKueryToElasticSearchQuery(md.filter, derivedIndexPattern) || ''
);
}
preFillAlertFilter();
}

if (!alertParams.sourceId) {
setAlertParams('sourceId', source?.id);
setAlertParams('sourceId', source?.id || 'default');
}
}, [alertsContext.metadata, derivedIndexPattern, defaultExpression, source]); // eslint-disable-line react-hooks/exhaustive-deps

Expand All @@ -235,11 +252,13 @@ export const Expressions: React.FC<Props> = props => {
</h4>
</EuiText>
<StyledExpression>
<NodeTypeExpression
options={nodeTypes}
value={alertParams.nodeType || 'host'}
onChange={updateNodeType}
/>
<StyledExpressionRow>
<NodeTypeExpression
options={nodeTypes}
value={alertParams.nodeType || 'host'}
onChange={updateNodeType}
/>
</StyledExpressionRow>
</StyledExpression>
<EuiSpacer size={'xs'} />
{alertParams.criteria &&
Expand Down Expand Up @@ -425,11 +444,13 @@ export const ExpressionRow: React.FC<ExpressionRowProps> = props => {
/>
</StyledExpression>
{metric && (
<StyledExpression>
<div style={{ display: 'flex', alignItems: 'center', height: '100%' }}>
<div>{metricUnit[metric]?.label || ''}</div>
</div>
</StyledExpression>
<div
style={{
alignSelf: 'center',
}}
>
<EuiText size={'s'}>{metricUnit[metric]?.label || ''}</EuiText>
</div>
)}
</StyledExpressionRow>
</EuiFlexItem>
Expand Down Expand Up @@ -502,4 +523,5 @@ const metricUnit: Record<string, { label: string }> = {
s3UploadBytes: { label: 'bytes' },
s3DownloadBytes: { label: 'bytes' },
sqsOldestMessage: { label: 'seconds' },
rdsLatency: { label: 'ms' },
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Props {
metric?: { value: SnapshotMetricType; text: string };
metrics: Array<{ value: string; text: string }>;
errors: IErrorObject;
onChange: (metric: SnapshotMetricType) => void;
onChange: (metric?: SnapshotMetricType) => void;
popupPosition?:
| 'upCenter'
| 'upLeft'
Expand Down Expand Up @@ -65,11 +65,11 @@ export const MetricExpression = ({ metric, metrics, errors, onChange, popupPosit
}
)}
value={metric?.text || firstFieldOption.text}
isActive={aggFieldPopoverOpen || !metric}
isActive={Boolean(aggFieldPopoverOpen || (errors.metric && errors.metric.length > 0))}
onClick={() => {
setAggFieldPopoverOpen(true);
}}
color={metric ? 'secondary' : 'danger'}
color={errors.metric?.length ? 'danger' : 'secondary'}
/>
}
isOpen={aggFieldPopoverOpen}
Expand All @@ -89,16 +89,12 @@ export const MetricExpression = ({ metric, metrics, errors, onChange, popupPosit
</ClosablePopoverTitle>
<EuiFlexGroup>
<EuiFlexItem grow={false} className="actOf__aggFieldContainer">
<EuiFormRow
fullWidth
isInvalid={errors.metric.length > 0 && metric !== undefined}
error={errors.metric}
>
<EuiFormRow fullWidth isInvalid={errors.metric.length > 0} error={errors.metric}>
<EuiComboBox
fullWidth
singleSelection={{ asPlainText: true }}
data-test-subj="availablefieldsOptionsComboBox"
isInvalid={errors.metric.length > 0 && metric !== undefined}
isInvalid={errors.metric.length > 0}
placeholder={firstFieldOption.text}
options={availablefieldsOptions}
noSuggestions={!availablefieldsOptions.length}
Expand All @@ -110,6 +106,8 @@ export const MetricExpression = ({ metric, metrics, errors, onChange, popupPosit
if (selectedOptions.length > 0) {
onChange(selectedOptions[0].value as SnapshotMetricType);
setAggFieldPopoverOpen(false);
} else {
onChange();
}
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ import { FormattedMessage } from '@kbn/i18n/react';
import React, { useCallback } from 'react';
import { LoadingOverlayWrapper } from '../../../loading_overlay_wrapper';
import { IndexSetupRow } from './index_setup_row';
import { AvailableIndex } from './validation';
import { AvailableIndex, ValidationIndicesError } from './validation';

export const AnalysisSetupIndicesForm: React.FunctionComponent<{
disabled?: boolean;
indices: AvailableIndex[];
isValidating: boolean;
onChangeSelectedIndices: (selectedIndices: AvailableIndex[]) => void;
valid: boolean;
}> = ({ disabled = false, indices, isValidating, onChangeSelectedIndices, valid }) => {
validationErrors?: ValidationIndicesError[];
}> = ({
disabled = false,
indices,
isValidating,
onChangeSelectedIndices,
validationErrors = [],
}) => {
const changeIsIndexSelected = useCallback(
(indexName: string, isSelected: boolean) => {
onChangeSelectedIndices(
Expand All @@ -41,6 +47,8 @@ export const AnalysisSetupIndicesForm: React.FunctionComponent<{
[indices, onChangeSelectedIndices]
);

const isInvalid = validationErrors.length > 0;

return (
<EuiDescribedFormGroup
title={
Expand All @@ -59,7 +67,12 @@ export const AnalysisSetupIndicesForm: React.FunctionComponent<{
}
>
<LoadingOverlayWrapper isLoading={isValidating}>
<EuiFormRow fullWidth isInvalid={!valid} label={indicesSelectionLabel} labelType="legend">
<EuiFormRow
fullWidth
isInvalid={isInvalid}
label={indicesSelectionLabel}
labelType="legend"
>
<>
{indices.map(index => (
<IndexSetupRow
Expand Down
Loading

0 comments on commit 32a7031

Please sign in to comment.