mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ML] Adds query history and improves performance for ES|QL Data visualizer (#179098)
## Summary This PR adds query history (see https://github.com/elastic/kibana/issues/179672) and improves performance for ES|QL Data visualizer  It: - Adds drop_null_column=true to reduce making aggregations on empty fields - Adds better support for geo point/geo shape maps where time field is not defined in the data view, but '@timestamp' does exist - Adds a new Top sampled values to match with the unified field list popover in Discover - Removes ES|QL link from search bar if not enabled  - Closes https://github.com/elastic/kibana/issues/180072 [Flaky test suite runner](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5699#018ee80e-3ebf-4d9b-ab79-c8013f3f4c1d)... 25/25 successful runs ✅ ### Checklist Delete any items that are not applicable to this PR. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
20af76f331
commit
4546d274e8
24 changed files with 355 additions and 263 deletions
|
@ -62,9 +62,16 @@ export interface FieldVisStats {
|
|||
};
|
||||
fieldName?: string;
|
||||
isTopValuesSampled?: boolean;
|
||||
topValuesSampleSize?: number;
|
||||
max?: number;
|
||||
median?: number;
|
||||
min?: number;
|
||||
sampledValues?: Array<{
|
||||
key: number | string;
|
||||
doc_count: number;
|
||||
percent: number;
|
||||
key_as_string?: string;
|
||||
}>;
|
||||
topValues?: Array<{
|
||||
key: number | string;
|
||||
doc_count: number;
|
||||
|
|
|
@ -93,6 +93,7 @@ export interface StringFieldStats {
|
|||
fieldName: string;
|
||||
isTopValuesSampled: boolean;
|
||||
topValues: Bucket[];
|
||||
sampledValues?: Bucket[];
|
||||
topValuesSampleSize?: number;
|
||||
topValuesSamplerShardSize?: number;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ export const GeoPointContentWithMap: FC<{
|
|||
dataView: DataView | undefined;
|
||||
combinedQuery?: CombinedQuery;
|
||||
esql?: string;
|
||||
}> = ({ config, dataView, combinedQuery, esql }) => {
|
||||
timeFieldName?: string;
|
||||
}> = ({ config, dataView, combinedQuery, esql, timeFieldName }) => {
|
||||
const { stats } = config;
|
||||
const [layerList, setLayerList] = useState<LayerDescriptor[]>([]);
|
||||
const {
|
||||
|
@ -72,7 +73,7 @@ export const GeoPointContentWithMap: FC<{
|
|||
},
|
||||
],
|
||||
dataViewId: dataView.id,
|
||||
dateField: dataView.timeFieldName,
|
||||
dateField: dataView.timeFieldName ?? timeFieldName,
|
||||
geoField: config.fieldName,
|
||||
esql,
|
||||
narrowByGlobalSearch: true,
|
||||
|
|
|
@ -32,6 +32,7 @@ export const IndexBasedDataVisualizerExpandedRow = ({
|
|||
onAddFilter,
|
||||
esql,
|
||||
totalDocuments,
|
||||
timeFieldName,
|
||||
typeAccessor = 'type',
|
||||
}: {
|
||||
item: FieldVisConfig;
|
||||
|
@ -44,6 +45,7 @@ export const IndexBasedDataVisualizerExpandedRow = ({
|
|||
* Callback to add a filter to filter bar
|
||||
*/
|
||||
onAddFilter?: (field: DataViewField | string, value: string, type: '+' | '-') => void;
|
||||
timeFieldName?: string;
|
||||
}) => {
|
||||
const config = { ...item, stats: { ...item.stats, totalDocuments } };
|
||||
const { loading, existsInDocs, fieldName } = config;
|
||||
|
@ -77,6 +79,7 @@ export const IndexBasedDataVisualizerExpandedRow = ({
|
|||
dataView={dataView}
|
||||
combinedQuery={combinedQuery}
|
||||
esql={esql}
|
||||
timeFieldName={timeFieldName}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
@ -55,6 +55,16 @@ export const KeywordContent: FC<FieldDataRowProps> = ({ config, onAddFilter }) =
|
|||
barColor="success"
|
||||
onAddFilter={onAddFilter}
|
||||
/>
|
||||
{config.stats?.sampledValues && fieldName !== undefined ? (
|
||||
<TopValues
|
||||
stats={stats}
|
||||
fieldFormat={fieldFormat}
|
||||
barColor="success"
|
||||
onAddFilter={onAddFilter}
|
||||
showSampledValues={true}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{EMSSuggestion && stats && <ChoroplethMap stats={stats} suggestion={EMSSuggestion} />}
|
||||
</ExpandedRowContent>
|
||||
);
|
||||
|
|
|
@ -37,6 +37,7 @@ interface Props {
|
|||
barColor?: 'primary' | 'success' | 'danger' | 'subdued' | 'accent';
|
||||
compressed?: boolean;
|
||||
onAddFilter?: (field: DataViewField | string, value: string, type: '+' | '-') => void;
|
||||
showSampledValues?: boolean;
|
||||
}
|
||||
|
||||
function getPercentLabel(percent: number): string {
|
||||
|
@ -47,7 +48,20 @@ function getPercentLabel(percent: number): string {
|
|||
}
|
||||
}
|
||||
|
||||
export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor, compressed, onAddFilter }) => {
|
||||
export const TopValues: FC<Props> = ({
|
||||
stats,
|
||||
fieldFormat,
|
||||
barColor,
|
||||
compressed,
|
||||
onAddFilter,
|
||||
/** Top values by default show % of time a value exist in sampled records/rows (i.e. value A exists in 10% of sampled records)
|
||||
* showSampledValues: true shows % of times a value exist in all arrays of values that have been flattened
|
||||
* Example for 4 records: ["a", "a", "b"], ["b", "b", "c"], "d", "e"
|
||||
* "a" exists in 1/4 records (50% - showSampledValues: false),
|
||||
* "a" exists in 2/8 sampled values (25% - showSampledValues: true).
|
||||
*/
|
||||
showSampledValues = false,
|
||||
}) => {
|
||||
const {
|
||||
services: {
|
||||
data: { fieldFormats },
|
||||
|
@ -55,10 +69,71 @@ export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor, compressed,
|
|||
} = useDataVisualizerKibana();
|
||||
|
||||
if (stats === undefined || !stats.topValues) return null;
|
||||
const { topValues: originalTopValues, fieldName, sampleCount } = stats;
|
||||
const { fieldName, sampleCount } = stats;
|
||||
|
||||
const originalTopValues = (showSampledValues ? stats.sampledValues : stats.topValues) ?? [];
|
||||
if (originalTopValues?.length === 0) return null;
|
||||
const totalDocuments = Math.min(sampleCount ?? 0, stats.totalDocuments ?? 0);
|
||||
const totalDocuments = showSampledValues
|
||||
? stats.topValuesSampleSize ?? 0
|
||||
: Math.min(sampleCount ?? 0, stats.totalDocuments ?? 0);
|
||||
|
||||
const getMessage = () => {
|
||||
if (showSampledValues && stats.topValuesSampleSize !== undefined) {
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.dataGrid.field.topValues.calculatedFromSampleValuesLabel"
|
||||
defaultMessage="Calculated from {sampledDocumentsFormatted} sample {sampledDocuments, plural, one {value} other {values}}."
|
||||
values={{
|
||||
sampledDocuments: stats.topValuesSampleSize,
|
||||
sampledDocumentsFormatted: (
|
||||
<strong>
|
||||
{fieldFormats
|
||||
.getDefaultInstance(KBN_FIELD_TYPES.NUMBER, [ES_FIELD_TYPES.INTEGER])
|
||||
.convert(stats.topValuesSampleSize)}
|
||||
</strong>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return totalDocuments > (sampleCount ?? 0) ? (
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.dataGrid.field.topValues.calculatedFromSampleRecordsLabel"
|
||||
defaultMessage="Calculated from {sampledDocumentsFormatted} sample {sampledDocuments, plural, one {record} other {records}}."
|
||||
values={{
|
||||
sampledDocuments: sampleCount,
|
||||
sampledDocumentsFormatted: (
|
||||
<strong>
|
||||
{fieldFormats
|
||||
.getDefaultInstance(KBN_FIELD_TYPES.NUMBER, [ES_FIELD_TYPES.INTEGER])
|
||||
.convert(sampleCount)}
|
||||
</strong>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.dataGrid.field.topValues.calculatedFromTotalRecordsLabel"
|
||||
defaultMessage="Calculated from {totalDocumentsFormatted} {totalDocuments, plural, one {record} other {records}}."
|
||||
values={{
|
||||
totalDocuments,
|
||||
totalDocumentsFormatted: (
|
||||
<strong>
|
||||
{fieldFormats
|
||||
.getDefaultInstance(KBN_FIELD_TYPES.NUMBER, [ES_FIELD_TYPES.INTEGER])
|
||||
.convert(totalDocuments ?? 0)}
|
||||
</strong>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
const countsElement = (
|
||||
<EuiText color="subdued" size="xs">
|
||||
{getMessage()}
|
||||
</EuiText>
|
||||
);
|
||||
|
||||
const topValues = originalTopValues.map((bucket) => ({
|
||||
...bucket,
|
||||
|
@ -70,52 +145,23 @@ export const TopValues: FC<Props> = ({ stats, fieldFormat, barColor, compressed,
|
|||
1 - (topValues ? topValues.reduce((acc, bucket) => acc + bucket.percent, 0) : 0);
|
||||
const topValuesOtherCount = Math.floor(topValuesOtherCountPercent * (sampleCount ?? 0));
|
||||
|
||||
const countsElement = (
|
||||
<EuiText color="subdued" size="xs">
|
||||
{totalDocuments > (sampleCount ?? 0) ? (
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.dataGrid.field.topValues.calculatedFromSampleRecordsLabel"
|
||||
defaultMessage="Calculated from {sampledDocumentsFormatted} sample {sampledDocuments, plural, one {record} other {records}}."
|
||||
values={{
|
||||
sampledDocuments: sampleCount,
|
||||
sampledDocumentsFormatted: (
|
||||
<strong>
|
||||
{fieldFormats
|
||||
.getDefaultInstance(KBN_FIELD_TYPES.NUMBER, [ES_FIELD_TYPES.INTEGER])
|
||||
.convert(sampleCount)}
|
||||
</strong>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.dataGrid.field.topValues.calculatedFromTotalRecordsLabel"
|
||||
defaultMessage="Calculated from {totalDocumentsFormatted} {totalDocuments, plural, one {record} other {records}}."
|
||||
values={{
|
||||
totalDocuments,
|
||||
totalDocumentsFormatted: (
|
||||
<strong>
|
||||
{fieldFormats
|
||||
.getDefaultInstance(KBN_FIELD_TYPES.NUMBER, [ES_FIELD_TYPES.INTEGER])
|
||||
.convert(totalDocuments ?? 0)}
|
||||
</strong>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</EuiText>
|
||||
);
|
||||
|
||||
return (
|
||||
<ExpandedRowPanel
|
||||
dataTestSubj={'dataVisualizerFieldDataTopValues'}
|
||||
className={classNames('dvPanel__wrapper', compressed ? 'dvPanel--compressed' : undefined)}
|
||||
>
|
||||
<ExpandedRowFieldHeader>
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.dataGrid.field.topValuesLabel"
|
||||
defaultMessage="Top values"
|
||||
/>
|
||||
{showSampledValues ? (
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.dataGrid.field.topSampledValuesLabel"
|
||||
defaultMessage="Top sampled values"
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.dataGrid.field.topValuesLabel"
|
||||
defaultMessage="Top values"
|
||||
/>
|
||||
)}
|
||||
</ExpandedRowFieldHeader>
|
||||
|
||||
<div
|
||||
|
|
|
@ -161,6 +161,7 @@ export const IndexDataVisualizerESQL: FC<IndexDataVisualizerESQLProps> = (dataVi
|
|||
const {
|
||||
totalCount,
|
||||
progress: combinedProgress,
|
||||
queryHistoryStatus,
|
||||
overallStatsProgress,
|
||||
configs,
|
||||
documentCountStats,
|
||||
|
@ -256,7 +257,7 @@ export const IndexDataVisualizerESQL: FC<IndexDataVisualizerESQLProps> = (dataVi
|
|||
detectTimestamp={true}
|
||||
hideMinimizeButton={true}
|
||||
hideRunQueryText={false}
|
||||
hideQueryHistory
|
||||
isLoading={queryHistoryStatus ?? false}
|
||||
/>
|
||||
|
||||
<EuiFlexGroup gutterSize="m" direction={isWithinLargeBreakpoint ? 'column' : 'row'}>
|
||||
|
|
|
@ -270,10 +270,13 @@ export const useESQLDataVisualizerData = (
|
|||
documentCountStats,
|
||||
totalCount,
|
||||
overallStats,
|
||||
totalFields,
|
||||
overallStatsProgress,
|
||||
columns,
|
||||
cancelOverallStatsRequest,
|
||||
timeFieldName,
|
||||
queryHistoryStatus,
|
||||
exampleDocs,
|
||||
} = useESQLOverallStatsData(fieldStatsRequest);
|
||||
|
||||
const [metricConfigs, setMetricConfigs] = useState(defaults.metricConfigs);
|
||||
|
@ -497,13 +500,7 @@ export const useESQLDataVisualizerData = (
|
|||
if (!overallStats) return;
|
||||
|
||||
let _visibleFieldsCount = 0;
|
||||
let _totalFieldsCount = 0;
|
||||
Object.keys(overallStats).forEach((key) => {
|
||||
const fieldsGroup = overallStats[key as keyof typeof overallStats];
|
||||
if (Array.isArray(fieldsGroup) && fieldsGroup.length > 0) {
|
||||
_totalFieldsCount += fieldsGroup.length;
|
||||
}
|
||||
});
|
||||
const _totalFieldsCount = totalFields ?? 0;
|
||||
|
||||
if (showEmptyFields === true) {
|
||||
_visibleFieldsCount = _totalFieldsCount;
|
||||
|
@ -513,7 +510,7 @@ export const useESQLDataVisualizerData = (
|
|||
overallStats.nonAggregatableExistsFields.length;
|
||||
}
|
||||
return { visibleFieldsCount: _visibleFieldsCount, totalFieldsCount: _totalFieldsCount };
|
||||
}, [overallStats, showEmptyFields]);
|
||||
}, [overallStats, showEmptyFields, totalFields]);
|
||||
|
||||
useEffect(
|
||||
() => {
|
||||
|
@ -533,9 +530,14 @@ export const useESQLDataVisualizerData = (
|
|||
visibleFieldTypes
|
||||
).filteredFields;
|
||||
|
||||
const examples = exampleDocs?.reduce((map, exampleDoc) => {
|
||||
map.set(exampleDoc.fieldName, exampleDoc);
|
||||
return map;
|
||||
}, new Map());
|
||||
|
||||
if (fieldStatsProgress.loaded === 100 && fieldStats) {
|
||||
combinedConfigs = combinedConfigs.map((c) => {
|
||||
const loadedFullStats = fieldStats.get(c.fieldName) ?? {};
|
||||
const loadedFullStats = fieldStats.get(c.fieldName) ?? examples?.get(c.fieldName) ?? {};
|
||||
return loadedFullStats
|
||||
? {
|
||||
...c,
|
||||
|
@ -555,6 +557,7 @@ export const useESQLDataVisualizerData = (
|
|||
fieldStatsProgress.loaded,
|
||||
dataVisualizerListState.pageIndex,
|
||||
dataVisualizerListState.pageSize,
|
||||
exampleDocs,
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -570,13 +573,14 @@ export const useESQLDataVisualizerData = (
|
|||
esql={query.esql}
|
||||
totalDocuments={totalCount}
|
||||
typeAccessor="secondaryType"
|
||||
timeFieldName={timeFieldName}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return map;
|
||||
}, {} as ItemIdToExpandedRowMap);
|
||||
},
|
||||
[currentDataView, totalCount, query.esql]
|
||||
[currentDataView, totalCount, query.esql, timeFieldName]
|
||||
);
|
||||
|
||||
const combinedProgress = useMemo(
|
||||
|
@ -626,5 +630,6 @@ export const useESQLDataVisualizerData = (
|
|||
showEmptyFields,
|
||||
fieldsCountStats,
|
||||
timeFieldName,
|
||||
queryHistoryStatus,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -21,7 +21,6 @@ import { getESQLNumericFieldStats } from '../../search_strategy/esql_requests/ge
|
|||
import { getESQLKeywordFieldStats } from '../../search_strategy/esql_requests/get_keyword_fields';
|
||||
import { getESQLDateFieldStats } from '../../search_strategy/esql_requests/get_date_field_stats';
|
||||
import { getESQLBooleanFieldStats } from '../../search_strategy/esql_requests/get_boolean_field_stats';
|
||||
import { getESQLExampleFieldValues } from '../../search_strategy/esql_requests/get_text_field_stats';
|
||||
|
||||
export const useESQLFieldStatsData = <T extends Column>({
|
||||
searchQuery,
|
||||
|
@ -114,19 +113,6 @@ export const useESQLFieldStatsData = <T extends Column>({
|
|||
esqlBaseQuery,
|
||||
}).then(addToProcessedFieldStats);
|
||||
|
||||
// GETTING STATS FOR TEXT FIELDS
|
||||
await getESQLExampleFieldValues({
|
||||
columns: columns.filter(
|
||||
(f) =>
|
||||
f.secondaryType === 'text' ||
|
||||
f.secondaryType === 'geo_point' ||
|
||||
f.secondaryType === 'geo_shape'
|
||||
),
|
||||
filter,
|
||||
runRequest,
|
||||
esqlBaseQuery,
|
||||
}).then(addToProcessedFieldStats);
|
||||
|
||||
// GETTING STATS FOR DATE FIELDS
|
||||
await getESQLDateFieldStats({
|
||||
columns: columns.filter((f) => f.secondaryType === 'date'),
|
||||
|
|
|
@ -9,12 +9,13 @@ import { ESQL_SEARCH_STRATEGY, KBN_FIELD_TYPES } from '@kbn/data-plugin/common';
|
|||
import type { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types';
|
||||
import type { AggregateQuery } from '@kbn/es-query';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { useCallback, useEffect, useMemo, useReducer, useRef } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
||||
import { type UseCancellableSearch, useCancellableSearch } from '@kbn/ml-cancellable-search';
|
||||
import type { estypes } from '@elastic/elasticsearch';
|
||||
import type { ISearchOptions } from '@kbn/data-plugin/common';
|
||||
import type { TimeBucketsInterval } from '@kbn/ml-time-buckets';
|
||||
import { getESQLWithSafeLimit, ESQL_LATEST_VERSION } from '@kbn/esql-utils';
|
||||
import { isDefined } from '@kbn/ml-is-defined';
|
||||
import { OMIT_FIELDS } from '../../../../../common/constants';
|
||||
import type {
|
||||
DataStatsFetchProgress,
|
||||
|
@ -25,7 +26,6 @@ import { useDataVisualizerKibana } from '../../../kibana_context';
|
|||
import { getInitialProgress, getReducer } from '../../progress_utils';
|
||||
import { getSafeESQLName, isESQLQuery } from '../../search_strategy/requests/esql_utils';
|
||||
import type { NonAggregatableField } from '../../types/overall_stats';
|
||||
import { getESQLSupportedAggs } from '../../utils/get_supported_aggs';
|
||||
import { getESQLOverallStats } from '../../search_strategy/esql_requests/get_count_and_cardinality';
|
||||
import type { AggregatableField } from '../../types/esql_data_visualizer';
|
||||
import {
|
||||
|
@ -33,13 +33,19 @@ import {
|
|||
type HandleErrorCallback,
|
||||
} from '../../search_strategy/esql_requests/handle_error';
|
||||
|
||||
export interface Column {
|
||||
interface ESQLColumn {
|
||||
type: string;
|
||||
name: string;
|
||||
}
|
||||
interface ESQLResponse {
|
||||
rawResponse: { columns: ESQLColumn[]; all_columns: ESQLColumn[]; values: unknown[][] };
|
||||
}
|
||||
export interface Column extends ESQLColumn {
|
||||
secondaryType: string;
|
||||
}
|
||||
|
||||
interface Data {
|
||||
totalFields?: number;
|
||||
timeFieldName?: string;
|
||||
columns?: Column[];
|
||||
totalCount?: number;
|
||||
|
@ -52,6 +58,7 @@ interface Data {
|
|||
nonAggregatableExistsFields: NonAggregatableField[];
|
||||
nonAggregatableNotExistsFields: NonAggregatableField[];
|
||||
};
|
||||
exampleDocs: Array<{ fieldName: string; examples: string[] }> | undefined;
|
||||
}
|
||||
|
||||
const getESQLDocumentCountStats = async (
|
||||
|
@ -158,6 +165,8 @@ export const getInitialData = (): Data => ({
|
|||
timeFieldName: undefined,
|
||||
columns: undefined,
|
||||
totalCount: undefined,
|
||||
exampleDocs: undefined,
|
||||
totalFields: undefined,
|
||||
});
|
||||
|
||||
const NON_AGGREGATABLE_FIELD_TYPES = new Set<string>([
|
||||
|
@ -201,6 +210,7 @@ export const useESQLOverallStatsData = (
|
|||
const { runRequest, cancelRequest } = useCancellableSearch(data);
|
||||
|
||||
const [tableData, setTableData] = useReducer(getReducer<Data>(), getInitialData());
|
||||
const [queryHistoryStatus, setQueryHistoryStatus] = useState<boolean | undefined>(false);
|
||||
const [overallStatsProgress, setOverallStatsProgress] = useReducer(
|
||||
getReducer<DataStatsFetchProgress>(),
|
||||
getInitialProgress()
|
||||
|
@ -244,24 +254,37 @@ export const useESQLOverallStatsData = (
|
|||
// For doc count chart, we want the full base query without any limit
|
||||
const esqlBaseQuery = searchQuery.esql;
|
||||
|
||||
const columnsResp = await runRequest(
|
||||
setQueryHistoryStatus(true);
|
||||
|
||||
// Note: dropNullColumns will return empty [] for all_columns if limit size is 0
|
||||
// So we are making a query with default limit
|
||||
// And use this one query to
|
||||
// 1) identify populated/empty fields
|
||||
// 2) gather examples for populated text fields
|
||||
const columnsResp = (await runRequest(
|
||||
{
|
||||
params: {
|
||||
query: esqlBaseQuery + '| LIMIT 0',
|
||||
// Doing this to match with the default limit
|
||||
query: esqlBaseQuery,
|
||||
...(filter ? { filter } : {}),
|
||||
version: ESQL_LATEST_VERSION,
|
||||
dropNullColumns: true,
|
||||
},
|
||||
},
|
||||
{ strategy: ESQL_SEARCH_STRATEGY }
|
||||
);
|
||||
const columns = columnsResp?.rawResponse
|
||||
? // @ts-expect-error ES types need to be updated with columns for ESQL queries
|
||||
(columnsResp.rawResponse.columns.map((c) => ({
|
||||
...c,
|
||||
secondaryType: getSupportedFieldType(c.type),
|
||||
})) as Column[])
|
||||
)) as ESQLResponse | undefined;
|
||||
setQueryHistoryStatus(false);
|
||||
|
||||
const columnInfo = columnsResp?.rawResponse
|
||||
? columnsResp.rawResponse.all_columns ?? columnsResp.rawResponse.columns
|
||||
: [];
|
||||
|
||||
const populatedColumns = new Set(columnsResp?.rawResponse.columns.map((c) => c.name));
|
||||
const columns = columnInfo.map((c) => ({
|
||||
...c,
|
||||
secondaryType: getSupportedFieldType(c.type),
|
||||
})) as Column[];
|
||||
|
||||
const timeFields = columns.filter((d) => d.type === 'date');
|
||||
|
||||
const dataViewTimeField = timeFields.find(
|
||||
|
@ -324,20 +347,10 @@ export const useESQLOverallStatsData = (
|
|||
setOverallStatsProgress({
|
||||
loaded: 50,
|
||||
});
|
||||
const aggregatableFields: Array<{
|
||||
fieldName: string;
|
||||
name: string;
|
||||
type: string;
|
||||
supportedAggs: Set<string>;
|
||||
secondaryType: string;
|
||||
aggregatable: boolean;
|
||||
}> = [];
|
||||
const nonAggregatableFields: Array<{
|
||||
fieldName: string;
|
||||
name: string;
|
||||
type: string;
|
||||
secondaryType: string;
|
||||
}> = [];
|
||||
const aggregatableNotExistsFields: AggregatableField[] = [];
|
||||
|
||||
const nonAggregatableNotExistsFields: NonAggregatableField[] = [];
|
||||
|
||||
const fields = columns
|
||||
// Some field types are not supported by ESQL yet
|
||||
// Also, temporarily removing null columns because it causes problems with some aggs
|
||||
|
@ -346,30 +359,33 @@ export const useESQLOverallStatsData = (
|
|||
.map((field) => {
|
||||
return { ...field, aggregatable: !NON_AGGREGATABLE_FIELD_TYPES.has(field.type) };
|
||||
});
|
||||
|
||||
const populatedFields = fields.filter((field) => populatedColumns.has(field.name));
|
||||
fields?.forEach((field) => {
|
||||
const fieldName = field.name;
|
||||
|
||||
if (!OMIT_FIELDS.includes(fieldName)) {
|
||||
if (!field.aggregatable) {
|
||||
nonAggregatableFields.push({
|
||||
...field,
|
||||
fieldName: field.name,
|
||||
secondaryType: getSupportedFieldType(field.type),
|
||||
});
|
||||
if (!populatedColumns.has(fieldName)) {
|
||||
nonAggregatableNotExistsFields.push({
|
||||
...field,
|
||||
fieldName: field.name,
|
||||
secondaryType: getSupportedFieldType(field.type),
|
||||
existsInDocs: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
aggregatableFields.push({
|
||||
...field,
|
||||
fieldName: field.name,
|
||||
secondaryType: getSupportedFieldType(field.type),
|
||||
supportedAggs: getESQLSupportedAggs(field, true),
|
||||
aggregatable: true,
|
||||
});
|
||||
if (!populatedColumns.has(fieldName)) {
|
||||
aggregatableNotExistsFields.push({
|
||||
...field,
|
||||
fieldName: field.name,
|
||||
aggregatable: true,
|
||||
existsInDocs: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setTableData({ aggregatableFields, nonAggregatableFields });
|
||||
|
||||
// COUNT + CARDINALITY
|
||||
// For % count & cardinality, we want the full base query WITH specified limit
|
||||
// to safeguard against huge datasets
|
||||
|
@ -394,20 +410,40 @@ export const useESQLOverallStatsData = (
|
|||
if (totalCount > 0 && fields.length > 0) {
|
||||
const stats = await getESQLOverallStats({
|
||||
runRequest,
|
||||
fields,
|
||||
// Only need to fetch stats for fields we know are populated
|
||||
fields: populatedFields,
|
||||
esqlBaseQueryWithLimit,
|
||||
filter,
|
||||
limitSize: limit,
|
||||
totalCount,
|
||||
onError,
|
||||
});
|
||||
if (!stats) return;
|
||||
stats.aggregatableNotExistsFields = aggregatableNotExistsFields;
|
||||
stats.nonAggregatableNotExistsFields = nonAggregatableNotExistsFields;
|
||||
|
||||
setTableData({ overallStats: stats });
|
||||
setTableData({ overallStats: stats, totalFields: columns.length });
|
||||
setOverallStatsProgress({
|
||||
loaded: 100,
|
||||
isRunning: false,
|
||||
error: undefined,
|
||||
});
|
||||
|
||||
const columnsWithExamples = columnInfo.reduce((hashmap, curr, idx) => {
|
||||
if (curr.type === 'text' || curr.type === 'geo_point' || curr.type === 'geo_shape') {
|
||||
hashmap[curr.name] = idx;
|
||||
}
|
||||
return hashmap;
|
||||
}, {} as Record<string, number>);
|
||||
|
||||
const exampleDocs = Object.entries(columnsWithExamples).map(([fieldName, idx]) => {
|
||||
const examples = [...new Set(columnsResp?.rawResponse?.values.map((row) => row[idx]))]
|
||||
.filter(isDefined)
|
||||
.slice(0, 10);
|
||||
return { fieldName, examples: examples as string[] };
|
||||
});
|
||||
|
||||
setTableData({ exampleDocs });
|
||||
}
|
||||
} catch (error) {
|
||||
// If error already handled in sub functions, no need to propogate
|
||||
|
@ -415,10 +451,10 @@ export const useESQLOverallStatsData = (
|
|||
toasts.addError(error, {
|
||||
title: fieldStatsErrorTitle,
|
||||
});
|
||||
// Log error to console for better debugging
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`${fieldStatsErrorTitle}: fetchOverallStats`, error);
|
||||
}
|
||||
// Log error to console for better debugging
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`${fieldStatsErrorTitle}: fetchOverallStats`, error);
|
||||
}
|
||||
},
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
|
@ -431,7 +467,12 @@ export const useESQLOverallStatsData = (
|
|||
}, [startFetch]);
|
||||
|
||||
return useMemo(
|
||||
() => ({ ...tableData, overallStatsProgress, cancelOverallStatsRequest: cancelRequest }),
|
||||
[tableData, overallStatsProgress, cancelRequest]
|
||||
() => ({
|
||||
...tableData,
|
||||
overallStatsProgress,
|
||||
cancelOverallStatsRequest: cancelRequest,
|
||||
queryHistoryStatus,
|
||||
}),
|
||||
[tableData, overallStatsProgress, cancelRequest, queryHistoryStatus]
|
||||
);
|
||||
};
|
||||
|
|
|
@ -318,7 +318,6 @@ export function useOverallStats<TParams extends OverallStatsSearchStrategyParams
|
|||
const docs = resp.rawResponse.hits.hits.map((d) =>
|
||||
d.fields ? getProcessedFields(d.fields) : {}
|
||||
);
|
||||
|
||||
sampledNonAggregatableFieldsExamples = docs;
|
||||
}
|
||||
if (isAggregatableFieldOverallStats(resp)) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import '../_index.scss';
|
||||
import { pick } from 'lodash';
|
||||
import type { FC } from 'react';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import React, { useCallback, useEffect, useState, useMemo } from 'react';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
import { parse, stringify } from 'query-string';
|
||||
import { isEqual } from 'lodash';
|
||||
|
@ -30,6 +30,9 @@ import {
|
|||
UrlStateProvider,
|
||||
} from '@kbn/ml-url-state';
|
||||
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
|
||||
import { ENABLE_ESQL } from '@kbn/discover-utils';
|
||||
import { EuiCallOut } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { getCoreStart, getPluginsStart } from '../../kibana_services';
|
||||
import {
|
||||
type IndexDataVisualizerViewProps,
|
||||
|
@ -85,6 +88,22 @@ export const getLocatorParams = (params: {
|
|||
};
|
||||
|
||||
const DataVisualizerESQLStateContextProvider = () => {
|
||||
const { services } = useDataVisualizerKibana();
|
||||
const isEsqlEnabled = useMemo(() => services.uiSettings.get(ENABLE_ESQL), [services.uiSettings]);
|
||||
|
||||
if (!isEsqlEnabled) {
|
||||
return (
|
||||
<EuiCallOut
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="xpack.dataVisualizer.esqlNotEnabledCalloutTitle"
|
||||
defaultMessage="ES|QL is not enabled"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<UrlStateProvider>
|
||||
<IndexDataVisualizerESQL />
|
||||
|
@ -314,6 +333,7 @@ export const IndexDataVisualizer: FC<Props> = ({
|
|||
charts,
|
||||
unifiedSearch,
|
||||
};
|
||||
|
||||
const datePickerDeps: DatePickerDependencies = {
|
||||
...pick(services, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
|
||||
uiSettingsKeys: UI_SETTINGS,
|
||||
|
|
|
@ -9,6 +9,7 @@ import type { UseCancellableSearch } from '@kbn/ml-cancellable-search';
|
|||
import type { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types';
|
||||
import { ESQL_SEARCH_STRATEGY } from '@kbn/data-plugin/common';
|
||||
import pLimit from 'p-limit';
|
||||
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
|
||||
import type { Column } from '../../hooks/esql/use_esql_overall_stats_data';
|
||||
import { getSafeESQLName } from '../requests/esql_utils';
|
||||
import { isFulfilled, isRejected } from '../../../common/util/promise_all_settled_utils';
|
||||
|
@ -45,6 +46,7 @@ export const getESQLBooleanFieldStats = async ({
|
|||
params: {
|
||||
query: esqlBaseQuery + query,
|
||||
...(filter ? { filter } : {}),
|
||||
version: ESQL_LATEST_VERSION,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -102,6 +102,7 @@ const getESQLOverallStatsInChunk = async ({
|
|||
countQuery += fieldsToFetch.map((field) => field.query).join(',');
|
||||
|
||||
const query = esqlBaseQueryWithLimit + (evalQuery ? ' | EVAL ' + evalQuery : '') + countQuery;
|
||||
|
||||
const request = {
|
||||
params: {
|
||||
query,
|
||||
|
|
|
@ -9,6 +9,7 @@ import type { UseCancellableSearch } from '@kbn/ml-cancellable-search';
|
|||
import type { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types';
|
||||
import { ESQL_SEARCH_STRATEGY } from '@kbn/data-plugin/common';
|
||||
import pLimit from 'p-limit';
|
||||
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
|
||||
import type { Column } from '../../hooks/esql/use_esql_overall_stats_data';
|
||||
import { getSafeESQLName } from '../requests/esql_utils';
|
||||
import { isFulfilled, isRejected } from '../../../common/util/promise_all_settled_utils';
|
||||
|
@ -33,17 +34,19 @@ export const getESQLKeywordFieldStats = async ({
|
|||
const keywordFields = columns.map((field) => {
|
||||
const query =
|
||||
esqlBaseQuery +
|
||||
`| STATS ${getSafeESQLName(`${field.name}_terms`)} = count(${getSafeESQLName(
|
||||
`| STATS ${getSafeESQLName(`${field.name}_in_records`)} = count(MV_MIN(${getSafeESQLName(
|
||||
field.name
|
||||
)}) BY ${getSafeESQLName(field.name)}
|
||||
| LIMIT 10
|
||||
| SORT ${getSafeESQLName(`${field.name}_terms`)} DESC`;
|
||||
)})), ${getSafeESQLName(`${field.name}_in_values`)} = count(${getSafeESQLName(field.name)})
|
||||
BY ${getSafeESQLName(field.name)}
|
||||
| SORT ${getSafeESQLName(`${field.name}_in_records`)} DESC
|
||||
| LIMIT 10`;
|
||||
return {
|
||||
field,
|
||||
request: {
|
||||
params: {
|
||||
query,
|
||||
...(filter ? { filter } : {}),
|
||||
version: ESQL_LATEST_VERSION,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -61,17 +64,31 @@ export const getESQLKeywordFieldStats = async ({
|
|||
if (!resp) return;
|
||||
|
||||
if (isFulfilled(resp)) {
|
||||
const results = resp.value?.rawResponse.values as Array<[BucketCount, BucketTerm]>;
|
||||
const results = resp.value?.rawResponse?.values as Array<
|
||||
[BucketCount, BucketCount, BucketTerm]
|
||||
>;
|
||||
|
||||
if (results) {
|
||||
const topValuesSampleSize = results.reduce((acc, row) => {
|
||||
return row[1] + acc;
|
||||
}, 0);
|
||||
|
||||
const sampledValues = results.map((row) => ({
|
||||
key: row[2],
|
||||
doc_count: row[1],
|
||||
}));
|
||||
|
||||
const terms = results.map((row) => ({
|
||||
key: row[1],
|
||||
key: row[2],
|
||||
doc_count: row[0],
|
||||
}));
|
||||
|
||||
return {
|
||||
fieldName: field.name,
|
||||
topValues: terms,
|
||||
isTopValuesSampled: false,
|
||||
sampledValues,
|
||||
isTopValuesSampled: true,
|
||||
topValuesSampleSize,
|
||||
} as StringFieldStats;
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { UseCancellableSearch } from '@kbn/ml-cancellable-search';
|
||||
import type { QueryDslQueryContainer } from '@kbn/data-views-plugin/common/types';
|
||||
import { ESQL_SEARCH_STRATEGY } from '@kbn/data-plugin/common';
|
||||
import { ESQL_LATEST_VERSION } from '@kbn/esql-utils';
|
||||
import type { Column } from '../../hooks/esql/use_esql_overall_stats_data';
|
||||
import type { FieldExamples, FieldStatsError } from '../../../../../common/types/field_stats';
|
||||
|
||||
interface Params {
|
||||
runRequest: UseCancellableSearch['runRequest'];
|
||||
columns: Column[];
|
||||
esqlBaseQuery: string;
|
||||
filter?: QueryDslQueryContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make one query that gets the top 10 rows for each text field requested
|
||||
* then process the values to showcase examples for each field
|
||||
* @param
|
||||
* @returns
|
||||
*/
|
||||
export const getESQLExampleFieldValues = async ({
|
||||
runRequest,
|
||||
columns: textFields,
|
||||
esqlBaseQuery,
|
||||
filter,
|
||||
}: Params): Promise<Array<FieldExamples | FieldStatsError>> => {
|
||||
try {
|
||||
if (textFields.length > 0) {
|
||||
const request = {
|
||||
params: {
|
||||
query:
|
||||
esqlBaseQuery +
|
||||
`| KEEP ${textFields.map((f) => f.name).join(',')}
|
||||
| LIMIT 10`,
|
||||
...(filter ? { filter } : {}),
|
||||
version: ESQL_LATEST_VERSION,
|
||||
},
|
||||
};
|
||||
const textFieldsResp = await runRequest(request, { strategy: ESQL_SEARCH_STRATEGY });
|
||||
|
||||
if (textFieldsResp) {
|
||||
return textFields.map((textField, idx) => {
|
||||
const examples = [
|
||||
...new Set((textFieldsResp.rawResponse.values as unknown[][]).map((row) => row[idx])),
|
||||
];
|
||||
|
||||
return {
|
||||
fieldName: textField.name,
|
||||
examples,
|
||||
} as FieldExamples;
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
return textFields.map((textField, idx) => ({
|
||||
fieldName: textField.name,
|
||||
error,
|
||||
})) as FieldStatsError[];
|
||||
}
|
||||
return [];
|
||||
};
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import type { DocumentCountStats } from '../../../../common/types/field_stats';
|
||||
|
||||
import type { SupportedFieldType } from '../../../../common/types';
|
||||
export interface AggregatableField {
|
||||
fieldName: string;
|
||||
stats: {
|
||||
|
@ -25,6 +25,7 @@ export interface NonAggregatableField {
|
|||
sampleCount?: number;
|
||||
};
|
||||
existsInDocs: boolean;
|
||||
secondaryType?: SupportedFieldType;
|
||||
}
|
||||
|
||||
export interface OverallStats {
|
||||
|
|
|
@ -77,7 +77,8 @@
|
|||
"@kbn/utility-types",
|
||||
"@kbn/visualization-utils",
|
||||
"@kbn/ml-time-buckets",
|
||||
"@kbn/aiops-log-rate-analysis"
|
||||
"@kbn/aiops-log-rate-analysis",
|
||||
"@kbn/discover-utils"
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import type { FC } from 'react';
|
||||
import React, { Fragment } from 'react';
|
||||
import React, { Fragment, useMemo } from 'react';
|
||||
|
||||
import {
|
||||
EuiButton,
|
||||
|
@ -25,6 +25,7 @@ import {
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { useTimefilter } from '@kbn/ml-date-picker';
|
||||
import { ENABLE_ESQL } from '@kbn/discover-utils';
|
||||
import { isFullLicense } from '../license';
|
||||
import { useMlKibana, useNavigateToPath } from '../contexts/kibana';
|
||||
import { HelpMenu } from '../components/help_menu';
|
||||
|
@ -61,8 +62,10 @@ export const DatavisualizerSelector: FC = () => {
|
|||
http: { basePath },
|
||||
docLinks,
|
||||
dataVisualizer,
|
||||
uiSettings,
|
||||
},
|
||||
} = useMlKibana();
|
||||
const isEsqlEnabled = useMemo(() => uiSettings.get(ENABLE_ESQL), [uiSettings]);
|
||||
|
||||
const helpLink = docLinks.links.ml.guide;
|
||||
const navigateToPath = useNavigateToPath();
|
||||
|
@ -160,60 +163,62 @@ export const DatavisualizerSelector: FC = () => {
|
|||
data-test-subj="mlDataVisualizerCardIndexData"
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<EuiCard
|
||||
hasBorder
|
||||
icon={<EuiIcon size="xxl" type="dataVisualizer" />}
|
||||
title={
|
||||
<EuiTextAlign textAlign="center">
|
||||
<>
|
||||
<FormattedMessage
|
||||
id="xpack.ml.datavisualizer.selector.selectESQLTitle"
|
||||
defaultMessage="Visualize data using ES|QL"
|
||||
/>{' '}
|
||||
<EuiBetaBadge
|
||||
label=""
|
||||
iconType="beaker"
|
||||
size="m"
|
||||
color="hollow"
|
||||
tooltipContent={
|
||||
<FormattedMessage
|
||||
id="xpack.ml.datavisualizer.selector.technicalPreviewBadge.titleMsg"
|
||||
defaultMessage="ES|QL is in technical preview."
|
||||
/>
|
||||
}
|
||||
tooltipPosition={'right'}
|
||||
aria-label={i18n.translate(
|
||||
'xpack.ml.datavisualizer.selector.technicalPreviewBadge.ariaLabel',
|
||||
{
|
||||
defaultMessage: 'ES|QL is in technical preview.',
|
||||
{isEsqlEnabled ? (
|
||||
<EuiFlexItem>
|
||||
<EuiCard
|
||||
hasBorder
|
||||
icon={<EuiIcon size="xxl" type="dataVisualizer" />}
|
||||
title={
|
||||
<EuiTextAlign textAlign="center">
|
||||
<>
|
||||
<FormattedMessage
|
||||
id="xpack.ml.datavisualizer.selector.selectESQLTitle"
|
||||
defaultMessage="Visualize data using ES|QL"
|
||||
/>{' '}
|
||||
<EuiBetaBadge
|
||||
label=""
|
||||
iconType="beaker"
|
||||
size="m"
|
||||
color="hollow"
|
||||
tooltipContent={
|
||||
<FormattedMessage
|
||||
id="xpack.ml.datavisualizer.selector.technicalPreviewBadge.titleMsg"
|
||||
defaultMessage="ES|QL is in technical preview."
|
||||
/>
|
||||
}
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
</EuiTextAlign>
|
||||
}
|
||||
description={
|
||||
<FormattedMessage
|
||||
id="xpack.ml.datavisualizer.selector.technicalPreviewBadge.contentMsg"
|
||||
defaultMessage="Use ES|QL queries to visualize information about any data set."
|
||||
/>
|
||||
}
|
||||
footer={
|
||||
<EuiButton
|
||||
target="_self"
|
||||
onClick={() => navigateToPath(ML_PAGES.DATA_VISUALIZER_ESQL)}
|
||||
data-test-subj="mlDataVisualizerSelectESQLButton"
|
||||
>
|
||||
tooltipPosition={'right'}
|
||||
aria-label={i18n.translate(
|
||||
'xpack.ml.datavisualizer.selector.technicalPreviewBadge.ariaLabel',
|
||||
{
|
||||
defaultMessage: 'ES|QL is in technical preview.',
|
||||
}
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
</EuiTextAlign>
|
||||
}
|
||||
description={
|
||||
<FormattedMessage
|
||||
id="xpack.ml.datavisualizer.selector.useESQLButtonLabel"
|
||||
defaultMessage="Use ES|QL"
|
||||
id="xpack.ml.datavisualizer.selector.technicalPreviewBadge.contentMsg"
|
||||
defaultMessage="Use ES|QL queries to visualize information about any data set."
|
||||
/>
|
||||
</EuiButton>
|
||||
}
|
||||
data-test-subj="mlDataVisualizerCardESQLData"
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
}
|
||||
footer={
|
||||
<EuiButton
|
||||
target="_self"
|
||||
onClick={() => navigateToPath(ML_PAGES.DATA_VISUALIZER_ESQL)}
|
||||
data-test-subj="mlDataVisualizerSelectESQLButton"
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.ml.datavisualizer.selector.useESQLButtonLabel"
|
||||
defaultMessage="Use ES|QL"
|
||||
/>
|
||||
</EuiButton>
|
||||
}
|
||||
data-test-subj="mlDataVisualizerCardESQLData"
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
) : null}
|
||||
</EuiFlexGrid>
|
||||
{startTrialVisible === true && (
|
||||
<Fragment>
|
||||
|
|
|
@ -50,6 +50,7 @@ import type { SavedSearchPublicPluginStart } from '@kbn/saved-search-plugin/publ
|
|||
import type { PresentationUtilPluginStart } from '@kbn/presentation-util-plugin/public';
|
||||
import type { DataViewEditorStart } from '@kbn/data-view-editor-plugin/public';
|
||||
import type { FieldFormatsRegistry } from '@kbn/field-formats-plugin/common';
|
||||
import { ENABLE_ESQL } from '@kbn/discover-utils';
|
||||
import type { MlSharedServices } from './application/services/get_shared_ml_services';
|
||||
import { getMlSharedServices } from './application/services/get_shared_ml_services';
|
||||
import { registerManagementSection } from './application/management';
|
||||
|
@ -222,6 +223,8 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
|
|||
const { capabilities } = coreStart.application;
|
||||
const mlCapabilities = capabilities.ml as MlCapabilities;
|
||||
|
||||
const isEsqlEnabled = core.uiSettings.get(ENABLE_ESQL);
|
||||
|
||||
// register various ML plugin features which require a full license
|
||||
// note including registerHomeFeature in register_helper would cause the page bundle size to increase significantly
|
||||
if (mlEnabled) {
|
||||
|
@ -236,7 +239,13 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
|
|||
registerSearchLinks,
|
||||
registerCasesAttachments,
|
||||
} = await import('./register_helper');
|
||||
registerSearchLinks(this.appUpdater$, fullLicense, mlCapabilities, this.isServerless);
|
||||
registerSearchLinks(
|
||||
this.appUpdater$,
|
||||
fullLicense,
|
||||
mlCapabilities,
|
||||
this.isServerless,
|
||||
isEsqlEnabled
|
||||
);
|
||||
|
||||
if (
|
||||
pluginsSetup.triggersActionsUi &&
|
||||
|
|
|
@ -16,7 +16,8 @@ export function registerSearchLinks(
|
|||
appUpdater: BehaviorSubject<AppUpdater>,
|
||||
isFullLicense: boolean,
|
||||
mlCapabilities: MlCapabilities,
|
||||
isServerless: boolean
|
||||
isServerless: boolean,
|
||||
isEsqlEnabled?: boolean
|
||||
) {
|
||||
appUpdater.next(() => ({
|
||||
keywords: [
|
||||
|
@ -24,6 +25,6 @@ export function registerSearchLinks(
|
|||
defaultMessage: 'ML',
|
||||
}),
|
||||
],
|
||||
deepLinks: getDeepLinks(isFullLicense, mlCapabilities, isServerless),
|
||||
deepLinks: getDeepLinks(isFullLicense, mlCapabilities, isServerless, isEsqlEnabled),
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ import { ML_PAGES } from '../../../common/constants/locator';
|
|||
function createDeepLinks(
|
||||
mlCapabilities: MlCapabilities,
|
||||
isFullLicense: boolean,
|
||||
isServerless: boolean
|
||||
isServerless: boolean,
|
||||
esqlEnabled?: boolean
|
||||
) {
|
||||
return {
|
||||
getOverviewLinkDeepLink: (): AppDeepLink<LinkId> | null => {
|
||||
|
@ -238,7 +239,8 @@ function createDeepLinks(
|
|||
};
|
||||
},
|
||||
|
||||
getESQLDataVisualizerDeepLink: (): AppDeepLink<LinkId> => {
|
||||
getESQLDataVisualizerDeepLink: (): AppDeepLink<LinkId> | null => {
|
||||
if (!esqlEnabled) return null;
|
||||
return {
|
||||
id: 'esqlDataVisualizer',
|
||||
title: i18n.translate('xpack.ml.deepLink.esqlDataVisualizer', {
|
||||
|
@ -263,9 +265,10 @@ function createDeepLinks(
|
|||
export function getDeepLinks(
|
||||
isFullLicense: boolean,
|
||||
mlCapabilities: MlCapabilities,
|
||||
isServerless: boolean
|
||||
isServerless: boolean,
|
||||
esqlEnabled?: boolean
|
||||
): Array<AppDeepLink<LinkId>> {
|
||||
const links = createDeepLinks(mlCapabilities, isFullLicense, isServerless);
|
||||
const links = createDeepLinks(mlCapabilities, isFullLicense, isServerless, esqlEnabled);
|
||||
return Object.values(links)
|
||||
.map((link) => link())
|
||||
.filter((link): link is AppDeepLink<LinkId> => link !== null);
|
||||
|
|
|
@ -124,5 +124,6 @@
|
|||
"@kbn/presentation-containers",
|
||||
"@kbn/presentation-panel-plugin",
|
||||
"@kbn/shared-ux-utility",
|
||||
"@kbn/discover-utils",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ const esqlSampleLogData: TestData = {
|
|||
sourceIndexOrSavedSearch: 'ft_module_sample_logs',
|
||||
expected: {
|
||||
hasDocCountChart: false,
|
||||
totalDocCountFormatted: '149',
|
||||
totalDocCountFormatted: '143',
|
||||
metricFields: [
|
||||
{
|
||||
fieldName: 'max_bytes_kb',
|
||||
|
@ -140,7 +140,7 @@ const esqlSampleLogData: TestData = {
|
|||
existsInDocs: true,
|
||||
aggregatable: true,
|
||||
loading: false,
|
||||
docCountFormatted: '143 (95.97%)',
|
||||
docCountFormatted: '143 (100%)',
|
||||
statsMaxDecimalPlaces: 3,
|
||||
topValuesCount: 12,
|
||||
viewableInLens: false,
|
||||
|
@ -151,7 +151,7 @@ const esqlSampleLogData: TestData = {
|
|||
existsInDocs: true,
|
||||
aggregatable: true,
|
||||
loading: false,
|
||||
docCountFormatted: '143 (95.97%)',
|
||||
docCountFormatted: '143 (100%)',
|
||||
statsMaxDecimalPlaces: 3,
|
||||
topValuesCount: 20,
|
||||
viewableInLens: false,
|
||||
|
@ -164,7 +164,7 @@ const esqlSampleLogData: TestData = {
|
|||
existsInDocs: true,
|
||||
aggregatable: true,
|
||||
loading: false,
|
||||
docCountFormatted: '143 (95.97%)',
|
||||
docCountFormatted: '143 (100%)',
|
||||
exampleCount: 10,
|
||||
viewableInLens: false,
|
||||
},
|
||||
|
@ -174,7 +174,7 @@ const esqlSampleLogData: TestData = {
|
|||
existsInDocs: true,
|
||||
aggregatable: true,
|
||||
loading: false,
|
||||
docCountFormatted: '143 (95.97%)',
|
||||
docCountFormatted: '143 (100%)',
|
||||
exampleCount: 11,
|
||||
viewableInLens: false,
|
||||
},
|
||||
|
@ -314,8 +314,7 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
|
|||
runTests(esqlFarequoteData);
|
||||
});
|
||||
|
||||
// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/180072
|
||||
describe.skip('with module_sample_logs ', function () {
|
||||
describe('with module_sample_logs ', function () {
|
||||
runTests(esqlSampleLogData);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue