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

Support MDS on List, Detail, Dashboard, Overview pages #722

Merged
merged 28 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d3de573
update snapshots
jackiehanyang Feb 14, 2024
8258d5c
add snpshot
jackiehanyang Feb 14, 2024
9f62cf2
add data source client
jackiehanyang Feb 26, 2024
b0d3f5b
test
jackiehanyang Feb 29, 2024
c21d6c7
Merge branch 'opensearch-project:main' into main
jackiehanyang Apr 4, 2024
e0333ec
neo List Detectors page
jackiehanyang Apr 4, 2024
8a94a9b
add opensearch_dashboards.json file
jackiehanyang Apr 5, 2024
f122344
neo List Detectors page
jackiehanyang Apr 4, 2024
aa5e25d
test
jackiehanyang Apr 5, 2024
10c730b
Support MDS on DetectorDetails page
jackiehanyang Apr 7, 2024
fd26997
change 4/7
jackiehanyang Apr 8, 2024
99a06f1
Merge branch 'neoDetailPage' into neo1
jackiehanyang Apr 8, 2024
2bb2a89
version change
jackiehanyang Apr 9, 2024
c363632
list detector list change
jackiehanyang Apr 9, 2024
c2d97dc
Support MDS on List, Detail, Dashboard, Overview pages
jackiehanyang Apr 12, 2024
373bbdf
change version back to 3.0
jackiehanyang Apr 12, 2024
e046f6d
revert version change
jackiehanyang Apr 12, 2024
d1bbbae
make dataSourceId optional in DetectorListItem type
jackiehanyang Apr 12, 2024
894cf08
update imports
jackiehanyang Apr 12, 2024
2cea066
remove used function
jackiehanyang Apr 12, 2024
2189a54
cleanup
jackiehanyang Apr 12, 2024
7b428f8
add getter and setter for dataSource plugin
jackiehanyang Apr 12, 2024
f166bd2
read dataSourceId from the url instead of passing props
jackiehanyang Apr 17, 2024
67f0a08
addressing comments and run prettier
jackiehanyang Apr 17, 2024
e28ff14
addressing comments
jackiehanyang Apr 18, 2024
598e3d3
make getDataSourceManagementPlugin() optional
jackiehanyang Apr 18, 2024
50e407b
add comment
jackiehanyang Apr 18, 2024
139d315
make dataSourceId type safe
jackiehanyang Apr 18, 2024
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: 1 addition & 4 deletions public/anomaly_detection_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import { Provider } from 'react-redux';
import configureStore from './redux/configureStore';
import { CoreServicesContext } from './components/CoreServices/CoreServices';

export function renderApp(
coreStart: CoreStart,
params: AppMountParameters,
) {
export function renderApp(coreStart: CoreStart, params: AppMountParameters) {
const http = coreStart.http;
const store = configureStore(http);

Expand Down
20 changes: 15 additions & 5 deletions public/pages/AnomalyCharts/containers/AnomalyDetailsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ import {
} from '../utils/constants';
import { HeatmapCell } from './AnomalyHeatmapChart';
import { ANOMALY_AGG, MIN_END_TIME, MAX_END_TIME } from '../../utils/constants';
import { DATA_SOURCE_ID, MAX_HISTORICAL_AGG_RESULTS } from '../../../utils/constants';
import {
DATA_SOURCE_ID,
MAX_HISTORICAL_AGG_RESULTS,
} from '../../../utils/constants';
import { searchResults } from '../../../redux/reducers/anomalyResults';
import {
DAY_IN_MILLI_SECS,
Expand Down Expand Up @@ -120,7 +123,8 @@ export const AnomalyDetailsChart = React.memo(
(props: AnomalyDetailsChartProps) => {
const dispatch = useDispatch();
const location = useLocation();
const dataSourceId = new URLSearchParams(location.search).get(DATA_SOURCE_ID) || '';
const dataSourceId =
new URLSearchParams(location.search).get(DATA_SOURCE_ID) || '';
const [showAlertsFlyout, setShowAlertsFlyout] = useState<boolean>(false);
const [alertAnnotations, setAlertAnnotations] = useState<any[]>([]);
const [isLoadingAlerts, setIsLoadingAlerts] = useState<boolean>(false);
Expand Down Expand Up @@ -177,7 +181,9 @@ export const AnomalyDetailsChart = React.memo(
zoomRange.endDate,
taskId
);
dispatch(searchResults(anomalyDataRangeQuery, resultIndex, dataSourceId, true))
dispatch(
searchResults(anomalyDataRangeQuery, resultIndex, dataSourceId, true)
)
.then((response: any) => {
// Only retrieve buckets that are in the anomaly results range. This is so
// we don't show aggregate results for where there is no data at all
Expand All @@ -196,7 +202,9 @@ export const AnomalyDetailsChart = React.memo(
taskId,
selectedAggId
);
dispatch(searchResults(historicalAggQuery, resultIndex, dataSourceId, true))
dispatch(
searchResults(historicalAggQuery, resultIndex, dataSourceId, true)
)
.then((response: any) => {
const aggregatedAnomalies = parseHistoricalAggregatedAnomalies(
response,
Expand Down Expand Up @@ -232,7 +240,9 @@ export const AnomalyDetailsChart = React.memo(
zoomRange.endDate,
taskId
);
dispatch(searchResults(anomalyDataRangeQuery, resultIndex, dataSourceId, true))
dispatch(
searchResults(anomalyDataRangeQuery, resultIndex, dataSourceId, true)
)
.then((response: any) => {
const dataStartDate = get(
response,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const AnomaliesDistributionChart = (
) => {
const dispatch = useDispatch();
const location = useLocation();
const dataSourceId = new URLSearchParams(location.search).get(DATA_SOURCE_ID) || '';
const dataSourceId =
new URLSearchParams(location.search).get(DATA_SOURCE_ID) || '';

const [anomalyDistribution, setAnomalyDistribution] = useState(
[] as object[]
Expand Down
9 changes: 7 additions & 2 deletions public/pages/Dashboard/Components/AnomaliesLiveChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ import {
getLatestAnomalyResultsForDetectorsByTimeRange,
getLatestAnomalyResultsByTimeRange,
} from '../utils/utils';
import { DATA_SOURCE_ID, MAX_ANOMALIES, SPACE_STR } from '../../../utils/constants';
import {
DATA_SOURCE_ID,
MAX_ANOMALIES,
SPACE_STR,
} from '../../../utils/constants';
import { ALL_CUSTOM_AD_RESULT_INDICES } from '../../utils/constants';
import { searchResults } from '../../../redux/reducers/anomalyResults';
import { useLocation } from 'react-router-dom';
Expand All @@ -70,7 +74,8 @@ const MAX_LIVE_DETECTORS = 10;
export const AnomaliesLiveChart = (props: AnomaliesLiveChartProps) => {
const dispatch = useDispatch();
const location = useLocation();
const dataSourceId = new URLSearchParams(location.search).get(DATA_SOURCE_ID) || '';
const dataSourceId =
new URLSearchParams(location.search).get(DATA_SOURCE_ID) || '';

const [liveTimeRange, setLiveTimeRange] = useState<LiveTimeRangeState>({
startDateTime: moment().subtract(31, 'minutes'),
Expand Down
89 changes: 56 additions & 33 deletions public/pages/Dashboard/Container/DashboardOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,21 @@ import {
ALL_INDICES_MESSAGE,
} from '../utils/constants';
import { AppState } from '../../../redux/reducers';
import { CatIndex, IndexAlias, MDSQueryParams } from '../../../../server/models/types';
import { getAllDetectorsQueryParamsWithDataSourceId, getVisibleOptions } from '../../utils/helpers';
import {
CatIndex,
IndexAlias,
MDSQueryParams,
} from '../../../../server/models/types';
import {
getAllDetectorsQueryParamsWithDataSourceId,
getVisibleOptions,
} from '../../utils/helpers';
import { BREADCRUMBS } from '../../../utils/constants';
import { DETECTOR_STATE } from '../../../../server/utils/constants';
import { getDetectorStateOptions, getURLQueryParams } from '../../DetectorsList/utils/helpers';
import {
getDetectorStateOptions,
getURLQueryParams,
} from '../../DetectorsList/utils/helpers';
import { DashboardHeader } from '../Components/utils/DashboardHeader';
import { EmptyDashboard } from '../Components/EmptyDashboard/EmptyDashboard';
import {
Expand All @@ -49,7 +59,12 @@ import {
import { CoreServicesContext } from '../../../components/CoreServices/CoreServices';
import { CoreStart, MountPoint } from '../../../../../../src/core/public';
import { DataSourceSelectableConfig } from '../../../../../../src/plugins/data_source_management/public';
import { getDataSourceManagementPlugin, getDataSourcePlugin, getNotifications, getSavedObjectsClient } from '../../../services';
import {
getDataSourceManagementPlugin,
getDataSourcePlugin,
getNotifications,
getSavedObjectsClient,
} from '../../../services';
import { RouteComponentProps } from 'react-router-dom';

interface OverviewProps extends RouteComponentProps {
Expand All @@ -70,7 +85,7 @@ export function DashboardOverview(props: OverviewProps) {
const errorGettingDetectors = adState.errorMessage;
const isLoadingDetectors = adState.requesting;

const dataSourceEnabled = getDataSourcePlugin().dataSourceEnabled;
const dataSourceEnabled = getDataSourcePlugin()?.dataSourceEnabled || false;

const [currentDetectors, setCurrentDetectors] = useState(
Object.values(allDetectorList)
Expand All @@ -82,7 +97,9 @@ export function DashboardOverview(props: OverviewProps) {
const queryParams = getURLQueryParams(props.location);
const [MDSOverviewState, setMDSOverviewState] = useState<MDSOverviewState>({
queryParams,
selectedDataSourceId: queryParams.dataSourceId ? queryParams.dataSourceId : '',
selectedDataSourceId: queryParams.dataSourceId
? queryParams.dataSourceId
: '',
});

const getDetectorOptions = (detectorsIdMap: {
Expand Down Expand Up @@ -140,7 +157,7 @@ export function DashboardOverview(props: OverviewProps) {
selectedDataSourceId: dataSourceId,
jackiehanyang marked this conversation as resolved.
Show resolved Hide resolved
});
}
}
};

const opensearchState = useSelector((state: AppState) => state.opensearch);

Expand Down Expand Up @@ -191,7 +208,13 @@ export function DashboardOverview(props: OverviewProps) {
};

const intializeDetectors = async () => {
dispatch(getDetectorList(getAllDetectorsQueryParamsWithDataSourceId(MDSOverviewState.selectedDataSourceId)));
dispatch(
getDetectorList(
getAllDetectorsQueryParamsWithDataSourceId(
MDSOverviewState.selectedDataSourceId
)
)
);
dispatch(getIndices('', MDSOverviewState.selectedDataSourceId));
dispatch(getAliases('', MDSOverviewState.selectedDataSourceId));
};
Expand All @@ -204,10 +227,8 @@ export function DashboardOverview(props: OverviewProps) {
history.replace({
...location,
search: queryString.stringify(updatedParams),
})
if (dataSourceEnabled ? MDSOverviewState.selectedDataSourceId : true) {
jackiehanyang marked this conversation as resolved.
Show resolved Hide resolved
intializeDetectors();
}
});
intializeDetectors();
}, [MDSOverviewState]);

useEffect(() => {
Expand Down Expand Up @@ -237,28 +258,31 @@ export function DashboardOverview(props: OverviewProps) {
filterSelectedDetectors(
selectedDetectorsName,
selectedDetectorStates,
selectedIndices,
selectedIndices
);
}, [selectedDetectorsName, selectedIndices, selectedDetectorStates]);

const DataSourceMenu =
getDataSourceManagementPlugin().ui.getDataSourceMenu<DataSourceSelectableConfig>();
const renderDataSourceComponent = useMemo(() => {
return (
<DataSourceMenu
setMenuMountPoint={props.setActionMenu}
componentType={'DataSourceSelectable'}
componentConfig={{
fullWidth: false,
activeOption:[{ id: MDSOverviewState.selectedDataSourceId }],
savedObjects: getSavedObjectsClient(),
notifications: getNotifications(),
onSelectedDataSources: (dataSources) =>
handleDataSourceChange(dataSources),
}}
/>
);
}, [getSavedObjectsClient(), getNotifications(), props.setActionMenu]);
let renderDataSourceComponent = null;
if (dataSourceEnabled) {
const DataSourceMenu =
getDataSourceManagementPlugin().ui.getDataSourceMenu<DataSourceSelectableConfig>();
ohltyler marked this conversation as resolved.
Show resolved Hide resolved
renderDataSourceComponent = useMemo(() => {
return (
<DataSourceMenu
setMenuMountPoint={props.setActionMenu}
componentType={'DataSourceSelectable'}
componentConfig={{
fullWidth: false,
activeOption: [{ id: MDSOverviewState.selectedDataSourceId }],
savedObjects: getSavedObjectsClient(),
notifications: getNotifications(),
onSelectedDataSources: (dataSources) =>
handleDataSourceChange(dataSources),
}}
/>
);
}, [getSavedObjectsClient(), getNotifications(), props.setActionMenu]);
}

return (
<div style={{ height: '1200px' }}>
Expand Down Expand Up @@ -312,8 +336,7 @@ export function DashboardOverview(props: OverviewProps) {
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer />
<AnomaliesLiveChart
selectedDetectors={currentDetectors} />
<AnomaliesLiveChart selectedDetectors={currentDetectors} />
<EuiSpacer />
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={6}>
Expand Down
3 changes: 2 additions & 1 deletion public/pages/DetectorConfig/containers/DetectorConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ interface DetectorConfigProps extends RouteComponentProps {
export function DetectorConfig(props: DetectorConfigProps) {
const dispatch = useDispatch();
const location = useLocation();
const dataSourceId = new URLSearchParams(location.search).get(DATA_SOURCE_ID) || '';
const dataSourceId =
new URLSearchParams(location.search).get(DATA_SOURCE_ID) || '';
const detector = useSelector(
(state: AppState) => state.ad.detectors[props.detectorId]
);
Expand Down
Loading
Loading