[ML] AIOps: Fix query string for the metric chart (#181314)

## Summary

Fixes https://github.com/elastic/kibana/issues/179814

Query string from the Unified Search query bar was applying to the
change point agg request, but wasn't in sync with the query service to
correctly render the chart preview. With the PR the query string is
synchronized and metric charts are rendered correctly.


### Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
This commit is contained in:
Dima Arnautov 2024-04-24 13:55:03 +02:00 committed by GitHub
parent e2c39c93ac
commit 2bd49f5ae4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -132,7 +132,7 @@ export const ChangePointDetectionContextProvider: FC = ({ children }) => {
const {
uiSettings,
data: {
query: { filterManager },
query: { filterManager, queryString },
},
} = useAiopsAppContext();
@ -241,11 +241,18 @@ export const ChangePointDetectionContextProvider: FC = ({ children }) => {
if (requestParamsFromUrl.filters) {
filterManager.setFilters(requestParamsFromUrl.filters);
}
if (requestParamsFromUrl.query) {
queryString.setQuery(requestParamsFromUrl.query);
}
if (globalFilters) {
filterManager?.addFilters(globalFilters);
}
return () => {
filterManager?.removeAll();
queryString.clearQuery();
};
},
[requestParamsFromUrl.filters, filterManager]
[requestParamsFromUrl.filters, requestParamsFromUrl.query, filterManager, queryString]
);
const combinedQuery = useMemo(() => {