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

Feature query bar #166

Merged
merged 6 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dashboards-observability/common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ 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|source|index)\s*=\s*([^\s]+)(.*)/i;
export const PPL_INDEX_REGEX = /(search source|source|index)\s*=\s*([^|\s]+)/i;
export const PPL_NEWLINE_REGEX = /[\n\r]+/gi;
Copy link
Member

Choose a reason for hiding this comment

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

just a note, the /i might be confusing since regex is not alphabetical?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh yes, sure i'll remove it.


// Observability plugin URI
const BASE_OBSERVABILITY_URI = '/_plugins/_observability';
Expand Down
5 changes: 3 additions & 2 deletions dashboards-observability/common/utils/query_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import datemath from '@elastic/datemath';
import { DATE_PICKER_FORMAT } from '../../common/constants/explorer';
import {
PPL_INDEX_REGEX,
PPL_INDEX_INSERT_POINT_REGEX
PPL_INDEX_INSERT_POINT_REGEX,
PPL_NEWLINE_REGEX
} from '../../common/constants/shared';

export const getIndexPatternFromRawQuery = (query: string) : string => {
Expand Down Expand Up @@ -44,7 +45,7 @@ export const insertDateRangeToQuery = ({
// convert to moment
const start = datemath.parse(startTime)?.format(DATE_PICKER_FORMAT);
const end = datemath.parse(endTime)?.format(DATE_PICKER_FORMAT);
const tokens = rawQuery.match(PPL_INDEX_INSERT_POINT_REGEX);
const tokens = rawQuery.replaceAll(PPL_NEWLINE_REGEX, '').match(PPL_INDEX_INSERT_POINT_REGEX);
Copy link
Member

@joshuali925 joshuali925 Oct 28, 2021

Choose a reason for hiding this comment

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

minor issue, replace can be used instead of replaceAll since there is /g

Edit actually you can ignore this, I remember replaceAll is not supported by some legacy browser but dashboards doesn't support them anyways


if (isEmpty(tokens)) return finalQuery;
finalQuery = `${tokens![1]}=${tokens![2]} | where ${timeField} >= timestamp('${start}') and ${timeField} <= timestamp('${end}')${tokens![3]}`;
Expand Down
12 changes: 6 additions & 6 deletions dashboards-observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"plugin_helpers": "node ../../scripts/plugin_helpers"
},
"dependencies": {
"@reduxjs/toolkit": "^1.6.1",
"plotly.js-dist": "^2.2.0",
"react-plotly.js": "^2.5.1",
"react-graph-vis": "^1.0.5",
"@algolia/autocomplete-core": "^1.4.1",
"@algolia/autocomplete-theme-classic": "^1.2.1",
"@cypress/skip-test": "^2.6.1",
"@nteract/outputs": "^3.0.11",
"@nteract/presentational-components": "^3.4.3",
"@algolia/autocomplete-js": "^1.2.1",
"@algolia/autocomplete-theme-classic": "^1.2.1"
"@reduxjs/toolkit": "^1.6.1",
"plotly.js-dist": "^2.2.0",
"react-graph-vis": "^1.0.5",
"react-plotly.js": "^2.5.1"
},
"devDependencies": {
"@types/enzyme-adapter-react-16": "^1.0.6",
Expand Down
Loading