From ac4331332bc114e32ca7265f157d929032c75d1d Mon Sep 17 00:00:00 2001 From: Eric Wei Date: Mon, 25 Oct 2021 16:58:14 -0700 Subject: [PATCH] changed to support query without 'search' prefix Signed-off-by: Eric Wei --- .../common/constants/shared.ts | 2 +- .../common/types/explorer.ts | 16 ++++++++++++++-- .../common/utils/query_utils.ts | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dashboards-observability/common/constants/shared.ts b/dashboards-observability/common/constants/shared.ts index e82bbd3d5..d120a12a8 100644 --- a/dashboards-observability/common/constants/shared.ts +++ b/dashboards-observability/common/constants/shared.ts @@ -35,7 +35,7 @@ export const observabilityPluginOrder = 6000; export const UI_DATE_FORMAT = 'MM/DD/YYYY hh:mm A'; export const PPL_DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss'; export const PPL_STATS_REGEX = /\|\s*stats/i; -export const PPL_INDEX_INSERT_POINT_REGEX = /search (source|index)\s*=\s*([^\s]+)(.*)/i; +export const PPL_INDEX_INSERT_POINT_REGEX = /(search source|source|index)\s*=\s*([^\s]+)(.*)/i; export const PPL_INDEX_REGEX = /(search source|source|index)\s*=\s*([^|\s]+)/i; // Observability plugin URI diff --git a/dashboards-observability/common/types/explorer.ts b/dashboards-observability/common/types/explorer.ts index 87cbaa6fe..109104462 100644 --- a/dashboards-observability/common/types/explorer.ts +++ b/dashboards-observability/common/types/explorer.ts @@ -20,7 +20,11 @@ import { SELECTED_TIMESTAMP, SELECTED_DATE_RANGE } from '../constants/explorer'; + import { HttpStart } from '../../../../src/core/public'; import SavedObjects from '../../public/services/saved_objects/event_analytics/saved_objects'; + import TimestampUtils from '../../public/services/timestamp/timestamp'; + import PPLService from '../../public/services/requests/ppl'; + import DSLService from '../../public/services/requests/dsl'; export interface IQueryTab { id: string; @@ -61,7 +65,15 @@ export interface IExplorerFields { } export interface ILogExplorerProps { - pplService: any; - dslService: any; + pplService: PPLService; + dslService: DSLService; savedObjects: SavedObjects; + http: HttpStart; + timestampUtils: TimestampUtils; + setToast: ( + title: string, + color?: string, + text?: React.ReactChild | undefined, + side?: string | undefined + ) => void; } \ No newline at end of file diff --git a/dashboards-observability/common/utils/query_utils.ts b/dashboards-observability/common/utils/query_utils.ts index 9407b7339..648f21c2e 100644 --- a/dashboards-observability/common/utils/query_utils.ts +++ b/dashboards-observability/common/utils/query_utils.ts @@ -47,7 +47,7 @@ export const insertDateRangeToQuery = ({ const tokens = rawQuery.match(PPL_INDEX_INSERT_POINT_REGEX); if (isEmpty(tokens)) return finalQuery; - finalQuery = `search ${tokens![1]}=${tokens![2]} | where ${timeField} >= timestamp('${start}') and ${timeField} <= timestamp('${end}')${tokens![3]}`; + finalQuery = `${tokens![1]}=${tokens![2]} | where ${timeField} >= timestamp('${start}') and ${timeField} <= timestamp('${end}')${tokens![3]}`; return finalQuery; }; \ No newline at end of file