Skip to content

Commit

Permalink
Merge branch 'master' into apm-rum
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Dec 17, 2019
2 parents 1b27050 + b7ff35d commit a7ff3b3
Show file tree
Hide file tree
Showing 60 changed files with 777 additions and 695 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
/x-pack/legacy/plugins/alerting @elastic/kibana-alerting-services
/x-pack/legacy/plugins/actions @elastic/kibana-alerting-services
/x-pack/legacy/plugins/task_manager @elastic/kibana-alerting-services
/x-pack/test/alerting_api_integration @elastic/kibana-alerting-services
/x-pack/test/plugin_api_integration/plugins/task_manager @elastic/kibana-alerting-services
/x-pack/test/plugin_api_integration/test_suites/task_manager @elastic/kibana-alerting-services

# Design
**/*.scss @elastic/kibana-design
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions x-pack/legacy/plugins/monitoring/public/components/logs/reason.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EuiCallOut, EuiLink } 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';
import { Monospace } from '../metricbeat_migration/instruction_steps/components/monospace/monospace';

export const Reason = ({ reason }) => {
let title = i18n.translate('xpack.monitoring.logs.reason.defaultTitle', {
Expand Down Expand Up @@ -91,6 +92,29 @@ export const Reason = ({ reason }) => {
}}
/>
);
} else if (false === reason.usingStructuredLogs) {
title = i18n.translate('xpack.monitoring.logs.reason.notUsingStructuredLogsTitle', {
defaultMessage: 'No structured logs found',
});
message = (
<FormattedMessage
id="xpack.monitoring.logs.reason.notUsingStructuredLogsMessage"
defaultMessage="Check if the {varPaths} setting {link}."
values={{
varPaths: <Monospace>var.paths</Monospace>,
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}
>
{i18n.translate('xpack.monitoring.logs.reason.notUsingStructuredLogsLink', {
defaultMessage: 'points to JSON logs',
})}
</EuiLink>
),
}}
/>
);
} else if (false === reason.clusterExists) {
title = i18n.translate('xpack.monitoring.logs.reason.noClusterTitle', {
defaultMessage: 'No logs for this cluster',
Expand All @@ -103,7 +127,7 @@ export const Reason = ({ reason }) => {
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}
>
{i18n.translate('xpack.monitoring.logs.reason.noClusterLink', {
defaultMessage: 'setup',
Expand All @@ -125,7 +149,7 @@ export const Reason = ({ reason }) => {
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}
>
{i18n.translate('xpack.monitoring.logs.reason.noNodeLink', {
defaultMessage: 'setup',
Expand All @@ -147,7 +171,7 @@ export const Reason = ({ reason }) => {
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation.html`}
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}
>
{i18n.translate('xpack.monitoring.logs.reason.noIndexLink', {
defaultMessage: 'setup',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ describe('Logs', () => {
expect(component).toMatchSnapshot();
});

it('should render with a no structured logs reason', () => {
const component = shallow(
<Reason reason={{ indexPatternExists: true, typeExists: true, usingStructuredLogs: false }} />
);
expect(component).toMatchSnapshot();
});

it('should render with a no cluster found reason', () => {
const component = shallow(
<Reason reason={{ indexPatternExists: true, typeExists: true, clusterExists: false }} />
Expand Down
13 changes: 13 additions & 0 deletions x-pack/legacy/plugins/monitoring/server/lib/logs/detect_reason.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async function doesFilebeatIndexExist(
const filter = [createTimeFilter({ start, end, metric })];

const typeFilter = { term: { 'service.type': 'elasticsearch' } };
const structuredLogsFilter = { exists: { field: 'elasticsearch.cluster' } };
const clusterFilter = { term: { 'elasticsearch.cluster.uuid': clusterUuid } };
const nodeFilter = { term: { 'elasticsearch.node.id': nodeUuid } };
const indexFilter = { term: { 'elasticsearch.index.name': indexUuid } };
Expand Down Expand Up @@ -44,6 +45,14 @@ async function doesFilebeatIndexExist(
},
};

const usingStructuredLogsQuery = {
query: {
bool: {
filter: [...filter, typeFilter, structuredLogsFilter],
},
},
};

const clusterExistsQuery = {
query: {
bool: {
Expand Down Expand Up @@ -81,6 +90,8 @@ async function doesFilebeatIndexExist(
{ ...defaultParams, ...typeExistsAtAnyTimeQuery },
{ index: filebeatIndexPattern },
{ ...defaultParams, ...typeExistsQuery },
{ index: filebeatIndexPattern },
{ ...defaultParams, ...usingStructuredLogsQuery },
];

if (clusterUuid) {
Expand All @@ -102,6 +113,7 @@ async function doesFilebeatIndexExist(
indexPatternExistsInTimeRangeResponse,
typeExistsAtAnyTimeResponse,
typeExistsResponse,
usingStructuredLogsResponse,
clusterExistsResponse,
nodeExistsResponse,
indexExistsResponse,
Expand All @@ -114,6 +126,7 @@ async function doesFilebeatIndexExist(
get(indexPatternExistsInTimeRangeResponse, 'hits.total.value', 0) > 0,
typeExistsAtAnyTime: get(typeExistsAtAnyTimeResponse, 'hits.total.value', 0) > 0,
typeExists: get(typeExistsResponse, 'hits.total.value', 0) > 0,
usingStructuredLogs: get(usingStructuredLogsResponse, 'hits.total.value', 0) > 0,
clusterExists: clusterUuid ? get(clusterExistsResponse, 'hits.total.value', 0) > 0 : null,
nodeExists: nodeUuid ? get(nodeExistsResponse, 'hits.total.value', 0) > 0 : null,
indexExists: indexUuid ? get(indexExistsResponse, 'hits.total.value', 0) > 0 : null,
Expand Down
3 changes: 1 addition & 2 deletions x-pack/legacy/plugins/uptime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ export const uptime = (kibana: any) =>
init(server: KibanaServer) {
const initializerContext = {} as PluginInitializerContext;
const { savedObjects } = server;
const { elasticsearch, xpack_main } = server.plugins;
const { xpack_main } = server.plugins;
const { usageCollection } = server.newPlatform.setup.plugins;

plugin(initializerContext).setup(
{
route: server.newPlatform.setup.core.http.createRouter(),
},
{
elasticsearch,
savedObjects,
usageCollection,
xpack: xpack_main,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const createMonitorStatesResolvers: CreateUMGraphQLResolvers = (
return {
Query: {
async getMonitorStates(
resolver,
_resolver,
{ dateRangeStart, dateRangeEnd, filters, pagination, statusFilter },
{ req }
{ APICaller }
): Promise<MonitorSummaryResult> {
const decodedPagination = pagination
? JSON.parse(decodeURIComponent(pagination))
Expand All @@ -50,15 +50,18 @@ export const createMonitorStatesResolvers: CreateUMGraphQLResolvers = (
totalSummaryCount,
{ summaries, nextPagePagination, prevPagePagination },
] = await Promise.all([
libs.pings.getDocCount(req),
libs.monitorStates.getMonitorStates(
req,
libs.pings.getDocCount({ callES: APICaller }),
libs.monitorStates.getMonitorStates({
callES: APICaller,
dateRangeStart,
dateRangeEnd,
decodedPagination,
pagination: decodedPagination,
filters,
statusFilter
),
// this is added to make typescript happy,
// this sort of reassignment used to be further downstream but I've moved it here
// because this code is going to be decomissioned soon
statusFilter: statusFilter || undefined,
}),
]);
return {
summaries,
Expand All @@ -67,8 +70,8 @@ export const createMonitorStatesResolvers: CreateUMGraphQLResolvers = (
totalSummaryCount,
};
},
async getStatesIndexStatus(resolver, {}, { req }): Promise<StatesIndexStatus> {
return await libs.monitorStates.statesIndexExists(req);
async getStatesIndexStatus(_resolver, {}, { APICaller }): Promise<StatesIndexStatus> {
return await libs.monitorStates.statesIndexExists({ callES: APICaller });
},
},
};
Expand Down
54 changes: 31 additions & 23 deletions x-pack/legacy/plugins/uptime/server/graphql/monitors/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,54 +71,62 @@ export const createMonitorsResolvers: CreateUMGraphQLResolvers = (
} => ({
Query: {
async getSnapshotHistogram(
resolver,
_resolver,
{ dateRangeStart, dateRangeEnd, filters, monitorId, statusFilter },
{ req }
{ APICaller }
): Promise<HistogramResult> {
return await libs.pings.getPingHistogram(
req,
return await libs.pings.getPingHistogram({
callES: APICaller,
dateRangeStart,
dateRangeEnd,
filters,
monitorId,
statusFilter
);
statusFilter,
});
},
async getMonitorChartsData(
resolver,
_resolver,
{ monitorId, dateRangeStart, dateRangeEnd, location },
{ req }
{ APICaller }
): Promise<MonitorChart> {
return await libs.monitors.getMonitorChartsData(
req,
return await libs.monitors.getMonitorChartsData({
callES: APICaller,
monitorId,
dateRangeStart,
dateRangeEnd,
location
);
location,
});
},
async getLatestMonitors(
resolver,
_resolver,
{ dateRangeStart, dateRangeEnd, monitorId, location },
{ req }
{ APICaller }
): Promise<Ping[]> {
return await libs.pings.getLatestMonitorDocs(
req,
return await libs.pings.getLatestMonitorDocs({
callES: APICaller,
dateRangeStart,
dateRangeEnd,
monitorId,
location
);
location,
});
},
async getFilterBar(resolver, { dateRangeStart, dateRangeEnd }, { req }): Promise<FilterBar> {
return await libs.monitors.getFilterBar(req, dateRangeStart, dateRangeEnd);
async getFilterBar(
_resolver,
{ dateRangeStart, dateRangeEnd },
{ APICaller }
): Promise<FilterBar> {
return await libs.monitors.getFilterBar({
callES: APICaller,
dateRangeStart,
dateRangeEnd,
});
},
async getMonitorPageTitle(
resolver: any,
_resolver: any,
{ monitorId },
{ req }
{ APICaller }
): Promise<MonitorPageTitle | null> {
return await libs.monitors.getMonitorPageTitle(req, monitorId);
return await libs.monitors.getMonitorPageTitle({ callES: APICaller, monitorId });
},
},
});
16 changes: 8 additions & 8 deletions x-pack/legacy/plugins/uptime/server/graphql/pings/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ export const createPingsResolvers: CreateUMGraphQLResolvers = (
} => ({
Query: {
async allPings(
resolver,
_resolver,
{ monitorId, sort, size, status, dateRangeStart, dateRangeEnd, location },
{ req }
{ APICaller }
): Promise<PingResults> {
return await libs.pings.getAll(
req,
return await libs.pings.getAll({
callES: APICaller,
dateRangeStart,
dateRangeEnd,
monitorId,
status,
sort,
size,
location
);
location,
});
},
async getDocCount(resolver, args, { req }): Promise<DocCount> {
return libs.pings.getDocCount(req);
async getDocCount(_resolver, _args, { APICaller }): Promise<DocCount> {
return libs.pings.getDocCount({ callES: APICaller });
},
},
});
Loading

0 comments on commit a7ff3b3

Please sign in to comment.