From b21f9af470e982efbb5247acd6159b03f33e1559 Mon Sep 17 00:00:00 2001 From: TackAdam Date: Tue, 13 Jun 2023 15:23:38 -0700 Subject: [PATCH 1/5] Bugfix filter not appearing, and loading on click Signed-off-by: TackAdam --- .../explorer/log_patterns/log_patterns.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx index 5a149e0c7..862dc8def 100644 --- a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx +++ b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx @@ -4,7 +4,7 @@ */ import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiLink, EuiText } from '@elastic/eui'; -import React, { useContext, useState } from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import { connect, useDispatch } from 'react-redux'; import { FILTERED_PATTERN, @@ -49,11 +49,16 @@ const EventPatterns = ({ requestParams: { tabId }, }); + // refresh filters on opening page + useEffect(() => { + onPatternSelection(''); + }, []); + const onPatternSelection = async (pattern: string) => { if (query[FILTERED_PATTERN] === pattern) { return; } - dispatch( + await dispatch( changeQuery({ tabId, query: { @@ -62,7 +67,7 @@ const EventPatterns = ({ }) ); // workaround to refresh callback and trigger fetch data - await setTempQuery(query[RAW_QUERY]); + // await setTempQuery(query[RAW_QUERY]); await handleTimeRangePickerRefresh(true); }; From 8266c0d737697226ce39825bf5b82ef72d181124 Mon Sep 17 00:00:00 2001 From: TackAdam Date: Wed, 14 Jun 2023 11:29:33 -0700 Subject: [PATCH 2/5] Fixed applications not working with change Signed-off-by: TackAdam --- public/components/event_analytics/explorer/explorer.tsx | 2 +- .../explorer/log_patterns/log_patterns.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/components/event_analytics/explorer/explorer.tsx b/public/components/event_analytics/explorer/explorer.tsx index 8541ae2e6..fa38125da 100644 --- a/public/components/event_analytics/explorer/explorer.tsx +++ b/public/components/event_analytics/explorer/explorer.tsx @@ -727,7 +727,7 @@ export const Explorer = ({ if (availability !== true) { await updateQueryInStore(tempQuery); } - await fetchData(); + await fetchData(startTime, endTime); }, [tempQuery, query] ); diff --git a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx index 862dc8def..61a1eab45 100644 --- a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx +++ b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx @@ -49,7 +49,7 @@ const EventPatterns = ({ requestParams: { tabId }, }); - // refresh filters on opening page + // refresh patterns on opening page useEffect(() => { onPatternSelection(''); }, []); @@ -58,6 +58,8 @@ const EventPatterns = ({ if (query[FILTERED_PATTERN] === pattern) { return; } + // await here allows react to render update properly and display it. + // it forces the query to be changed before running it, without await the visual wont update. await dispatch( changeQuery({ tabId, @@ -66,9 +68,7 @@ const EventPatterns = ({ }, }) ); - // workaround to refresh callback and trigger fetch data - // await setTempQuery(query[RAW_QUERY]); - await handleTimeRangePickerRefresh(true); + handleTimeRangePickerRefresh(true); }; const showToastError = (errorMsg: string) => { From 354a2a9a13eb7f62a599f89df62c8a4b220a6fb8 Mon Sep 17 00:00:00 2001 From: TackAdam Date: Thu, 15 Jun 2023 14:23:00 -0700 Subject: [PATCH 3/5] Fixed refresh keeping the old pattern stored in the query Signed-off-by: TackAdam --- .../explorer/log_patterns/log_patterns.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx index 61a1eab45..a5a4aa46e 100644 --- a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx +++ b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx @@ -69,6 +69,15 @@ const EventPatterns = ({ }) ); handleTimeRangePickerRefresh(true); + // after rendering the patterns visual, we want the pattern to be reset for future searches + await dispatch( + changeQuery({ + tabId, + query: { + [FILTERED_PATTERN]: '', + }, + }) + ); }; const showToastError = (errorMsg: string) => { From 837f15c2591d0797aa17349803dcdd0e7812e544 Mon Sep 17 00:00:00 2001 From: TackAdam Date: Wed, 21 Jun 2023 11:02:43 -0700 Subject: [PATCH 4/5] Patterns working in Applications and Logs Signed-off-by: TackAdam --- .../explorer/log_patterns/log_patterns.tsx | 2 +- .../data_fetchers/ppl/ppl_data_fetcher.ts | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx index a5a4aa46e..aeb941273 100644 --- a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx +++ b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx @@ -51,7 +51,7 @@ const EventPatterns = ({ // refresh patterns on opening page useEffect(() => { - onPatternSelection(''); + getPatterns(selectedIntervalUnit?.value?.replace(/^auto_/, '') || 'y'); }, []); const onPatternSelection = async (pattern: string) => { diff --git a/public/services/data_fetchers/ppl/ppl_data_fetcher.ts b/public/services/data_fetchers/ppl/ppl_data_fetcher.ts index 592d8ab2d..68717b74a 100644 --- a/public/services/data_fetchers/ppl/ppl_data_fetcher.ts +++ b/public/services/data_fetchers/ppl/ppl_data_fetcher.ts @@ -83,7 +83,7 @@ export class PPLDataFetcher extends DataFetcherBase implements IDataFetcher { } = this.searchContext; const { dispatch, changeQuery } = this.storeContext; - await this.processTimestamp(query, appBaseQuery); + await this.processTimestamp(query); if (isEmpty(this.timestamp)) return; const curStartTime = startingTime || this.query[SELECTED_DATE_RANGE][0]; @@ -103,7 +103,7 @@ export class PPLDataFetcher extends DataFetcherBase implements IDataFetcher { ); // update UI with new query state - await this.updateQueryState(this.query[RAW_QUERY], finalQuery, this.timestamp, appBaseQuery); + await this.updateQueryState(this.query[RAW_QUERY], finalQuery, this.timestamp); // calculate proper time interval for count distribution if (!selectedInterval.current || selectedInterval.current.text === 'Auto') { findAutoInterval(curStartTime, curEndTime); @@ -158,8 +158,8 @@ export class PPLDataFetcher extends DataFetcherBase implements IDataFetcher { } } - async processTimestamp(query: IQuery, appBaseQuery: string) { - if (query[SELECTED_TIMESTAMP] && appBaseQuery === '') { + async processTimestamp(query: IQuery) { + if (query[SELECTED_TIMESTAMP]) { this.timestamp = query[SELECTED_TIMESTAMP]; } else { await this.setTimestamp(this.queryIndex); @@ -175,12 +175,7 @@ export class PPLDataFetcher extends DataFetcherBase implements IDataFetcher { return await timestampUtils.getTimestamp(indexPattern); } - async updateQueryState( - rawQuery: string, - finalQuery: string, - curTimestamp: string, - appBaseQuery: string - ) { + async updateQueryState(rawQuery: string, finalQuery: string, curTimestamp: string) { const { batch, dispatch, changeQuery, changeVizConfig } = this.storeContext; const { query } = this.searchParams; const { @@ -197,7 +192,7 @@ export class PPLDataFetcher extends DataFetcherBase implements IDataFetcher { tabId, query: { finalQuery, - [RAW_QUERY]: buildRawQuery(query, appBaseQuery), + [RAW_QUERY]: query.rawQuery, [SELECTED_TIMESTAMP]: curTimestamp, }, }) From 6ff533a191ec31c6bc669bdb2cdab3d82fc9b08f Mon Sep 17 00:00:00 2001 From: TackAdam Date: Mon, 26 Jun 2023 14:48:49 -0700 Subject: [PATCH 5/5] Removed tempQuery from log patterns Signed-off-by: TackAdam --- public/components/event_analytics/explorer/explorer.tsx | 1 - .../event_analytics/explorer/log_patterns/log_patterns.tsx | 2 -- 2 files changed, 3 deletions(-) diff --git a/public/components/event_analytics/explorer/explorer.tsx b/public/components/event_analytics/explorer/explorer.tsx index fa38125da..a321b3bee 100644 --- a/public/components/event_analytics/explorer/explorer.tsx +++ b/public/components/event_analytics/explorer/explorer.tsx @@ -556,7 +556,6 @@ export const Explorer = ({ diff --git a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx index aeb941273..2ed2d408f 100644 --- a/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx +++ b/public/components/event_analytics/explorer/log_patterns/log_patterns.tsx @@ -25,7 +25,6 @@ export interface LogPatternProps { text: string; value: string; }; - setTempQuery: () => string; handleTimeRangePickerRefresh: (flag: boolean) => {}; patterns: PatternTableData[]; query: IQuery; @@ -33,7 +32,6 @@ export interface LogPatternProps { const EventPatterns = ({ selectedIntervalUnit, - setTempQuery, handleTimeRangePickerRefresh, patterns, query,