diff --git a/x-pack/legacy/plugins/monitoring/public/components/logs/__snapshots__/reason.test.js.snap b/x-pack/legacy/plugins/monitoring/public/components/logs/__snapshots__/reason.test.js.snap index fa4b11ed57240..70fb86b06e14c 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/logs/__snapshots__/reason.test.js.snap +++ b/x-pack/legacy/plugins/monitoring/public/components/logs/__snapshots__/reason.test.js.snap @@ -14,6 +14,7 @@ exports[`Logs should render a default message 1`] = ` Object { "link": `; +exports[`Logs should render with a bad indices reason 1`] = ` + +

+ + this issue + , + } + } + /> +

+
+`; + exports[`Logs should render with a no cluster found reason 1`] = ` setup
, @@ -66,6 +93,7 @@ exports[`Logs should render with a no index found reason 1`] = ` Object { "link": setup , @@ -90,6 +118,7 @@ exports[`Logs should render with a no index pattern found reason 1`] = ` Object { "link": Filebeat , @@ -114,6 +143,7 @@ exports[`Logs should render with a no node found reason 1`] = ` Object { "link": setup , @@ -138,6 +168,7 @@ exports[`Logs should render with a no type found reason 1`] = ` Object { "link": these directions , diff --git a/x-pack/legacy/plugins/monitoring/public/components/logs/reason.js b/x-pack/legacy/plugins/monitoring/public/components/logs/reason.js index a2acbe4ac3a58..3dda60a87a635 100644 --- a/x-pack/legacy/plugins/monitoring/public/components/logs/reason.js +++ b/x-pack/legacy/plugins/monitoring/public/components/logs/reason.js @@ -23,7 +23,7 @@ export const Reason = ({ reason }) => { defaultMessage="We did not find any log data and we are unable to diagnose why. {link}" values={{ link: ( - + { defaultMessage="Set up {link}, then configure your Elasticsearch output to your monitoring cluster." values={{ link: ( - + {i18n.translate('xpack.monitoring.logs.reason.noIndexPatternLink', { defaultMessage: 'Filebeat' })} @@ -75,7 +75,10 @@ export const Reason = ({ reason }) => { defaultMessage="Follow {link} to set up Elasticsearch." values={{ link: ( - + {i18n.translate('xpack.monitoring.logs.reason.noTypeLink', { defaultMessage: 'these directions' })} @@ -95,7 +98,7 @@ export const Reason = ({ reason }) => { defaultMessage="Check that your {link} is correct." values={{ link: ( - + {i18n.translate('xpack.monitoring.logs.reason.noClusterLink', { defaultMessage: 'setup' })} @@ -115,7 +118,7 @@ export const Reason = ({ reason }) => { defaultMessage="Check that your {link} is correct." values={{ link: ( - + {i18n.translate('xpack.monitoring.logs.reason.noNodeLink', { defaultMessage: 'setup' })} @@ -135,7 +138,7 @@ export const Reason = ({ reason }) => { defaultMessage="We found logs, but none for this index. If this problem continues, check that your {link} is correct." values={{ link: ( - + {i18n.translate('xpack.monitoring.logs.reason.noNodeLink', { defaultMessage: 'setup' })} @@ -145,6 +148,26 @@ export const Reason = ({ reason }) => { /> ); } + else if (false === reason.correctIndexName) { + title = i18n.translate('xpack.monitoring.logs.reason.correctIndexNameTitle', { + defaultMessage: 'Corrupted filebeat index' + }); + message = ( + + {i18n.translate('xpack.monitoring.logs.reason.noNodeLink', { + defaultMessage: 'this issue' + })} + + ) + }} + /> + ); + } return ( { />); expect(component).toMatchSnapshot(); }); + + it('should render with a bad indices reason', () => { + const component = shallow(); + expect(component).toMatchSnapshot(); + }); }); diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logs/detect_reason_from_exception.js b/x-pack/legacy/plugins/monitoring/server/lib/logs/detect_reason_from_exception.js new file mode 100644 index 0000000000000..c88d55df8efa1 --- /dev/null +++ b/x-pack/legacy/plugins/monitoring/server/lib/logs/detect_reason_from_exception.js @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export function detectReasonFromException(exception) { + const reason = {}; + + if (exception) { + if (exception.status === 400 && exception.message.indexOf('Fielddata is disabled on text fields by default') > -1) { + reason.correctIndexName = false; + } + } + + return reason; +} diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logs/get_log_types.js b/x-pack/legacy/plugins/monitoring/server/lib/logs/get_log_types.js index 2a16b0b89b5e8..606a50a3612ee 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logs/get_log_types.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logs/get_log_types.js @@ -8,6 +8,7 @@ import { get } from 'lodash'; import { checkParam } from '../error_missing_required'; import { createTimeFilter } from '../create_query'; import { detectReason } from './detect_reason'; +import { detectReasonFromException } from './detect_reason_from_exception'; async function handleResponse(response, req, filebeatIndexPattern, opts) { const result = { @@ -88,6 +89,13 @@ export async function getLogTypes(req, filebeatIndexPattern, { clusterUuid, node }; const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('monitoring'); - const response = await callWithRequest(req, 'search', params); - return await handleResponse(response, req, filebeatIndexPattern, { clusterUuid, nodeUuid, indexUuid, start, end }); + let result = {}; + try { + const response = await callWithRequest(req, 'search', params); + result = await handleResponse(response, req, filebeatIndexPattern, { clusterUuid, nodeUuid, indexUuid, start, end }); + } + catch (err) { + result.reason = detectReasonFromException(err); + } + return result; } diff --git a/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js b/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js index 0d45b8c6a1c4e..e9c36dd7295c9 100644 --- a/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js +++ b/x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js @@ -11,6 +11,7 @@ import { createTimeFilter } from '../create_query'; import { detectReason } from './detect_reason'; import { formatUTCTimestampForTimezone } from '../format_timezone'; import { getTimezone } from '../get_timezone'; +import { detectReasonFromException } from './detect_reason_from_exception'; async function handleResponse(response, req, filebeatIndexPattern, opts) { const result = { @@ -87,8 +88,16 @@ export async function getLogs(config, req, filebeatIndexPattern, { clusterUuid, }; const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('monitoring'); - const response = await callWithRequest(req, 'search', params); - const result = await handleResponse(response, req, filebeatIndexPattern, { clusterUuid, nodeUuid, indexUuid, start, end }); + + let result = {}; + try { + const response = await callWithRequest(req, 'search', params); + result = await handleResponse(response, req, filebeatIndexPattern, { clusterUuid, nodeUuid, indexUuid, start, end }); + } + catch (err) { + result.reason = detectReasonFromException(err); + } + return { ...result, limit: params.size,