diff --git a/dashboards-observability/common/constants/autocomplete.ts b/dashboards-observability/common/constants/autocomplete.ts index 3eda599e5..5753603e6 100644 --- a/dashboards-observability/common/constants/autocomplete.ts +++ b/dashboards-observability/common/constants/autocomplete.ts @@ -67,24 +67,21 @@ export interface DataItem { doc_count: any; } -const JUST_SEARCH_REGEX = /\s*search\s+source\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*/; -const SEARCH_WHERE_REGEX = /\s*search\s+source\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*\s*\|\s*where\s+\S+\s*=\s*\S+/; -const SEARCH_MATCH_REGEX = /\s*search\s+source\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*\s*\|\s*where\s+match\(\S+,\s*\S+\)/; -const JUST_SOURCE_REGEX = /\s*source\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*/; -const SOURCE_WHERE_REGEX = /\s*source\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*\s*\|\s*where\s+\S+\s*=\s*\S+/; -const SOURCE_MATCH_REGEX = /\s*source\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*\s*\|\s*where\s+match\(\S+,\s*\S+\)/; +const JUST_SEARCH_REGEX = /\s*(search\s+source|source|index)\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*/; +const SEARCH_WHERE_REGEX = /\s*(search\s+source|source|index)\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*\s*\|\s*where\s+\S+\s*=\s*\S+/; +const SEARCH_MATCH_REGEX = /\s*(search\s+source|source|index)\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*\s*\|\s*where\s+match\(\S+,\s*\S+\)/; export const EMPTY_REGEX = /^\s*\S*$/; export const FIELD_AFTER_COMMAND = /^\s*(dedup|eval|rare|top|rename|where\s+match\()\s+\S*$/; // Regex for where command export const MATCH_FIELD_AFTER_WHERE = /^\s*where\s+\S*$/; export const EQUAL_AFTER_WHERE_FIELD = /^\s*where\s+(\S+)\s+$/; -export const DATA_AFTER_WHERE_EQUAL = /^\s*where\s+\S+\s*=\s*(("(\w|\s)*)|(\d*\.?\d*)|\w*)$/; -export const PIPE_AFTER_WHERE = /^\s*where\s+\S+\s*=\s*(("(\w|\s)+")|(\d+\.?\d*)|\w+)\s+$/; +export const DATA_AFTER_WHERE_EQUAL = /^\s*where\s+\S+\s*=\s*(("(\w|\s|')*)|(\d*\.?\d*)|\w*)$/; +export const PIPE_AFTER_WHERE = /^\s*where\s+\S+\s*=\s*(("(\w|\s|')+")|(\d+\.?\d*)|\w+)\s+$/; export const COMMA_AFTER_FIELD = /^\s*where\s+match\(\s*([^\s,]+)\s*$/; -export const DATA_AFTER_COMMA = /^\s*where\s+match\(\s*\S+\s*,\s*(("(\w|\s)*)|(\d*\.?\d*)|\w*)$/; -export const CLOSE_AFTER_DATA = /^\s*where\s+match\(\s*\S+\s*,\s*(("(\w|\s)+")|(\d+\.?\d*)|\w+)\s+$/; -export const PIPE_AFTER_MATCH = /^\s*where\s+match\(\s*\S+\s*,\s*(("(\w|\s)+")|(\d+\.?\d*)|\w+)\s*\)\s*$/; +export const DATA_AFTER_COMMA = /^\s*where\s+match\(\s*\S+\s*,\s*(("(\w|\s|')*)|(\d*\.?\d*)|\w*)$/; +export const CLOSE_AFTER_DATA = /^\s*where\s+match\(\s*\S+\s*,\s*(("(\w|\s|')+")|(\d+\.?\d*)|\w+)\s+$/; +export const PIPE_AFTER_MATCH = /^\s*where\s+match\(\s*\S+\s*,\s*(("(\w|\s|')+")|(\d+\.?\d*)|\w+)\s*\)\s*$/; // Regex for dedup command export const FIELD_IN_FIELD_LOOP = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*,\s*([^\s,]*)$/; @@ -128,8 +125,8 @@ export const PLUS_MINUS_FIELD_IN_FIELDS_LOOP = /^\s*sort(\s+\d+)?((,\s*)?\s+(\+| export const FIELD_SPAN_AFTER_GROUP_BY = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+\S*$/; export const NUM_FIELD_AFTER_AGGREGATION = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))*(,\s*)?(sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S*$/; export const FIELD_AFTER_SPAN = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+span\(\s*([^\s,]*)\s*$/; -export const CLOSE_AFTER_SPAN = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+span\(\s*[^\s,]+\s*,\s*(("(\w|\s)+")|(\d+\.?\d*)|\w+)\s+$/; -export const PIPE_AFTER_SPAN = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+span\(\s*[^\s,]+\s*,\s*(("(\w|\s)*")|(\d*\.?\d*)|\w*)\s*\)\s*$/; +export const CLOSE_AFTER_SPAN = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+span\(\s*[^\s,]+\s*,\s*(("(\w|\s|')+")|(\d+\.?\d*)|\w+)\s+$/; +export const PIPE_AFTER_SPAN = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+span\(\s*[^\s,]+\s*,\s*(("(\w|\s|')*")|(\d*\.?\d*)|\w*)\s*\)\s*$/; export const CLOSE_AFTER_FIELD = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))*(,\s*)?(sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s+$/; export const PIPE_COMMA_BY_AFTER_AGGREGATION = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+\S*$/; export const PIPE_AFTER_STATS_GROUP_BY = /^\s*stats\s+((,\s*)?((sum|avg|max|min|var_samp|var_pop|stddev_samp|stddev_pop)\(\s*\S+\s*\)\s*)|((,\s*)?count\(\)\s*))+\s+by\s+\S+\s+$/; @@ -182,9 +179,6 @@ export const regexForSuggestion = [ ]; export const regexForIndex = [ - JUST_SOURCE_REGEX, - SOURCE_WHERE_REGEX, - SOURCE_MATCH_REGEX, JUST_SEARCH_REGEX, SEARCH_WHERE_REGEX, SEARCH_MATCH_REGEX, diff --git a/dashboards-observability/public/components/explorer/explorer.tsx b/dashboards-observability/public/components/explorer/explorer.tsx index 869a95123..8f2272a49 100644 --- a/dashboards-observability/public/components/explorer/explorer.tsx +++ b/dashboards-observability/public/components/explorer/explorer.tsx @@ -182,8 +182,8 @@ export const Explorer = ({ const composeFinalQuery = ( curQuery: any, - startTime: string, - endTime: string, + startingTime: string, + endingTime: string, timeField: string, isLiveQuery: boolean ) => { @@ -191,8 +191,8 @@ export const Explorer = ({ if (isEmpty(fullQuery)) return ''; return preprocessQuery({ rawQuery: fullQuery, - startTime, - endTime, + startTime: startingTime, + endTime: endingTime, timeField, isLiveQuery, }); @@ -469,17 +469,16 @@ export const Explorer = ({ if (appLogEvents) { setStartTime(timeRange[0]); setEndTime(timeRange[1]); - } else { - await dispatch( - changeDateRange({ - tabId: requestParams.tabId, - data: { - [RAW_QUERY]: queryRef.current![RAW_QUERY], - [SELECTED_DATE_RANGE]: timeRange, - }, - }) - ); } + await dispatch( + changeDateRange({ + tabId: requestParams.tabId, + data: { + [RAW_QUERY]: queryRef.current![RAW_QUERY], + [SELECTED_DATE_RANGE]: timeRange, + }, + }) + ); }; const showPermissionErrorToast = () => { diff --git a/dashboards-observability/public/components/explorer/log_explorer.tsx b/dashboards-observability/public/components/explorer/log_explorer.tsx index b2f7ce25a..3c4093bc0 100644 --- a/dashboards-observability/public/components/explorer/log_explorer.tsx +++ b/dashboards-observability/public/components/explorer/log_explorer.tsx @@ -21,6 +21,7 @@ import { NEW_SELECTED_QUERY_TAB, TAB_EVENT_ID, TAB_CHART_ID, + APP_ANALYTICS_TAB_ID_REGEX, } from '../../../common/constants/explorer'; import { selectQueryTabs, addTab, setSelectedQueryTab, removeTab } from './slices/query_tab_slice'; import { selectQueries } from './slices/query_slice'; @@ -198,11 +199,13 @@ export const LogExplorer = ({ const memorizedTabs = useMemo(() => { const res = map(tabIds, (tabId) => { - return getQueryTab({ - tabTitle: tabNames[tabId] || TAB_TITLE, - tabId, - handleTabClose, - }); + if (!tabId.match(APP_ANALYTICS_TAB_ID_REGEX)) { + return getQueryTab({ + tabTitle: tabNames[tabId] || TAB_TITLE, + tabId, + handleTabClose, + }); + } }); return res; diff --git a/dashboards-observability/public/services/timestamp/timestamp.ts b/dashboards-observability/public/services/timestamp/timestamp.ts index 80a4e6051..b6ebabab1 100644 --- a/dashboards-observability/public/services/timestamp/timestamp.ts +++ b/dashboards-observability/public/services/timestamp/timestamp.ts @@ -6,6 +6,7 @@ import { isEmpty, isEqual, map } from 'lodash'; import DSLService from '../requests/dsl'; +// eslint-disable-next-line import/no-default-export export default class TimestampUtils { constructor(private dslService: DSLService) {} diff --git a/dashboards-observability/server/services/facets/saved_objects.ts b/dashboards-observability/server/services/facets/saved_objects.ts index d373decf8..0cbffe297 100644 --- a/dashboards-observability/server/services/facets/saved_objects.ts +++ b/dashboards-observability/server/services/facets/saved_objects.ts @@ -8,6 +8,7 @@ import { sampleVisualizations, } from '../../common/helpers/events_explorer/sample_savedObjects'; +// eslint-disable-next-line import/no-default-export export default class SavedObjectFacet { constructor(private client: any) { this.client = client;