Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Add sample detectors and indices (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohltyler authored Sep 1, 2020
1 parent fabeb04 commit 956fc91
Show file tree
Hide file tree
Showing 39 changed files with 3,970 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .cypress/integration/ad/dashboard/ad_dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ context('AD Dashboard', () => {
});

cy.mockSearchIndexOnAction('search_index_response.json', () => {
cy.get('a[data-test-subj="add_detector"]').click({
cy.get('a[data-test-subj="createDetectorButton"]').click({
force: true,
});
});
Expand Down
2 changes: 2 additions & 0 deletions public/components/ContentPanel/ContentPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ContentPanelProps = {
title: string | React.ReactNode | React.ReactNode[];
titleSize?: EuiTitleSize;
subTitle?: React.ReactNode | React.ReactNode[];
badgeLabel?: string;
bodyStyles?: React.CSSProperties;
panelStyles?: React.CSSProperties;
horizontalRuleClassName?: string;
Expand All @@ -45,6 +46,7 @@ const ContentPanel = (props: ContentPanelProps) => (
<EuiPanel
style={{ padding: '20px', ...props.panelStyles }}
className={props.contentPanelClassName}
betaBadgeLabel={props.badgeLabel}
>
<EuiFlexGroup
style={{ padding: '0px', ...props.titleContainerStyles }}
Expand Down
44 changes: 44 additions & 0 deletions public/components/CreateDetectorButtons/CreateDetectorButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

import { EuiFlexGroup, EuiFlexItem, EuiButton } from '@elastic/eui';
import React from 'react';
import { APP_PATH, PLUGIN_NAME } from '../../utils/constants';

export const CreateDetectorButtons = () => {
return (
<EuiFlexGroup direction="row" gutterSize="m" justifyContent="center">
<EuiFlexItem grow={false}>
<EuiButton
style={{ width: '200px' }}
href={`${PLUGIN_NAME}#${APP_PATH.SAMPLE_DETECTORS}`}
data-test-subj="sampleDetectorButton"
>
Try a sample detector
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
style={{ width: '200px' }}
fill
href={`${PLUGIN_NAME}#${APP_PATH.CREATE_DETECTOR}`}
data-test-subj="createDetectorButton"
>
Create detector
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* permissions and limitations under the License.
*/

import { EuiButton, EuiEmptyPrompt, EuiLink, EuiIcon } from '@elastic/eui';
import { EuiEmptyPrompt, EuiLink, EuiIcon } from '@elastic/eui';
import React, { Component, Fragment } from 'react';
import { APP_PATH, PLUGIN_NAME } from '../../../../utils/constants';
import { CreateDetectorButtons } from '../../../../components/CreateDetectorButtons/CreateDetectorButtons';

export class EmptyDashboard extends Component<{}, {}> {
render() {
Expand All @@ -27,7 +27,7 @@ export class EmptyDashboard extends Component<{}, {}> {
<p>Create detector first to detect anomalies in your data.</p>
<p>
Dashboard will generate insights on the anomalies across all of
your detectors
your detectors.
</p>
<p>
Read about{' '}
Expand All @@ -41,15 +41,7 @@ export class EmptyDashboard extends Component<{}, {}> {
</p>
</Fragment>
}
actions={
<EuiButton
fill
href={`${PLUGIN_NAME}#${APP_PATH.CREATE_DETECTOR}`}
data-test-subj="add_detector"
>
Create detector
</EuiButton>
}
actions={<CreateDetectorButtons />}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports[`<EmptyDetector /> spec Empty results renders component with empty messa
Create detector first to detect anomalies in your data.
</p>
<p>
Dashboard will generate insights on the anomalies across all of your detectors
Dashboard will generate insights on the anomalies across all of your detectors.
</p>
<p>
Read about
Expand Down Expand Up @@ -55,21 +55,51 @@ exports[`<EmptyDetector /> spec Empty results renders component with empty messa
<div
class="euiSpacer euiSpacer--s"
/>
<a
class="euiButton euiButton--primary euiButton--fill"
data-test-subj="add_detector"
href="opendistro-anomaly-detection-kibana#/create-ad/"
rel="noreferrer"
<div
class="euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--justifyContentCenter euiFlexGroup--directionRow euiFlexGroup--responsive"
>
<span
class="euiButton__content"
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<span
class="euiButton__text"
<a
class="euiButton euiButton--primary"
data-test-subj="sampleDetectorButton"
href="opendistro-anomaly-detection-kibana#/sample-detectors"
rel="noreferrer"
style="width: 200px;"
>
Create detector
</span>
</span>
</a>
<span
class="euiButton__content"
>
<span
class="euiButton__text"
>
Try a sample detector
</span>
</span>
</a>
</div>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<a
class="euiButton euiButton--primary euiButton--fill"
data-test-subj="createDetectorButton"
href="opendistro-anomaly-detection-kibana#/create-ad/"
rel="noreferrer"
style="width: 200px;"
>
<span
class="euiButton__content"
>
<span
class="euiButton__text"
>
Create detector
</span>
</span>
</a>
</div>
</div>
</div>
`;
27 changes: 27 additions & 0 deletions public/pages/DetectorResults/containers/AnomalyResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ import {
FEATURE_DATA_CHECK_WINDOW_OFFSET,
} from '../../utils/anomalyResultUtils';
import { getDetectorResults } from '../../../redux/reducers/anomalyResults';
import {
detectorIsSample,
getAssociatedIndex,
} from '../../SampleData/utils/helpers';
import { SampleIndexDetailsCallout } from '../../SampleData/components/SampleIndexDetailsCallout/SampleIndexDetailsCallout';

interface AnomalyResultsProps extends RouteComponentProps {
detectorId: string;
Expand Down Expand Up @@ -112,13 +117,26 @@ export function AnomalyResults(props: AnomalyResultsProps) {
}
}, [detector]);

useEffect(() => {
if (detector && detectorIsSample(detector)) {
setIsSampleDetector(true);
setSampleIndexName(getAssociatedIndex(detector));
} else {
setIsSampleDetector(false);
}
}, [detector]);

const monitors = useSelector((state: AppState) => state.alerting.monitors);
const monitor = get(monitors, `${detectorId}.0`);

const [featureMissingSeverity, setFeatureMissingSeverity] = useState<
MISSING_FEATURE_DATA_SEVERITY
>();

const [isSampleDetector, setIsSampleDetector] = useState<boolean>(false);

const [sampleIndexName, setSampleIndexName] = useState<string>('');

const [featureNamesAtHighSev, setFeatureNamesAtHighSev] = useState(
[] as string[]
);
Expand Down Expand Up @@ -367,6 +385,15 @@ export function AnomalyResults(props: AnomalyResultsProps) {
isDetectorInitializing ||
isDetectorFailed ? (
<Fragment>
{isSampleDetector ? (
<Fragment>
{' '}
<SampleIndexDetailsCallout
indexName={sampleIndexName}
/>{' '}
<EuiSpacer size="l" />{' '}
</Fragment>
) : null}
{isDetectorUpdated ||
isDetectorMissingData ||
isInitializingNormally ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { EuiButton, EuiEmptyPrompt, EuiText } from '@elastic/eui';
import React from 'react';
import { APP_PATH, PLUGIN_NAME } from '../../../../utils/constants';
import { CreateDetectorButtons } from '../../../../components/CreateDetectorButtons/CreateDetectorButtons';

const filterText =
'There are no detectors matching your applied filters. Reset your filters to view all detectors.';
Expand Down Expand Up @@ -45,13 +45,7 @@ export const EmptyDetectorMessage = (props: EmptyDetectorProps) => (
Reset filters
</EuiButton>
) : (
<EuiButton
fill
href={`${PLUGIN_NAME}#${APP_PATH.CREATE_DETECTOR}`}
data-test-subj="createDetectorButton"
>
Create detector
</EuiButton>
<CreateDetectorButtons />
)
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,52 @@ exports[`<EmptyDetectorMessage /> spec Empty results renders component with empt
<div
class="euiSpacer euiSpacer--s"
/>
<a
class="euiButton euiButton--primary euiButton--fill"
data-test-subj="createDetectorButton"
href="opendistro-anomaly-detection-kibana#/create-ad/"
rel="noreferrer"
<div
class="euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--justifyContentCenter euiFlexGroup--directionRow euiFlexGroup--responsive"
>
<span
class="euiButton__content"
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<span
class="euiButton__text"
<a
class="euiButton euiButton--primary"
data-test-subj="sampleDetectorButton"
href="opendistro-anomaly-detection-kibana#/sample-detectors"
rel="noreferrer"
style="width: 200px;"
>
Create detector
</span>
</span>
</a>
<span
class="euiButton__content"
>
<span
class="euiButton__text"
>
Try a sample detector
</span>
</span>
</a>
</div>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<a
class="euiButton euiButton--primary euiButton--fill"
data-test-subj="createDetectorButton"
href="opendistro-anomaly-detection-kibana#/create-ad/"
rel="noreferrer"
style="width: 200px;"
>
<span
class="euiButton__content"
>
<span
class="euiButton__text"
>
Create detector
</span>
</span>
</a>
</div>
</div>
</div>
`;

Expand Down
Loading

0 comments on commit 956fc91

Please sign in to comment.