Skip to content

Commit

Permalink
changed to support query without 'search' prefix (#158)
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Wei <menwe@amazon.com>
  • Loading branch information
mengweieric authored Oct 26, 2021
1 parent 103281b commit eaf5fdd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dashboards-observability/common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions dashboards-observability/common/types/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion dashboards-observability/common/utils/query_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit eaf5fdd

Please sign in to comment.