Skip to content

Commit eb49f7b

Browse files
committed
[Monitoring] Gracefully handle issue with filebeat indices (#48929)
* Gracefully handle issue with filebeat indices * Update translation keys * Update link * Add in default, per PR comment
1 parent 7927447 commit eb49f7b

6 files changed

Lines changed: 110 additions & 11 deletions

File tree

x-pack/legacy/plugins/monitoring/public/components/logs/__snapshots__/reason.test.js.snap

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/legacy/plugins/monitoring/public/components/logs/reason.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const Reason = ({ reason }) => {
2323
defaultMessage="We did not find any log data and we are unable to diagnose why. {link}"
2424
values={{
2525
link: (
26-
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
26+
<EuiLink target="_blank" href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
2727
<FormattedMessage
2828
id="xpack.monitoring.logs.reason.defaultMessageLink"
2929
defaultMessage="Please verify your setup is correct."
@@ -44,7 +44,7 @@ export const Reason = ({ reason }) => {
4444
defaultMessage="Set up {link}, then configure your Elasticsearch output to your monitoring cluster."
4545
values={{
4646
link: (
47-
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
47+
<EuiLink target="_blank" href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
4848
{i18n.translate('xpack.monitoring.logs.reason.noIndexPatternLink', {
4949
defaultMessage: 'Filebeat'
5050
})}
@@ -75,7 +75,10 @@ export const Reason = ({ reason }) => {
7575
defaultMessage="Follow {link} to set up Elasticsearch."
7676
values={{
7777
link: (
78-
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}>
78+
<EuiLink
79+
target="_blank"
80+
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}
81+
>
7982
{i18n.translate('xpack.monitoring.logs.reason.noTypeLink', {
8083
defaultMessage: 'these directions'
8184
})}
@@ -95,7 +98,7 @@ export const Reason = ({ reason }) => {
9598
defaultMessage="Check that your {link} is correct."
9699
values={{
97100
link: (
98-
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
101+
<EuiLink target="_blank" href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
99102
{i18n.translate('xpack.monitoring.logs.reason.noClusterLink', {
100103
defaultMessage: 'setup'
101104
})}
@@ -115,7 +118,7 @@ export const Reason = ({ reason }) => {
115118
defaultMessage="Check that your {link} is correct."
116119
values={{
117120
link: (
118-
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
121+
<EuiLink target="_blank" href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
119122
{i18n.translate('xpack.monitoring.logs.reason.noNodeLink', {
120123
defaultMessage: 'setup'
121124
})}
@@ -135,8 +138,8 @@ export const Reason = ({ reason }) => {
135138
defaultMessage="We found logs, but none for this index. If this problem continues, check that your {link} is correct."
136139
values={{
137140
link: (
138-
<EuiLink href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation.html">
139-
{i18n.translate('xpack.monitoring.logs.reason.noNodeLink', {
141+
<EuiLink target="_blank" href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
142+
{i18n.translate('xpack.monitoring.logs.reason.noIndexLink', {
140143
defaultMessage: 'setup'
141144
})}
142145
</EuiLink>
@@ -145,6 +148,29 @@ export const Reason = ({ reason }) => {
145148
/>
146149
);
147150
}
151+
else if (false === reason.correctIndexName) {
152+
title = i18n.translate('xpack.monitoring.logs.reason.correctIndexNameTitle', {
153+
defaultMessage: 'Corrupted filebeat index'
154+
});
155+
message = (
156+
<FormattedMessage
157+
id="xpack.monitoring.logs.reason.correctIndexNameMessage"
158+
defaultMessage="There is an issue reading from your filebeat indices. {link}."
159+
values={{
160+
link: (
161+
<EuiLink
162+
target="_blank"
163+
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/monitor-troubleshooting.html`}
164+
>
165+
{i18n.translate('xpack.monitoring.logs.reason.correctIndexNameLink', {
166+
defaultMessage: 'Click here for more information'
167+
})}
168+
</EuiLink>
169+
)
170+
}}
171+
/>
172+
);
173+
}
148174

149175
return (
150176
<EuiCallOut

x-pack/legacy/plugins/monitoring/public/components/logs/reason.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,12 @@ describe('Logs', () => {
7171
/>);
7272
expect(component).toMatchSnapshot();
7373
});
74+
75+
it('should render with a bad indices reason', () => {
76+
const component = shallow(<Reason reason={{
77+
correctIndexName: false
78+
}}
79+
/>);
80+
expect(component).toMatchSnapshot();
81+
});
7482
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export function detectReasonFromException(exception) {
8+
const reason = { correctIndexName: true };
9+
10+
if (exception) {
11+
if (exception.status === 400 && exception.message.indexOf('Fielddata is disabled on text fields by default') > -1) {
12+
reason.correctIndexName = false;
13+
}
14+
}
15+
16+
return reason;
17+
}

x-pack/legacy/plugins/monitoring/server/lib/logs/get_log_types.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { get } from 'lodash';
88
import { checkParam } from '../error_missing_required';
99
import { createTimeFilter } from '../create_query';
1010
import { detectReason } from './detect_reason';
11+
import { detectReasonFromException } from './detect_reason_from_exception';
1112

1213
async function handleResponse(response, req, filebeatIndexPattern, opts) {
1314
const result = {
@@ -88,6 +89,13 @@ export async function getLogTypes(req, filebeatIndexPattern, { clusterUuid, node
8889
};
8990

9091
const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('monitoring');
91-
const response = await callWithRequest(req, 'search', params);
92-
return await handleResponse(response, req, filebeatIndexPattern, { clusterUuid, nodeUuid, indexUuid, start, end });
92+
let result = {};
93+
try {
94+
const response = await callWithRequest(req, 'search', params);
95+
result = await handleResponse(response, req, filebeatIndexPattern, { clusterUuid, nodeUuid, indexUuid, start, end });
96+
}
97+
catch (err) {
98+
result.reason = detectReasonFromException(err);
99+
}
100+
return result;
93101
}

x-pack/legacy/plugins/monitoring/server/lib/logs/get_logs.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { createTimeFilter } from '../create_query';
1111
import { detectReason } from './detect_reason';
1212
import { formatUTCTimestampForTimezone } from '../format_timezone';
1313
import { getTimezone } from '../get_timezone';
14+
import { detectReasonFromException } from './detect_reason_from_exception';
1415

1516
async function handleResponse(response, req, filebeatIndexPattern, opts) {
1617
const result = {
@@ -87,8 +88,16 @@ export async function getLogs(config, req, filebeatIndexPattern, { clusterUuid,
8788
};
8889

8990
const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('monitoring');
90-
const response = await callWithRequest(req, 'search', params);
91-
const result = await handleResponse(response, req, filebeatIndexPattern, { clusterUuid, nodeUuid, indexUuid, start, end });
91+
92+
let result = {};
93+
try {
94+
const response = await callWithRequest(req, 'search', params);
95+
result = await handleResponse(response, req, filebeatIndexPattern, { clusterUuid, nodeUuid, indexUuid, start, end });
96+
}
97+
catch (err) {
98+
result.reason = detectReasonFromException(err);
99+
}
100+
92101
return {
93102
...result,
94103
limit: params.size,

0 commit comments

Comments
 (0)