Skip to content

Commit

Permalink
Merge branch 'main' into mds-update-tocache
Browse files Browse the repository at this point in the history
  • Loading branch information
sumukhswamy authored Apr 26, 2024
2 parents af04339 + 947385f commit 30c533c
Show file tree
Hide file tree
Showing 15 changed files with 3,627 additions and 3,926 deletions.
1 change: 1 addition & 0 deletions common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const PPL_INDEX_INSERT_POINT_REGEX = /(search source|source|index)\s*=\s*
export const PPL_INDEX_REGEX = /(search source|source|index)\s*=\s*([^|\s]+)/i;
export const PPL_WHERE_CLAUSE_REGEX = /\s*where\s+/i;
export const PPL_NEWLINE_REGEX = /[\n\r]+/g;
export const PPL_DESCRIBE_INDEX_REGEX = /(describe)\s+([^|\s]+)/i;

// Observability plugin URI
const BASE_OBSERVABILITY_URI = '/_plugins/_observability';
Expand Down
9 changes: 9 additions & 0 deletions public/components/common/query_utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
OTEL_DATE_FORMAT,
OTEL_METRIC_SUBTYPE,
PROMQL_METRIC_SUBTYPE,
PPL_DESCRIBE_INDEX_REGEX,
} from '../../../../common/constants/shared';
import { IExplorerFields, IQuery } from '../../../../common/types/explorer';
import { SPAN_RESOLUTION_REGEX } from '../../../../common/constants/metrics';
Expand Down Expand Up @@ -219,6 +220,14 @@ export const getIndexPatternFromRawQuery = (query: string): string => {
return getPromQLIndex(query) || getPPLIndex(query);
};

export const getDescribeQueryIndexFromRawQuery = (query: string): string | undefined => {
const matches = query.match(PPL_DESCRIBE_INDEX_REGEX);
if (matches) {
return matches[2];
}
return undefined;
};

function extractSpanAndResolution(query: string) {
if (!query) return;

Expand Down
22 changes: 16 additions & 6 deletions public/components/event_analytics/explorer/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
DATE_PICKER_FORMAT,
DEFAULT_AVAILABILITY_QUERY,
EVENT_ANALYTICS_DOCUMENTATION_URL,
FINAL_QUERY,
PATTERNS_EXTRACTOR_REGEX,
PATTERNS_REGEX,
RAW_QUERY,
Expand All @@ -63,6 +64,7 @@ import { QUERY_ASSIST_API } from '../../../../common/constants/query_assist';
import {
LIVE_END_TIME,
LIVE_OPTIONS,
PPL_DESCRIBE_INDEX_REGEX,
PPL_METRIC_SUBTYPE,
PPL_NEWLINE_REGEX,
} from '../../../../common/constants/shared';
Expand Down Expand Up @@ -540,12 +542,17 @@ export const Explorer = ({
return 0;
}, [countDistribution?.data]);

const showTimeBasedComponents =
(isDefaultDataSourceType || appLogEvents) &&
query[SELECTED_TIMESTAMP] !== '' &&
!query[FINAL_QUERY].match(PPL_DESCRIBE_INDEX_REGEX);

const mainContent = useMemo(() => {
return (
<div className="dscWrapper">
{explorerData && !isEmpty(explorerData.jsonData) ? (
<EuiFlexGroup direction="column" gutterSize="none">
{(isDefaultDataSourceType || appLogEvents) && query[SELECTED_TIMESTAMP] !== '' && (
{showTimeBasedComponents && (
<>
<EuiFlexItem grow={false}>
<EuiPanel hasBorder={false} hasShadow={false} paddingSize="s" color="transparent">
Expand Down Expand Up @@ -594,7 +601,7 @@ export const Explorer = ({
</EuiFlexItem>
</>
)}
{(isDefaultDataSourceType || appLogEvents) && query[SELECTED_TIMESTAMP] !== '' && (
{showTimeBasedComponents && (
<EuiFlexItem grow={false}>
<EuiPanel hasBorder={false} hasShadow={false} paddingSize="s" color="transparent">
<EuiPanel paddingSize="s" style={{ height: '100%' }}>
Expand Down Expand Up @@ -643,11 +650,14 @@ export const Explorer = ({
rows={explorerData.jsonData}
rowsAll={explorerData.jsonDataAll}
explorerFields={explorerFields}
timeStampField={queryRef.current![SELECTED_TIMESTAMP]}
timeStampField={
!query[FINAL_QUERY].match(PPL_DESCRIBE_INDEX_REGEX)
? queryRef.current![SELECTED_TIMESTAMP]
: ''
}
rawQuery={appBasedRef.current || queryRef.current![RAW_QUERY]}
totalHits={
(isDefaultDataSourceType || appLogEvents) &&
query[SELECTED_TIMESTAMP] !== ''
showTimeBasedComponents
? _.sum(countDistribution.data?.['count()']) ||
explorerData.datarows.length
: explorerData.datarows.length
Expand All @@ -656,7 +666,7 @@ export const Explorer = ({
startTime={startTime}
endTime={endTime}
isDefaultDataSource={
explorerSearchMeta.datasources[0].type === DEFAULT_DATA_SOURCE_TYPE
explorerSearchMeta?.datasources?.[0]?.type === DEFAULT_DATA_SOURCE_TYPE
}
/>
)}
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 30c533c

Please sign in to comment.