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 creating monitor for anomaly detector with custom result index #143

Merged
merged 2 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class AnomalyDetectors extends React.Component {
value: detector.id,
features: detector.featureAttributes,
interval: detector.detectionInterval,
resultIndex: detector.resultIndex,
}));
this.setState({ detectorOptions });
} else {
Expand Down Expand Up @@ -111,6 +112,7 @@ class AnomalyDetectors extends React.Component {
interval: 2 * get(options, '0.interval.period.interval'),
unit: get(options, '0.interval.period.unit', 'MINUTES').toUpperCase(),
});
form.setFieldValue('adResultIndex', get(options, '0.resultIndex'));
},
singleSelection: { asPlaintext: true },
isClearable: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports[`CreateMonitor renders 1`] = `
<Formik
initialValues={
Object {
"adResultIndex": undefined,
"aggregationType": "count",
"aggregations": Array [],
"bucketUnitOfTime": "h",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export function formikToInputs(values) {
export function formikToSearch(values) {
const isAD = values.searchType === SEARCH_TYPE.AD;
let query = isAD ? formikToAdQuery(values) : formikToQuery(values);
const indices = isAD ? ['.opendistro-anomaly-results*'] : formikToIndices(values);
const adResultIndex = _.get(values, 'adResultIndex', '.opendistro-anomaly-results*');
const indices = isAD ? [adResultIndex] : formikToIndices(values);

return {
search: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ export const initializeFromQueryParams = (queryParams) => {
queryParams.interval && queryParams.unit
? { interval: parseInt(queryParams.interval), unit: queryParams.unit }
: undefined,
adResultIndex: queryParams.adResultIndex || undefined,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default function monitorToFormik(monitor) {

detectorId: isAD ? _.get(inputs, INPUTS_DETECTOR_ID) : undefined,
index: inputs[0].search.indices.map((index) => ({ label: index })),
adResultIndex: isAD ? _.get(inputs, '0.search.indices.0') : undefined,
query: JSON.stringify(inputs[0].search.query, null, 4),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Compatible with OpenSearch Dashboards 1.2.0

### Features
* support creating monitor for anomaly detector with custom result index ([#143](https://github.com/opensearch-project/alerting-dashboards-plugin/pull/143))

### Maintenance
* Bumps version to 1.2 ([#128](https://github.com/opensearch-project/alerting-dashboards-plugin/pull/128))
* Added 1.2 release notes. ([#141](https://github.com/opensearch-project/alerting-dashboards-plugin/pull/141))
Expand Down