mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.9`: - [[APM] Swallow unhandled exceptions (#164251)](https://github.com/elastic/kibana/pull/164251) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Søren Louv-Jansen","email":"soren.louv@elastic.co"},"sourceCommit":{"committedDate":"2023-08-21T18:10:30Z","message":"[APM] Swallow unhandled exceptions (#164251)\n\nIf an unhandled error occurs, it will break the diagnostics bundle. This\r\nchange will log errors and then swallow them.\r\nThis should go out in 8.10 since it is already affecting users.","sha":"654de7b7285ad5748dc9ff1e19156e753d68d568","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:APM","release_note:skip","auto-backport","backport:prev-minor","apm:cypress-record","v8.9.0","v8.10.0","v8.11.0"],"number":164251,"url":"https://github.com/elastic/kibana/pull/164251","mergeCommit":{"message":"[APM] Swallow unhandled exceptions (#164251)\n\nIf an unhandled error occurs, it will break the diagnostics bundle. This\r\nchange will log errors and then swallow them.\r\nThis should go out in 8.10 since it is already affecting users.","sha":"654de7b7285ad5748dc9ff1e19156e753d68d568"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/164342","number":164342,"state":"MERGED","mergeCommit":{"sha":"481e6d5a9a7cd9bd89dbe6ef7bb821d556e7793f","message":"[8.10] [APM] Swallow unhandled exceptions (#164251) (#164342)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.10`:\n- [[APM] Swallow unhandled exceptions\n(#164251)](https://github.com/elastic/kibana/pull/164251)\n\n<!--- Backport version: 8.9.7 -->\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT [{\"author\":{\"name\":\"Søren\nLouv-Jansen\",\"email\":\"soren.louv@elastic.co\"},\"sourceCommit\":{\"committedDate\":\"2023-08-21T18:10:30Z\",\"message\":\"[APM]\nSwallow unhandled exceptions (#164251)\\n\\nIf an unhandled error occurs,\nit will break the diagnostics bundle. This\\r\\nchange will log errors and\nthen swallow them.\\r\\nThis should go out in 8.10 since it is already\naffecting\nusers.\",\"sha\":\"654de7b7285ad5748dc9ff1e19156e753d68d568\",\"branchLabelMapping\":{\"^v8.11.0$\":\"main\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"Team:APM\",\"release_note:skip\",\"backport:prev-minor\",\"apm:cypress-record\",\"v8.10.0\",\"v8.11.0\"],\"number\":164251,\"url\":\"https://github.com/elastic/kibana/pull/164251\",\"mergeCommit\":{\"message\":\"[APM]\nSwallow unhandled exceptions (#164251)\\n\\nIf an unhandled error occurs,\nit will break the diagnostics bundle. This\\r\\nchange will log errors and\nthen swallow them.\\r\\nThis should go out in 8.10 since it is already\naffecting\nusers.\",\"sha\":\"654de7b7285ad5748dc9ff1e19156e753d68d568\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.10\"],\"targetPullRequestStates\":[{\"branch\":\"8.10\",\"label\":\"v8.10.0\",\"labelRegex\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"},{\"branch\":\"main\",\"label\":\"v8.11.0\",\"labelRegex\":\"^v8.11.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/164251\",\"number\":164251,\"mergeCommit\":{\"message\":\"[APM]\nSwallow unhandled exceptions (#164251)\\n\\nIf an unhandled error occurs,\nit will break the diagnostics bundle. This\\r\\nchange will log errors and\nthen swallow them.\\r\\nThis should go out in 8.10 since it is already\naffecting users.\",\"sha\":\"654de7b7285ad5748dc9ff1e19156e753d68d568\"}}]}]\nBACKPORT-->\n\nCo-authored-by: Søren Louv-Jansen <soren.louv@elastic.co>"}},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164251","number":164251,"mergeCommit":{"message":"[APM] Swallow unhandled exceptions (#164251)\n\nIf an unhandled error occurs, it will break the diagnostics bundle. This\r\nchange will log errors and then swallow them.\r\nThis should go out in 8.10 since it is already affecting users.","sha":"654de7b7285ad5748dc9ff1e19156e753d68d568"}}]}] BACKPORT--> Co-authored-by: Søren Louv-Jansen <soren.louv@elastic.co>
This commit is contained in:
parent
89220a48cb
commit
d098dee68c
6 changed files with 56 additions and 63 deletions
|
@ -27,7 +27,7 @@ export function DiagnosticsIndices() {
|
|||
return <EuiLoadingElastic size="m" />;
|
||||
}
|
||||
|
||||
const { invalidIndices, validIndices } = diagnosticsBundle;
|
||||
const { invalidIndices = [], validIndices = [] } = diagnosticsBundle;
|
||||
const columns: Array<EuiBasicTableColumn<IndiciesItem>> = [
|
||||
{
|
||||
field: 'index',
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { EuiLink } from '@elastic/eui';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { useApmParams } from '../../../../hooks/use_apm_params';
|
||||
import { FETCH_STATUS } from '../../../../hooks/use_fetcher';
|
||||
import { APIReturnType } from '../../../../services/rest/create_call_apm_api';
|
||||
|
@ -45,5 +46,5 @@ export function getIsIndicesTabOk(diagnosticsBundle?: DiagnosticsBundle) {
|
|||
return true;
|
||||
}
|
||||
|
||||
return diagnosticsBundle.invalidIndices.length === 0;
|
||||
return isEmpty(diagnosticsBundle.invalidIndices);
|
||||
}
|
||||
|
|
|
@ -110,6 +110,8 @@ async function handleInvalidIndexTemplateException<T>(promise: Promise<T>) {
|
|||
return [];
|
||||
}
|
||||
|
||||
throw error;
|
||||
console.error(`Suppressed unknown exception: ${error.message}`);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import { NOT_AVAILABLE_LABEL } from '../../../common/i18n';
|
||||
import { ApmIndicesConfig } from '../settings/apm_indices/get_apm_indices';
|
||||
import { getDataStreams } from './bundle/get_data_streams';
|
||||
import { getNonDataStreamIndices } from './bundle/get_non_data_stream_indices';
|
||||
|
@ -15,7 +16,7 @@ import { getExistingApmIndexTemplates } from './bundle/get_existing_index_templa
|
|||
import { getIndicesStates } from './bundle/get_indices_states';
|
||||
import { getApmEvents } from './bundle/get_apm_events';
|
||||
import { getApmIndexTemplates } from './helpers/get_apm_index_template_names';
|
||||
import { handle403Exception } from './helpers/handle_403_exception';
|
||||
import { handleExceptions } from './helpers/handle_exceptions';
|
||||
import { getDiagnosticsPrivileges } from './helpers/get_diagnostic_privileges';
|
||||
|
||||
const DEFEAULT_START = Date.now() - 60 * 5 * 1000; // 5 minutes
|
||||
|
@ -39,62 +40,54 @@ export async function getDiagnosticsBundle({
|
|||
apmIndices,
|
||||
});
|
||||
|
||||
const indexTemplatesByIndexPattern = await handle403Exception(
|
||||
getIndexTemplatesByIndexPattern({
|
||||
esClient,
|
||||
apmIndices,
|
||||
}),
|
||||
[]
|
||||
);
|
||||
const indexTemplatesByIndexPattern =
|
||||
(await handleExceptions(
|
||||
getIndexTemplatesByIndexPattern({
|
||||
esClient,
|
||||
apmIndices,
|
||||
})
|
||||
)) ?? [];
|
||||
|
||||
const existingIndexTemplates = await handle403Exception(
|
||||
getExistingApmIndexTemplates({
|
||||
esClient,
|
||||
}),
|
||||
[]
|
||||
);
|
||||
const existingIndexTemplates =
|
||||
(await handleExceptions(
|
||||
getExistingApmIndexTemplates({
|
||||
esClient,
|
||||
})
|
||||
)) ?? [];
|
||||
|
||||
const dataStreams = await handle403Exception(
|
||||
getDataStreams({ esClient, apmIndices }),
|
||||
[]
|
||||
);
|
||||
const nonDataStreamIndices = await handle403Exception(
|
||||
getNonDataStreamIndices({
|
||||
esClient,
|
||||
apmIndices,
|
||||
}),
|
||||
[]
|
||||
);
|
||||
const dataStreams =
|
||||
(await handleExceptions(getDataStreams({ esClient, apmIndices }))) ?? [];
|
||||
|
||||
const nonDataStreamIndices =
|
||||
(await handleExceptions(
|
||||
getNonDataStreamIndices({
|
||||
esClient,
|
||||
apmIndices,
|
||||
})
|
||||
)) ?? [];
|
||||
|
||||
const { invalidIndices, validIndices, indices, ingestPipelines, fieldCaps } =
|
||||
await handle403Exception(
|
||||
(await handleExceptions(
|
||||
getIndicesStates({
|
||||
esClient,
|
||||
apmIndices,
|
||||
}),
|
||||
{
|
||||
invalidIndices: [],
|
||||
validIndices: [],
|
||||
indices: [],
|
||||
ingestPipelines: [],
|
||||
fieldCaps: {},
|
||||
}
|
||||
);
|
||||
})
|
||||
)) ?? {};
|
||||
|
||||
const apmEvents = await handle403Exception(
|
||||
getApmEvents({
|
||||
esClient,
|
||||
apmIndices,
|
||||
start,
|
||||
end,
|
||||
kuery,
|
||||
}),
|
||||
[]
|
||||
);
|
||||
const elasticsearchVersion = await handle403Exception(
|
||||
getElasticsearchVersion(esClient),
|
||||
'N/A'
|
||||
);
|
||||
const apmEvents =
|
||||
(await handleExceptions(
|
||||
getApmEvents({
|
||||
esClient,
|
||||
apmIndices,
|
||||
start,
|
||||
end,
|
||||
kuery,
|
||||
})
|
||||
)) ?? [];
|
||||
|
||||
const elasticsearchVersion =
|
||||
(await handleExceptions(getElasticsearchVersion(esClient))) ??
|
||||
NOT_AVAILABLE_LABEL;
|
||||
|
||||
return {
|
||||
created_at: new Date().toISOString(),
|
||||
|
|
|
@ -6,10 +6,7 @@
|
|||
*/
|
||||
import { errors } from '@elastic/elasticsearch';
|
||||
|
||||
export async function handle403Exception<T>(
|
||||
promise: Promise<T>,
|
||||
defaultValue: unknown
|
||||
) {
|
||||
export async function handleExceptions<T>(promise: Promise<T>) {
|
||||
try {
|
||||
return await promise;
|
||||
} catch (error) {
|
||||
|
@ -18,13 +15,13 @@ export async function handle403Exception<T>(
|
|||
error.meta.statusCode === 403
|
||||
) {
|
||||
console.error(`Suppressed insufficient access error: ${error.message}}`);
|
||||
return defaultValue as T;
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(
|
||||
`Unhandled error: ${error.message} ${JSON.stringify(error)}}`
|
||||
);
|
||||
|
||||
throw error;
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -53,9 +53,9 @@ const getDiagnosticsRoute = createApmServerRoute({
|
|||
): Promise<{
|
||||
esResponses: {
|
||||
existingIndexTemplates: IndicesGetIndexTemplateIndexTemplateItem[];
|
||||
fieldCaps: FieldCapsResponse;
|
||||
indices: IndicesGetResponse;
|
||||
ingestPipelines: IngestGetPipelineResponse;
|
||||
fieldCaps?: FieldCapsResponse;
|
||||
indices?: IndicesGetResponse;
|
||||
ingestPipelines?: IngestGetPipelineResponse;
|
||||
};
|
||||
diagnosticsPrivileges: {
|
||||
index: Record<string, SecurityHasPrivilegesPrivileges>;
|
||||
|
@ -77,8 +77,8 @@ const getDiagnosticsRoute = createApmServerRoute({
|
|||
kibanaVersion: string;
|
||||
elasticsearchVersion: string;
|
||||
apmEvents: ApmEvent[];
|
||||
invalidIndices: IndiciesItem[];
|
||||
validIndices: IndiciesItem[];
|
||||
invalidIndices?: IndiciesItem[];
|
||||
validIndices?: IndiciesItem[];
|
||||
dataStreams: IndicesDataStream[];
|
||||
nonDataStreamIndices: string[];
|
||||
indexTemplatesByIndexPattern: Array<{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue