mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[DataViews] Use 'rollup' data view type constant (#177524)
## Summary Resolves https://github.com/elastic/kibana/issues/158410. ### 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 - [ ] [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)
This commit is contained in:
parent
1f032eb138
commit
555b7b62b5
18 changed files with 46 additions and 31 deletions
|
@ -16,6 +16,7 @@ import { SearchStrategyDependencies } from '../../types';
|
||||||
import { enhancedEsSearchStrategyProvider } from './ese_search_strategy';
|
import { enhancedEsSearchStrategyProvider } from './ese_search_strategy';
|
||||||
import { createSearchSessionsClientMock } from '../../mocks';
|
import { createSearchSessionsClientMock } from '../../mocks';
|
||||||
import { getMockSearchConfig } from '../../../../config.mock';
|
import { getMockSearchConfig } from '../../../../config.mock';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/common';
|
||||||
|
|
||||||
const mockAsyncResponse = {
|
const mockAsyncResponse = {
|
||||||
body: {
|
body: {
|
||||||
|
@ -246,7 +247,7 @@ describe('ES search strategy', () => {
|
||||||
await esSearch
|
await esSearch
|
||||||
.search(
|
.search(
|
||||||
{
|
{
|
||||||
indexType: 'rollup',
|
indexType: DataViewType.ROLLUP,
|
||||||
params,
|
params,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
|
@ -274,7 +275,7 @@ describe('ES search strategy', () => {
|
||||||
await esSearch
|
await esSearch
|
||||||
.search(
|
.search(
|
||||||
{
|
{
|
||||||
indexType: 'rollup',
|
indexType: DataViewType.ROLLUP,
|
||||||
params,
|
params,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
|
|
|
@ -21,7 +21,7 @@ import type {
|
||||||
IEsSearchResponse,
|
IEsSearchResponse,
|
||||||
ISearchOptions,
|
ISearchOptions,
|
||||||
} from '../../../../common';
|
} from '../../../../common';
|
||||||
import { pollSearch } from '../../../../common';
|
import { DataViewType, pollSearch } from '../../../../common';
|
||||||
import {
|
import {
|
||||||
getDefaultAsyncGetParams,
|
getDefaultAsyncGetParams,
|
||||||
getDefaultAsyncSubmitParams,
|
getDefaultAsyncSubmitParams,
|
||||||
|
@ -171,7 +171,7 @@ export const enhancedEsSearchStrategyProvider = (
|
||||||
search: (request, options: IAsyncSearchOptions, deps) => {
|
search: (request, options: IAsyncSearchOptions, deps) => {
|
||||||
logger.debug(`search ${JSON.stringify(request.params) || request.id}`);
|
logger.debug(`search ${JSON.stringify(request.params) || request.id}`);
|
||||||
|
|
||||||
if (request.indexType === 'rollup' && deps.rollupsEnabled) {
|
if (request.indexType === DataViewType.ROLLUP && deps.rollupsEnabled) {
|
||||||
return from(rollupSearch(request, options, deps));
|
return from(rollupSearch(request, options, deps));
|
||||||
} else {
|
} else {
|
||||||
return asyncSearch(request, options, deps);
|
return asyncSearch(request, options, deps);
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { FormattedMessage } from '@kbn/i18n-react';
|
import { FormattedMessage } from '@kbn/i18n-react';
|
||||||
import { DataView, DataViewField, RuntimeField } from '@kbn/data-views-plugin/public';
|
import { DataView, DataViewField, DataViewType, RuntimeField } from '@kbn/data-views-plugin/public';
|
||||||
import { DATA_VIEW_SAVED_OBJECT_TYPE } from '@kbn/data-views-plugin/public';
|
import { DATA_VIEW_SAVED_OBJECT_TYPE } from '@kbn/data-views-plugin/public';
|
||||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||||
import {
|
import {
|
||||||
|
@ -170,7 +170,7 @@ export const EditIndexPattern = withRouter(
|
||||||
});
|
});
|
||||||
|
|
||||||
const isRollup =
|
const isRollup =
|
||||||
new URLSearchParams(useLocation().search).get('type') === 'rollup' &&
|
new URLSearchParams(useLocation().search).get('type') === DataViewType.ROLLUP &&
|
||||||
dataViews.getRollupsEnabled();
|
dataViews.getRollupsEnabled();
|
||||||
const displayIndexPatternEditor = showEditDialog ? (
|
const displayIndexPatternEditor = showEditDialog ? (
|
||||||
<IndexPatternEditor
|
<IndexPatternEditor
|
||||||
|
|
|
@ -27,6 +27,7 @@ import useObservable from 'react-use/lib/useObservable';
|
||||||
import { reactRouterNavigate, useKibana } from '@kbn/kibana-react-plugin/public';
|
import { reactRouterNavigate, useKibana } from '@kbn/kibana-react-plugin/public';
|
||||||
import { NoDataViewsPromptComponent } from '@kbn/shared-ux-prompt-no-data-views';
|
import { NoDataViewsPromptComponent } from '@kbn/shared-ux-prompt-no-data-views';
|
||||||
import type { SpacesContextProps } from '@kbn/spaces-plugin/public';
|
import type { SpacesContextProps } from '@kbn/spaces-plugin/public';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/public';
|
||||||
import type { IndexPatternManagmentContext } from '../../types';
|
import type { IndexPatternManagmentContext } from '../../types';
|
||||||
import { getListBreadcrumbs } from '../breadcrumbs';
|
import { getListBreadcrumbs } from '../breadcrumbs';
|
||||||
import { type RemoveDataViewProps, removeDataView } from '../edit_index_pattern';
|
import { type RemoveDataViewProps, removeDataView } from '../edit_index_pattern';
|
||||||
|
@ -169,7 +170,7 @@ export const IndexPatternTable = ({
|
||||||
chrome.docTitle.change(title);
|
chrome.docTitle.change(title);
|
||||||
|
|
||||||
const isRollup =
|
const isRollup =
|
||||||
new URLSearchParams(useLocation().search).get('type') === 'rollup' &&
|
new URLSearchParams(useLocation().search).get('type') === DataViewType.ROLLUP &&
|
||||||
dataViews.getRollupsEnabled();
|
dataViews.getRollupsEnabled();
|
||||||
|
|
||||||
const ContextWrapper = useMemo(
|
const ContextWrapper = useMemo(
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
DataView,
|
DataView,
|
||||||
DataViewField,
|
DataViewField,
|
||||||
DataViewListItem,
|
DataViewListItem,
|
||||||
|
DataViewType,
|
||||||
} from '@kbn/data-views-plugin/public';
|
} from '@kbn/data-views-plugin/public';
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ const rollupIndexPatternListName = i18n.translate(
|
||||||
);
|
);
|
||||||
|
|
||||||
export const isRollup = (indexPatternType: string = '') => {
|
export const isRollup = (indexPatternType: string = '') => {
|
||||||
return indexPatternType === 'rollup';
|
return indexPatternType === DataViewType.ROLLUP;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getIndexPatterns(defaultIndex: string, dataViewsService: DataViewsContract) {
|
export async function getIndexPatterns(defaultIndex: string, dataViewsService: DataViewsContract) {
|
||||||
|
@ -76,14 +77,14 @@ export const getTags = (
|
||||||
const tags = [];
|
const tags = [];
|
||||||
if (isDefault) {
|
if (isDefault) {
|
||||||
tags.push({
|
tags.push({
|
||||||
key: 'default',
|
key: DataViewType.DEFAULT,
|
||||||
name: defaultIndexPatternListName,
|
name: defaultIndexPatternListName,
|
||||||
'data-test-subj': 'default-tag',
|
'data-test-subj': 'default-tag',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (isRollup(indexPattern.type) && rollupsEnabled) {
|
if (isRollup(indexPattern.type) && rollupsEnabled) {
|
||||||
tags.push({
|
tags.push({
|
||||||
key: 'rollup',
|
key: DataViewType.ROLLUP,
|
||||||
name: rollupIndexPatternListName,
|
name: rollupIndexPatternListName,
|
||||||
'data-test-subj': 'rollup-tag',
|
'data-test-subj': 'rollup-tag',
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,12 +16,13 @@ import {
|
||||||
createResultSchema,
|
createResultSchema,
|
||||||
searchOptionsSchemas,
|
searchOptionsSchemas,
|
||||||
} from '@kbn/content-management-utils';
|
} from '@kbn/content-management-utils';
|
||||||
|
import { DataViewType } from '../..';
|
||||||
import { serializedFieldFormatSchema, fieldSpecSchema } from '../../schemas';
|
import { serializedFieldFormatSchema, fieldSpecSchema } from '../../schemas';
|
||||||
|
|
||||||
const dataViewAttributesSchema = schema.object(
|
const dataViewAttributesSchema = schema.object(
|
||||||
{
|
{
|
||||||
title: schema.string(),
|
title: schema.string(),
|
||||||
type: schema.maybe(schema.literal('rollup')),
|
type: schema.maybe(schema.literal(DataViewType.ROLLUP)),
|
||||||
timeFieldName: schema.maybe(schema.string()),
|
timeFieldName: schema.maybe(schema.string()),
|
||||||
sourceFilters: schema.maybe(
|
sourceFilters: schema.maybe(
|
||||||
schema.arrayOf(
|
schema.arrayOf(
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { IndexPatternsFetcher } from '.';
|
import { IndexPatternsFetcher } from '.';
|
||||||
import { elasticsearchServiceMock } from '@kbn/core/server/mocks';
|
import { elasticsearchServiceMock } from '@kbn/core/server/mocks';
|
||||||
import { DataViewMissingIndices } from '../../common';
|
import { DataViewMissingIndices, DataViewType } from '../../common';
|
||||||
|
|
||||||
const rollupResponse = {
|
const rollupResponse = {
|
||||||
foo: {
|
foo: {
|
||||||
|
@ -51,7 +51,7 @@ describe('Index Pattern Fetcher - server', () => {
|
||||||
indexPatterns = new IndexPatternsFetcher(esClient, true, true);
|
indexPatterns = new IndexPatternsFetcher(esClient, true, true);
|
||||||
await indexPatterns.getFieldsForWildcard({
|
await indexPatterns.getFieldsForWildcard({
|
||||||
pattern: patternList,
|
pattern: patternList,
|
||||||
type: 'rollup',
|
type: DataViewType.ROLLUP,
|
||||||
rollupIndex: 'foo',
|
rollupIndex: 'foo',
|
||||||
});
|
});
|
||||||
expect(esClient.rollup.getRollupIndexCaps).toHaveBeenCalledTimes(1);
|
expect(esClient.rollup.getRollupIndexCaps).toHaveBeenCalledTimes(1);
|
||||||
|
@ -64,7 +64,7 @@ describe('Index Pattern Fetcher - server', () => {
|
||||||
indexPatterns = new IndexPatternsFetcher(esClient, true, false);
|
indexPatterns = new IndexPatternsFetcher(esClient, true, false);
|
||||||
await indexPatterns.getFieldsForWildcard({
|
await indexPatterns.getFieldsForWildcard({
|
||||||
pattern: patternList,
|
pattern: patternList,
|
||||||
type: 'rollup',
|
type: DataViewType.ROLLUP,
|
||||||
rollupIndex: 'foo',
|
rollupIndex: 'foo',
|
||||||
});
|
});
|
||||||
expect(esClient.rollup.getRollupIndexCaps).toHaveBeenCalledTimes(0);
|
expect(esClient.rollup.getRollupIndexCaps).toHaveBeenCalledTimes(0);
|
||||||
|
|
|
@ -18,6 +18,7 @@ import {
|
||||||
getCapabilitiesForRollupIndices,
|
getCapabilitiesForRollupIndices,
|
||||||
mergeCapabilitiesWithFields,
|
mergeCapabilitiesWithFields,
|
||||||
} from './lib';
|
} from './lib';
|
||||||
|
import { DataViewType } from '../../common/types';
|
||||||
|
|
||||||
export interface FieldDescriptor {
|
export interface FieldDescriptor {
|
||||||
aggregatable: boolean;
|
aggregatable: boolean;
|
||||||
|
@ -105,7 +106,7 @@ export class IndexPatternsFetcher {
|
||||||
includeEmptyFields,
|
includeEmptyFields,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.rollupsEnabled && type === 'rollup' && rollupIndex) {
|
if (this.rollupsEnabled && type === DataViewType.ROLLUP && rollupIndex) {
|
||||||
const rollupFields: FieldDescriptor[] = [];
|
const rollupFields: FieldDescriptor[] = [];
|
||||||
const capabilityCheck = getCapabilitiesForRollupIndices(
|
const capabilityCheck = getCapabilitiesForRollupIndices(
|
||||||
await this.elasticsearchClient.rollup.getRollupIndexCaps({
|
await this.elasticsearchClient.rollup.getRollupIndexCaps({
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { isRunningResponse, ISearchSource } from '@kbn/data-plugin/public';
|
||||||
import { buildDataTableRecordList } from '@kbn/discover-utils';
|
import { buildDataTableRecordList } from '@kbn/discover-utils';
|
||||||
import type { EsHitRecord } from '@kbn/discover-utils/types';
|
import type { EsHitRecord } from '@kbn/discover-utils/types';
|
||||||
import type { SearchResponseWarning } from '@kbn/search-response-warnings';
|
import type { SearchResponseWarning } from '@kbn/search-response-warnings';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/public';
|
||||||
import type { RecordsFetchResponse } from '../../types';
|
import type { RecordsFetchResponse } from '../../types';
|
||||||
import { getAllowedSampleSize } from '../../../utils/get_allowed_sample_size';
|
import { getAllowedSampleSize } from '../../../utils/get_allowed_sample_size';
|
||||||
import { FetchDeps } from './fetch_all';
|
import { FetchDeps } from './fetch_all';
|
||||||
|
@ -29,7 +30,7 @@ export const fetchDocuments = (
|
||||||
searchSource.setField('trackTotalHits', false);
|
searchSource.setField('trackTotalHits', false);
|
||||||
searchSource.setField('highlightAll', true);
|
searchSource.setField('highlightAll', true);
|
||||||
searchSource.setField('version', true);
|
searchSource.setField('version', true);
|
||||||
if (searchSource.getField('index')?.type === 'rollup') {
|
if (searchSource.getField('index')?.type === DataViewType.ROLLUP) {
|
||||||
// We treat that data view as "normal" even if it was a rollup data view,
|
// We treat that data view as "normal" even if it was a rollup data view,
|
||||||
// since the rollup endpoint does not support querying individual documents, but we
|
// since the rollup endpoint does not support querying individual documents, but we
|
||||||
// can get them from the regular _search API that will be used if the data view
|
// can get them from the regular _search API that will be used if the data view
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
import { getCapabilitiesForRollupIndices } from '@kbn/data-plugin/server';
|
import { getCapabilitiesForRollupIndices } from '@kbn/data-plugin/server';
|
||||||
import type { DataViewsService } from '@kbn/data-views-plugin/common';
|
import type { DataViewsService } from '@kbn/data-views-plugin/common';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/common';
|
||||||
import { AbstractSearchStrategy, EsSearchRequest } from './abstract_search_strategy';
|
import { AbstractSearchStrategy, EsSearchRequest } from './abstract_search_strategy';
|
||||||
import { RollupSearchCapabilities } from '../capabilities/rollup_search_capabilities';
|
import { RollupSearchCapabilities } from '../capabilities/rollup_search_capabilities';
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ export class RollupSearchStrategy extends AbstractSearchStrategy {
|
||||||
esRequests: EsSearchRequest[],
|
esRequests: EsSearchRequest[],
|
||||||
trackedEsSearches?: TrackedEsSearches
|
trackedEsSearches?: TrackedEsSearches
|
||||||
) {
|
) {
|
||||||
return super.search(requestContext, req, esRequests, trackedEsSearches, 'rollup');
|
return super.search(requestContext, req, esRequests, trackedEsSearches, DataViewType.ROLLUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRollupData(
|
async getRollupData(
|
||||||
|
@ -60,7 +61,7 @@ export class RollupSearchStrategy extends AbstractSearchStrategy {
|
||||||
if (
|
if (
|
||||||
indexPatternString &&
|
indexPatternString &&
|
||||||
((!indexPattern && !isIndexPatternContainsWildcard(indexPatternString)) ||
|
((!indexPattern && !isIndexPatternContainsWildcard(indexPatternString)) ||
|
||||||
indexPattern?.type === 'rollup')
|
indexPattern?.type === DataViewType.ROLLUP)
|
||||||
) {
|
) {
|
||||||
const rollupData = await this.getRollupData(requestContext, indexPatternString);
|
const rollupData = await this.getRollupData(requestContext, indexPatternString);
|
||||||
const rollupIndices = getRollupIndices(rollupData);
|
const rollupIndices = getRollupIndices(rollupData);
|
||||||
|
@ -96,7 +97,7 @@ export class RollupSearchStrategy extends AbstractSearchStrategy {
|
||||||
capabilities?: unknown
|
capabilities?: unknown
|
||||||
) {
|
) {
|
||||||
return super.getFieldsForWildcard(fetchedIndexPattern, indexPatternsService, capabilities, {
|
return super.getFieldsForWildcard(fetchedIndexPattern, indexPatternsService, capabilities, {
|
||||||
type: 'rollup',
|
type: DataViewType.ROLLUP,
|
||||||
rollupIndex: fetchedIndexPattern.indexPatternString,
|
rollupIndex: fetchedIndexPattern.indexPatternString,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
type FieldId,
|
type FieldId,
|
||||||
EVENT_RATE_FIELD_ID,
|
EVENT_RATE_FIELD_ID,
|
||||||
} from '@kbn/ml-anomaly-utils';
|
} from '@kbn/ml-anomaly-utils';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/public';
|
||||||
import { getGeoFields, filterCategoryFields } from '../../../../common/util/fields_utils';
|
import { getGeoFields, filterCategoryFields } from '../../../../common/util/fields_utils';
|
||||||
import { ml, type MlApiServices } from '../ml_api_service';
|
import { ml, type MlApiServices } from '../ml_api_service';
|
||||||
import { processTextAndKeywordFields, NewJobCapabilitiesServiceBase } from './new_job_capabilities';
|
import { processTextAndKeywordFields, NewJobCapabilitiesServiceBase } from './new_job_capabilities';
|
||||||
|
@ -57,7 +58,7 @@ export class NewJobCapsService extends NewJobCapabilitiesServiceBase {
|
||||||
|
|
||||||
const resp = await this._mlApiService.jobs.newJobCaps(
|
const resp = await this._mlApiService.jobs.newJobCaps(
|
||||||
dataView.getIndexPattern(),
|
dataView.getIndexPattern(),
|
||||||
dataView.type === 'rollup'
|
dataView.type === DataViewType.ROLLUP
|
||||||
);
|
);
|
||||||
const { fields: allFields, aggs } = createObjects(resp, dataView.getIndexPattern());
|
const { fields: allFields, aggs } = createObjects(resp, dataView.getIndexPattern());
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
|
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
|
||||||
import { DataView } from '@kbn/data-views-plugin/public';
|
import { DataView, DataViewType } from '@kbn/data-views-plugin/public';
|
||||||
import type { Field, NewJobCapsResponse } from '@kbn/ml-anomaly-utils';
|
import type { Field, NewJobCapsResponse } from '@kbn/ml-anomaly-utils';
|
||||||
import {
|
import {
|
||||||
getDependentVar,
|
getDependentVar,
|
||||||
|
@ -63,7 +63,7 @@ class NewJobCapsServiceAnalytics extends NewJobCapabilitiesServiceBase {
|
||||||
try {
|
try {
|
||||||
const resp: NewJobCapsResponse = await ml.dataFrameAnalytics.newJobCapsAnalytics(
|
const resp: NewJobCapsResponse = await ml.dataFrameAnalytics.newJobCapsAnalytics(
|
||||||
dataView.getIndexPattern(),
|
dataView.getIndexPattern(),
|
||||||
dataView.type === 'rollup'
|
dataView.type === DataViewType.ROLLUP
|
||||||
);
|
);
|
||||||
|
|
||||||
const allFields = removeNestedFieldChildren(resp, dataView.getIndexPattern());
|
const allFields = removeNestedFieldChildren(resp, dataView.getIndexPattern());
|
||||||
|
|
|
@ -9,6 +9,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { IScopedClusterClient } from '@kbn/core/server';
|
import type { IScopedClusterClient } from '@kbn/core/server';
|
||||||
import type { DataViewsService, DataView } from '@kbn/data-views-plugin/common';
|
import type { DataViewsService, DataView } from '@kbn/data-views-plugin/common';
|
||||||
import type { RollupFields } from '@kbn/ml-anomaly-utils';
|
import type { RollupFields } from '@kbn/ml-anomaly-utils';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/common';
|
||||||
|
|
||||||
export interface RollupJob {
|
export interface RollupJob {
|
||||||
job_id: string;
|
job_id: string;
|
||||||
|
@ -67,7 +68,8 @@ async function loadRollupIndexPattern(
|
||||||
): Promise<DataView | null> {
|
): Promise<DataView | null> {
|
||||||
const resp = await dataViewsService.find('*', 10000);
|
const resp = await dataViewsService.find('*', 10000);
|
||||||
const obj = resp.find(
|
const obj = resp.find(
|
||||||
(dv) => dv.type === 'rollup' && dv.title === indexPattern && dv.typeMeta !== undefined
|
(dv) =>
|
||||||
|
dv.type === DataViewType.ROLLUP && dv.title === indexPattern && dv.typeMeta !== undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
return obj ?? null;
|
return obj ?? null;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { ElasticsearchClient } from '@kbn/core/server';
|
import { ElasticsearchClient } from '@kbn/core/server';
|
||||||
import { estypes } from '@elastic/elasticsearch';
|
import { estypes } from '@elastic/elasticsearch';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/common';
|
||||||
|
|
||||||
// elasticsearch index.max_result_window default value
|
// elasticsearch index.max_result_window default value
|
||||||
const ES_MAX_RESULT_WINDOW_DEFAULT_VALUE = 1000;
|
const ES_MAX_RESULT_WINDOW_DEFAULT_VALUE = 1000;
|
||||||
|
@ -40,7 +41,7 @@ export async function fetchRollupIndexPatterns(kibanaIndex: string, esClient: El
|
||||||
bool: {
|
bool: {
|
||||||
filter: {
|
filter: {
|
||||||
term: {
|
term: {
|
||||||
'index-pattern.type': 'rollup',
|
'index-pattern.type': DataViewType.ROLLUP,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,6 +12,7 @@ import expect from '@kbn/expect';
|
||||||
import { stringify } from 'query-string';
|
import { stringify } from 'query-string';
|
||||||
import { registerHelpers } from './rollup.test_helpers';
|
import { registerHelpers } from './rollup.test_helpers';
|
||||||
import { getRandomString } from './lib';
|
import { getRandomString } from './lib';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/common';
|
||||||
|
|
||||||
export default function ({ getService }) {
|
export default function ({ getService }) {
|
||||||
const supertest = getService('supertest');
|
const supertest = getService('supertest');
|
||||||
|
@ -40,7 +41,7 @@ export default function ({ getService }) {
|
||||||
uri = `${BASE_URI}?${stringify(
|
uri = `${BASE_URI}?${stringify(
|
||||||
{
|
{
|
||||||
pattern: 'foo',
|
pattern: 'foo',
|
||||||
type: 'rollup',
|
type: DataViewType.ROLLUP,
|
||||||
rollup_index: 'bar',
|
rollup_index: 'bar',
|
||||||
},
|
},
|
||||||
{ sort: false }
|
{ sort: false }
|
||||||
|
@ -63,7 +64,7 @@ export default function ({ getService }) {
|
||||||
// Query for wildcard
|
// Query for wildcard
|
||||||
const params = {
|
const params = {
|
||||||
pattern: indexName,
|
pattern: indexName,
|
||||||
type: 'rollup',
|
type: DataViewType.ROLLUP,
|
||||||
rollup_index: rollupIndex,
|
rollup_index: rollupIndex,
|
||||||
};
|
};
|
||||||
const uri = `${BASE_URI}?${stringify(params, { sort: false })}`;
|
const uri = `${BASE_URI}?${stringify(params, { sort: false })}`;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import { parse as parseCookie } from 'tough-cookie';
|
import { parse as parseCookie } from 'tough-cookie';
|
||||||
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
|
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/common';
|
||||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||||
import { verifyErrorResponse } from '../../../../../test/api_integration/apis/search/verify_error';
|
import { verifyErrorResponse } from '../../../../../test/api_integration/apis/search/verify_error';
|
||||||
|
|
||||||
|
@ -384,7 +385,7 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
|
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
|
||||||
.set('kbn-xsrf', 'foo')
|
.set('kbn-xsrf', 'foo')
|
||||||
.send({
|
.send({
|
||||||
indexType: 'rollup',
|
indexType: DataViewType.ROLLUP,
|
||||||
params: {
|
params: {
|
||||||
body: {
|
body: {
|
||||||
query: {
|
query: {
|
||||||
|
@ -403,7 +404,7 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
|
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
|
||||||
.set('kbn-xsrf', 'foo')
|
.set('kbn-xsrf', 'foo')
|
||||||
.send({
|
.send({
|
||||||
indexType: 'rollup',
|
indexType: DataViewType.ROLLUP,
|
||||||
params: {
|
params: {
|
||||||
index: 'banana',
|
index: 'banana',
|
||||||
body: {
|
body: {
|
||||||
|
@ -424,7 +425,7 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
|
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
|
||||||
.set('kbn-xsrf', 'foo')
|
.set('kbn-xsrf', 'foo')
|
||||||
.send({
|
.send({
|
||||||
indexType: 'rollup',
|
indexType: DataViewType.ROLLUP,
|
||||||
params: {
|
params: {
|
||||||
index: 'rollup_logstash',
|
index: 'rollup_logstash',
|
||||||
size: 0,
|
size: 0,
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
|
||||||
import { INITIAL_REST_VERSION_INTERNAL } from '@kbn/data-views-plugin/server/constants';
|
import { INITIAL_REST_VERSION_INTERNAL } from '@kbn/data-views-plugin/server/constants';
|
||||||
import { X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '@kbn/core-http-common/src/constants';
|
import { X_ELASTIC_INTERNAL_ORIGIN_REQUEST } from '@kbn/core-http-common/src/constants';
|
||||||
import { FIELDS_FOR_WILDCARD_PATH as BASE_URI } from '@kbn/data-views-plugin/common/constants';
|
import { FIELDS_FOR_WILDCARD_PATH as BASE_URI } from '@kbn/data-views-plugin/common/constants';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/common';
|
||||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||||
|
|
||||||
export default function ({ getService }: FtrProviderContext) {
|
export default function ({ getService }: FtrProviderContext) {
|
||||||
|
@ -31,7 +32,7 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
.get(BASE_URI)
|
.get(BASE_URI)
|
||||||
.query({
|
.query({
|
||||||
pattern: 'basic_index',
|
pattern: 'basic_index',
|
||||||
type: 'rollup',
|
type: DataViewType.ROLLUP,
|
||||||
rollup_index: 'bar',
|
rollup_index: 'bar',
|
||||||
})
|
})
|
||||||
.set(ELASTIC_HTTP_VERSION_HEADER, INITIAL_REST_VERSION_INTERNAL)
|
.set(ELASTIC_HTTP_VERSION_HEADER, INITIAL_REST_VERSION_INTERNAL)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import expect from 'expect';
|
||||||
import { DATA_VIEW_PATH } from '@kbn/data-views-plugin/server';
|
import { DATA_VIEW_PATH } from '@kbn/data-views-plugin/server';
|
||||||
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
|
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
|
||||||
import { INITIAL_REST_VERSION } from '@kbn/data-views-plugin/server/constants';
|
import { INITIAL_REST_VERSION } from '@kbn/data-views-plugin/server/constants';
|
||||||
|
import { DataViewType } from '@kbn/data-views-plugin/common';
|
||||||
import { FtrProviderContext } from '../../../../ftr_provider_context';
|
import { FtrProviderContext } from '../../../../ftr_provider_context';
|
||||||
|
|
||||||
const archivePath = 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index';
|
const archivePath = 'test/api_integration/fixtures/es_archiver/index_patterns/basic_index';
|
||||||
|
@ -70,7 +71,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
.send({
|
.send({
|
||||||
data_view: {
|
data_view: {
|
||||||
title: 'basic_index',
|
title: 'basic_index',
|
||||||
type: 'rollup',
|
type: DataViewType.ROLLUP,
|
||||||
},
|
},
|
||||||
override: true,
|
override: true,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue