Skip to content

Commit

Permalink
support creating monitor for anomaly detector with custom result index (
Browse files Browse the repository at this point in the history
opensearch-project#143) (opensearch-project#147)

* support creating monitor for anomaly detector with custom result index

Signed-off-by: Yaliang Wu <[email protected]>

* add release note

Signed-off-by: Yaliang Wu <[email protected]>
  • Loading branch information
ylwu-amzn authored Nov 9, 2021
1 parent 90b9dc6 commit ddaf063
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 1 deletion.
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

0 comments on commit ddaf063

Please sign in to comment.