mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Index Pattern UI - remove _remote/info query (#27345)
* use internal user to query _remote/info * query both * and *:* rather than querying for clusters * Update create_index_pattern_wizard.js * Update create_index_pattern_wizard.js * add a closing curly bracket * fix for failed matches * Update create_index_pattern_wizard.js
This commit is contained in:
parent
d265b4b8d1
commit
20ed7d43b7
7 changed files with 12 additions and 117 deletions
|
@ -31,7 +31,6 @@ import { managementApi } from './server/routes/api/management';
|
|||
import { scriptsApi } from './server/routes/api/scripts';
|
||||
import { registerSuggestionsApi } from './server/routes/api/suggestions';
|
||||
import { registerKqlTelemetryApi } from './server/routes/api/kql_telemetry';
|
||||
import { registerClustersRoute } from './server/routes/api/remote_info';
|
||||
import { registerFieldFormats } from './server/field_formats/register';
|
||||
import { registerTutorials } from './server/tutorials/register';
|
||||
import * as systemApi from './server/lib/system_api';
|
||||
|
@ -190,7 +189,6 @@ export default function (kibana) {
|
|||
registerFieldFormats(server);
|
||||
registerTutorials(server);
|
||||
makeKQLUsageCollector(server);
|
||||
registerClustersRoute(server);
|
||||
server.expose('systemApi', systemApi);
|
||||
server.expose('handleEsError', handleEsError);
|
||||
server.injectUiAppVars('kibana', () => injectVars(server));
|
||||
|
|
|
@ -35,7 +35,6 @@ import { MAX_SEARCH_SIZE } from './constants';
|
|||
import {
|
||||
ensureMinimumTime,
|
||||
getIndices,
|
||||
getRemoteClusters
|
||||
} from './lib';
|
||||
|
||||
export class CreateIndexPatternWizard extends Component {
|
||||
|
@ -104,17 +103,18 @@ export class CreateIndexPatternWizard extends Component {
|
|||
defaultMessage="Failed to load remote clusters"
|
||||
/>);
|
||||
|
||||
const [allIndices, remoteClusters] = await ensureMinimumTime([
|
||||
this.catchAndWarn(getIndices(services.es, this.indexPatternCreationType, `*`, MAX_SEARCH_SIZE), [], indicesFailMsg),
|
||||
this.catchAndWarn(getRemoteClusters(services.$http), [], clustersFailMsg)
|
||||
]);
|
||||
// query local and remote indices, updating state independently
|
||||
ensureMinimumTime(
|
||||
this.catchAndWarn(
|
||||
getIndices(services.es, this.indexPatternCreationType, `*`, MAX_SEARCH_SIZE), [], indicesFailMsg)
|
||||
).then(allIndices => this.setState({ allIndices, isInitiallyLoadingIndices: false }));
|
||||
|
||||
this.setState({
|
||||
allIndices,
|
||||
isInitiallyLoadingIndices: false,
|
||||
remoteClustersExist: remoteClusters.length !== 0
|
||||
});
|
||||
}
|
||||
this.catchAndWarn(
|
||||
// if we get an error from remote cluster query, supply fallback value that allows user entry.
|
||||
// ['a'] is fallback value
|
||||
getIndices(services.es, this.indexPatternCreationType, `*:*`, 1), ['a'], clustersFailMsg
|
||||
).then(remoteIndices => this.setState({ remoteClustersExist: !!remoteIndices.length }));
|
||||
};
|
||||
|
||||
createIndexPattern = async (timeFieldName, indexPatternId) => {
|
||||
const { services } = this.props;
|
||||
|
|
|
@ -46,6 +46,7 @@ export async function getIndices(es, indexPatternCreationType, rawPattern, limit
|
|||
}
|
||||
|
||||
const params = {
|
||||
ignoreUnavailable: true,
|
||||
index: pattern,
|
||||
ignore: [404],
|
||||
body: {
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import chrome from 'ui/chrome';
|
||||
const apiPrefix = chrome.addBasePath('/api/kibana');
|
||||
|
||||
export async function getRemoteClusters($http) {
|
||||
const response = await $http.get(`${apiPrefix}/clusters`);
|
||||
return response.data;
|
||||
}
|
|
@ -28,5 +28,3 @@ export { getMatchedIndices } from './get_matched_indices';
|
|||
export { containsIllegalCharacters } from './contains_illegal_characters';
|
||||
|
||||
export { extractTimeFields } from './extract_time_fields';
|
||||
|
||||
export { getRemoteClusters } from './get_remote_clusters';
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { once } from 'lodash';
|
||||
|
||||
const callWithRequest = once(server => {
|
||||
const cluster = server.plugins.elasticsearch.getCluster('data');
|
||||
return cluster.callWithRequest;
|
||||
});
|
||||
|
||||
export const callWithRequestFactory = (server, request) => {
|
||||
return (...args) => {
|
||||
return callWithRequest(server)(request, ...args);
|
||||
};
|
||||
};
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { callWithRequestFactory } from './call_with_request_factory';
|
||||
import handleEsError from '../../../lib/handle_es_error';
|
||||
|
||||
async function fetchRemoteClusters(callWithRequest) {
|
||||
const options = {
|
||||
method: 'GET',
|
||||
path: '_remote/info'
|
||||
};
|
||||
const remoteInfo = await callWithRequest('transport.request', options);
|
||||
return Object.keys(remoteInfo);
|
||||
}
|
||||
|
||||
export function registerClustersRoute(server) {
|
||||
server.route({
|
||||
path: '/api/kibana/clusters',
|
||||
method: 'GET',
|
||||
handler: async request => {
|
||||
const callWithRequest = callWithRequestFactory(server, request);
|
||||
try {
|
||||
return await fetchRemoteClusters(callWithRequest);
|
||||
} catch (error) {
|
||||
throw handleEsError(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue