Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocomplete enhancements #507

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export const TAB_OVERVIEW_ID_TXT_PFX = 'app-analytics-overview-';
export const TAB_SERVICE_ID_TXT_PFX = 'app-analytics-service-';
export const TAB_TRACE_ID_TXT_PFX = 'app-analytics-trace-';
export const TAB_LOG_ID_TXT_PFX = 'app-analytics-log-';
export const TAB_METRIC_ID_TXT_PFX = 'app-analytics-panel-';
export const TAB_PANEL_ID_TXT_PFX = 'app-analytics-panel-';
export const TAB_CONFIG_ID_TXT_PFX = 'app-analytics-config-';
export const TAB_OVERVIEW_TITLE = 'Overview';
export const TAB_SERVICE_TITLE = 'Services';
export const TAB_TRACE_TITLE = 'Traces & Spans';
export const TAB_LOG_TITLE = 'Log Events';
export const TAB_METRIC_TITLE = 'Metrics';
export const TAB_PANEL_TITLE = 'Panel';
export const TAB_CONFIG_TITLE = 'Configuration';

export const APP_ANALYTICS_API_PREFIX = '/api/observability/application';
40 changes: 23 additions & 17 deletions dashboards-observability/common/constants/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,27 @@ export interface DataItem {
doc_count: any;
}

const JUST_SEARCH_REGEX = /\s*search\s+source\s*=\s*(\S+)/;
const SEARCH_WHERE_REGEX = /\s*search\s+source\s*=\s*(\S+)\s*\|\s*where\s+\S+\s*=\s*\S+/;
const SEARCH_MATCH_REGEX = /\s*search\s+source\s*=\s*(\S+)\s*\|\s*where\s+match\(\S+,\s*\S+\)/;
const JUST_SOURCE_REGEX = /\s*source\s*=\s*(\S+)/;
const SOURCE_WHERE_REGEX = /\s*source\s*=\s*(\S+)\s*\|\s*where\s+\S+\s*=\s*\S+/;
const SOURCE_MATCH_REGEX = /\s*source\s*=\s*(\S+)\s*\|\s*where\s+match\(\S+,\s*\S+\)/;
const JUST_SEARCH_REGEX = /\s*search\s+source\s*=\s*[^\\\/\?\"\<\>\|\s\,\#]*(\s*,\s*[^\\\/\?\"\<\>\|\s\,\#]+)*/;
Copy link
Member

@joshuali925 joshuali925 Feb 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\s*[^\\\/\?\"\<\>\|\s\,\#]*

the first \s* is redundant? nvm it's not.. ignore this comment i need to read it again

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+\)/;
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*\S*$/;
export const PIPE_AFTER_WHERE = /^\s*where\s+\S+\s*=\s*\S+\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*$/;
export const CLOSE_AFTER_DATA = /^\s*where\s+match\(\s*\S+\s*,\s*\S+\s+$/;
export const PIPE_AFTER_MATCH = /^\s*where\s+match\(\s*\S+\s*,\s*\S+\s*\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 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*$/;

// Regex for dedup command
export const FIELD_IN_FIELD_LOOP = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*,\s*\S*$/;
export const FIELD_IN_FIELD_LOOP = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*,\s*([^\s,]*)$/;
export const PIPE_COMMA_AFTER_FIELD = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*\s+$/;
export const PIPE_AFTER_KEEP_EMPTY = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*\s*keepempty=true\s+$/;
export const PIPE_AFTER_CONSECUTIVE = /^\s*dedup\s*\d*\s+\S+\s*(,\s*\S+\s*)*\s*consecutive=true\s+$/;
Expand Down Expand Up @@ -125,8 +125,11 @@ export const PIPE_COMMA_AFTER_SORT_FIELD = /^\s*sort(\s+\d+)?((,\s*)?\s+(\+|\-)?
export const PLUS_MINUS_FIELD_IN_FIELDS_LOOP = /^\s*sort(\s+\d+)?((,\s*)?\s+(\+|\-)?\s*\S+\s*)*,\s+\S*$/;

// Regex for stats command
export const FIELD_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*$/;
export const 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_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_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+$/;
Expand Down Expand Up @@ -167,8 +170,11 @@ export const regexForSuggestion = [
FIELD_AFTER_PLUS_MINUS_SORT,
PLUS_MINUS_FIELD_IN_FIELDS_LOOP,
PIPE_COMMA_AFTER_SORT_FIELD,
FIELD_AFTER_STATS_GROUP_BY,
FIELD_AFTER_AGGREGATION,
FIELD_SPAN_AFTER_GROUP_BY,
NUM_FIELD_AFTER_AGGREGATION,
FIELD_AFTER_SPAN,
CLOSE_AFTER_SPAN,
PIPE_AFTER_SPAN,
CLOSE_AFTER_FIELD,
PIPE_COMMA_BY_AFTER_AGGREGATION,
PIPE_AFTER_STATS_GROUP_BY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ export function AppTable(props: AppTableProps) {
>
Rename
</EuiContextMenuItem>,
<EuiContextMenuItem
key="duplicate"
disabled={applications.length === 0 || selectedApplications.length !== 1}
>
Duplicate
</EuiContextMenuItem>,
// <EuiContextMenuItem
// key="duplicate"
// disabled={applications.length === 0 || selectedApplications.length !== 1}
// >
// Duplicate
// </EuiContextMenuItem>,
<EuiContextMenuItem
key="delete"
disabled={applications.length === 0 || selectedApplications.length === 0}
Expand All @@ -167,7 +167,7 @@ export function AppTable(props: AppTableProps) {
>
Delete
</EuiContextMenuItem>,
<EuiContextMenuItem key="addSample">Add sample application</EuiContextMenuItem>,
// <EuiContextMenuItem key="addSample">Add sample application</EuiContextMenuItem>,
];

const tableColumns = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import {
TAB_LOG_TITLE,
TAB_OVERVIEW_ID_TXT_PFX,
TAB_OVERVIEW_TITLE,
TAB_METRIC_ID_TXT_PFX,
TAB_METRIC_TITLE,
TAB_PANEL_ID_TXT_PFX,
TAB_PANEL_TITLE,
TAB_SERVICE_ID_TXT_PFX,
TAB_SERVICE_TITLE,
TAB_TRACE_ID_TXT_PFX,
Expand All @@ -65,7 +65,7 @@ const TAB_OVERVIEW_ID = uniqueId(TAB_OVERVIEW_ID_TXT_PFX);
const TAB_SERVICE_ID = uniqueId(TAB_SERVICE_ID_TXT_PFX);
const TAB_TRACE_ID = uniqueId(TAB_TRACE_ID_TXT_PFX);
const TAB_LOG_ID = uniqueId(TAB_LOG_ID_TXT_PFX);
const TAB_METRIC_ID = uniqueId(TAB_METRIC_ID_TXT_PFX);
const TAB_PANEL_ID = uniqueId(TAB_PANEL_ID_TXT_PFX);
const TAB_CONFIG_ID = uniqueId(TAB_CONFIG_ID_TXT_PFX);
const searchBarConfigs = {
[TAB_EVENT_ID]: {
Expand Down Expand Up @@ -379,8 +379,8 @@ export function Application(props: AppDetailProps) {
getContent: () => getLog(),
}),
getAppAnalyticsTab({
tabId: TAB_METRIC_ID,
tabTitle: TAB_METRIC_TITLE,
tabId: TAB_PANEL_ID,
tabTitle: TAB_PANEL_TITLE,
getContent: () => getPanel(),
}),
getAppAnalyticsTab({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ export const CreateApp = (props: CreateAppProps) => {
}, [existingAppId]);

useEffect(() => {
setNameWithStorage(existingApp.name);
setDescriptionWithStorage(existingApp.description);
setQueryWithStorage(existingApp.baseQuery);
if (editMode) {
setNameWithStorage(existingApp.name);
setDescriptionWithStorage(existingApp.description);
setQueryWithStorage(existingApp.baseQuery);
}
}, [existingApp]);

const closeFlyout = () => {
Expand Down
Loading