Skip to content

Commit

Permalink
[ML] AIOps Log Rate Analysis: Fix date picker refresh button. (#183768)
Browse files Browse the repository at this point in the history
## 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](https://github.com/elastic/kibana/assets/230104/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)
  • Loading branch information
walterra committed May 21, 2024
1 parent 4c9d65b commit 63441fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
17 changes: 12 additions & 5 deletions x-pack/packages/ml/aiops_components/src/dual_brush/dual_brush.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/aiops/public/hooks/use_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 63441fd

Please sign in to comment.