[Monitoring] Ensure we pass down all the parameters for fetching logs (#43869) (#44397)

* Ensure we pass these all the way down

* Add additional test

* Fix tests

* PR feedback

* Update copy and test wording
This commit is contained in:
Chris Roberson 2019-08-29 14:45:49 -04:00 committed by GitHub
parent 6d3e3eb2bc
commit c0c922355c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 4773 additions and 11 deletions

View file

@ -1,5 +1,36 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Logs should render a default message 1`] = `
<EuiCallOut
color="warning"
iconType="help"
size="m"
title="No log data found"
>
<p>
<FormattedMessage
defaultMessage="We did not find any log data and we are unable to diagnose why. {link}"
id="xpack.monitoring.logs.reason.defaultMessage"
values={
Object {
"link": <EuiLink
color="primary"
href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation.html"
type="button"
>
<FormattedMessage
defaultMessage="Please verify your setup is correct."
id="xpack.monitoring.logs.reason.defaultMessageLink"
values={Object {}}
/>
</EuiLink>,
}
}
/>
</p>
</EuiCallOut>
`;
exports[`Logs should render with a no cluster found reason 1`] = `
<EuiCallOut
color="warning"

View file

@ -11,10 +11,28 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } from 'ui/documentation_links';
export const Reason = ({ reason }) => {
let title;
let message;
let title = i18n.translate('xpack.monitoring.logs.reason.defaultTitle', {
defaultMessage: 'No log data found'
});
let message = (
<FormattedMessage
id="xpack.monitoring.logs.reason.defaultMessage"
defaultMessage="We did not find any log data and we are unable to diagnose why. {link}"
values={{
link: (
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
<FormattedMessage
id="xpack.monitoring.logs.reason.defaultMessageLink"
defaultMessage="Please verify your setup is correct."
/>
</EuiLink>
)
}}
/>
);
if (false === reason.indexPatternExists) {
title = i18n.translate('xpack.monitoring.logs.reason.noIndexPatternTitle', {
@ -26,7 +44,7 @@ export const Reason = ({ reason }) => {
defaultMessage="Set up {link}, then configure your Elasticsearch output to your monitoring cluster."
values={{
link: (
<EuiLink href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation.html">
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
{i18n.translate('xpack.monitoring.logs.reason.noIndexPatternLink', {
defaultMessage: 'Filebeat'
})}
@ -57,7 +75,7 @@ export const Reason = ({ reason }) => {
defaultMessage="Follow {link} to set up Elasticsearch."
values={{
link: (
<EuiLink href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-elasticsearch.html">
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}>
{i18n.translate('xpack.monitoring.logs.reason.noTypeLink', {
defaultMessage: 'these directions'
})}
@ -77,7 +95,7 @@ export const Reason = ({ reason }) => {
defaultMessage="Check that your {link} is correct."
values={{
link: (
<EuiLink href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation.html">
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
{i18n.translate('xpack.monitoring.logs.reason.noClusterLink', {
defaultMessage: 'setup'
})}
@ -97,7 +115,7 @@ export const Reason = ({ reason }) => {
defaultMessage="Check that your {link} is correct."
values={{
link: (
<EuiLink href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation.html">
<EuiLink href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}>
{i18n.translate('xpack.monitoring.logs.reason.noNodeLink', {
defaultMessage: 'setup'
})}

View file

@ -8,7 +8,17 @@ import React from 'react';
import { shallow } from 'enzyme';
import { Reason } from './reason';
jest.mock('ui/documentation_links', () => ({
ELASTIC_WEBSITE_URL: 'https://www.elastic.co/',
DOC_LINK_VERSION: 'current'
}));
describe('Logs', () => {
it('should render a default message', () => {
const component = shallow(<Reason reason={{}}/>);
expect(component).toMatchSnapshot();
});
it('should render with a no index pattern found reason', () => {
const component = shallow(<Reason reason={{ indexPatternExists: false }}/>);
expect(component).toMatchSnapshot();

View file

@ -9,7 +9,7 @@ import { checkParam } from '../error_missing_required';
import { createTimeFilter } from '../create_query';
import { detectReason } from './detect_reason';
async function handleResponse(response, req, filebeatIndexPattern, { start, end }) {
async function handleResponse(response, req, filebeatIndexPattern, opts) {
const result = {
enabled: false,
types: []
@ -31,7 +31,7 @@ async function handleResponse(response, req, filebeatIndexPattern, { start, end
});
}
else {
result.reason = await detectReason(req, filebeatIndexPattern, { start, end });
result.reason = await detectReason(req, filebeatIndexPattern, opts);
}
return result;
@ -89,5 +89,5 @@ 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, { start, end });
return await handleResponse(response, req, filebeatIndexPattern, { clusterUuid, nodeUuid, indexUuid, start, end });
}

View file

@ -63,7 +63,7 @@
"logs": {
"enabled": false,
"reason": {
"clusterExists": null,
"clusterExists": false,
"indexPatternExists": false,
"indexPatternInTimeRangeExists": false,
"nodeExists": null,

View file

@ -0,0 +1,13 @@
{
"enabled": false,
"types": [],
"reason": {
"indexPatternExists": true,
"indexPatternInTimeRangeExists": true,
"typeExistsAtAnyTime": true,
"typeExists": true,
"clusterExists": false,
"nodeExists": null,
"indexExists": null
}
}

View file

@ -9,5 +9,6 @@ export default function ({ loadTestFile }) {
loadTestFile(require.resolve('./node_detail'));
loadTestFile(require.resolve('./index_detail'));
loadTestFile(require.resolve('./cluster'));
loadTestFile(require.resolve('./multiple_clusters'));
});
}

View file

@ -0,0 +1,40 @@
/*
* 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.
*/
import expect from '@kbn/expect';
import multipleClustersFixture from './fixtures/multiple_clusters';
export default function ({ getService }) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
describe('multiple cluster', () => {
const archive = 'monitoring/logs_multiple_clusters';
const timeRange = {
min: '2019-08-23T14:14:31.686Z',
max: '2019-08-23T15:14:31.686Z'
};
const codePaths = ['logs'];
before('load archive', () => {
return esArchiver.load(archive);
});
after('unload archive', () => {
return esArchiver.unload(archive);
});
it('should not find any logs for cluster B when the logs were sent to cluster A', async () => {
const { body } = await supertest
.post('/api/monitoring/v1/clusters/yrpCVAZcSYW68_pAYTeKuw')
.set('kbn-xsrf', 'xxx')
.send({ timeRange, codePaths })
.expect(200);
expect(body[0].elasticsearch.logs).to.eql(multipleClustersFixture);
});
});
}

View file

@ -12,7 +12,7 @@
"logs": {
"enabled": false,
"reason": {
"clusterExists": null,
"clusterExists": false,
"indexPatternExists": false,
"indexPatternInTimeRangeExists": false,
"typeExistsAtAnyTime": false,