[ML] AIOps Log Rate Analysis: Fix date picker refresh button. (#183768)

## Summary

Part of #181111.

The refresh button wasn't working as expected. It would refetch the date
histogram, but if you had a time set like `Last 15 minutes`, the time
range on the page wasn't updated. This PR adds a fix to trigger a
refresh of active bounds. It fixes a problem with the deviation brush
not properly updating too. Without the fix, the deviation brush would
not move when the time range changes.


[aiops-lra-refresh-fix-0001.webm](70d51b1c-e831-4971-b385-3c455632b8eb)

### 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
- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
This commit is contained in:
Walter Rafelsberger 2024-05-21 11:35:16 +02:00 committed by GitHub
parent 4c9d65b767
commit 63441fd226
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 7 deletions

View file

@ -233,10 +233,14 @@ export const DualBrush: FC<DualBrushProps> = (props) => {
]);
}
brushes.current[0].start = snappedWindowParameters.baselineMin;
brushes.current[0].end = snappedWindowParameters.baselineMax;
brushes.current[1].start = snappedWindowParameters.deviationMin;
brushes.current[1].end = snappedWindowParameters.deviationMax;
if (id === 'baseline') {
brushes.current[0].start = snappedWindowParameters.baselineMin;
brushes.current[0].end = snappedWindowParameters.baselineMax;
}
if (id === 'deviation') {
brushes.current[1].start = snappedWindowParameters.deviationMin;
brushes.current[1].end = snappedWindowParameters.deviationMax;
}
if (onChange) {
onChange(snappedWindowParameters, newBrushPx);
@ -263,7 +267,10 @@ export const DualBrush: FC<DualBrushProps> = (props) => {
return 'aiopsBrush' + b.id.charAt(0).toUpperCase() + b.id.slice(1);
})
.each((brushObject: DualBrush, i, n) => {
const x = d3.scaleLinear().domain([min, max]).rangeRound([0, widthRef.current]);
const x = d3
.scaleLinear()
.domain([minRef.current, maxRef.current])
.rangeRound([0, widthRef.current]);
// Ensure brush style is applied
brushObject.brush.extent([
[0, BRUSH_MARGIN],

View file

@ -63,6 +63,7 @@ export function getDocumentCountStatsSplitLabel(
}
export interface LogRateAnalysisContentProps {
/** Optional time range override */
timeRange?: { min: Moment; max: Moment };
/** Elasticsearch query to pass to analysis endpoint */
esSearchQuery?: estypes.QueryDslQueryContainer;

View file

@ -99,7 +99,7 @@ export const LogRateAnalysisPage: FC<Props> = ({ stickyHistogram }) => {
);
useEffect(
// TODO: Consolidate this hook/function with with Data visualizer's
// TODO: Consolidate this hook/function with the one in `x-pack/plugins/data_visualizer/public/application/index_data_visualizer/components/index_data_visualizer_view/index_data_visualizer_view.tsx`
function clearFiltersOnLeave() {
return () => {
// We want to clear all filters that have not been pinned globally

View file

@ -117,8 +117,8 @@ export const useData = (
time: timefilter.getTime(),
refreshInterval: timefilter.getRefreshInterval(),
});
setLastRefresh(Date.now());
}
setLastRefresh(Date.now());
});
// This listens just for an initial update of the timefilter to be switched on.