Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use doc link service in more Stack Monitoring pages #89050

Merged
merged 4 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ readonly links: {
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly elasticsearchModule: string;
readonly startup: string;
readonly exportedFields: string;
};
Expand All @@ -29,6 +30,10 @@ readonly links: {
};
readonly metricbeat: {
readonly base: string;
readonly configure: string;
readonly httpEndpoint: string;
readonly install: string;
readonly start: string;
};
readonly enterpriseSearch: {
readonly base: string;
Expand Down
13 changes: 13 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class DocLinksService {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}`,
installation: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation-configuration.html`,
configuration: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/configuring-howto-filebeat.html`,
elasticsearchModule: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`,
elasticsearchOutput: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/elasticsearch-output.html`,
startup: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-starting.html`,
exportedFields: `${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/exported-fields.html`,
Expand All @@ -53,6 +54,10 @@ export class DocLinksService {
},
metricbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}`,
configure: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}/configuring-howto-metricbeat.html`,
httpEndpoint: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}/http-endpoint.html`,
install: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}/metricbeat-installation-configuration.html`,
start: `${ELASTIC_WEBSITE_URL}guide/en/beats/metricbeat/${DOC_LINK_VERSION}/metricbeat-starting.html`,
},
heartbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/heartbeat/${DOC_LINK_VERSION}`,
Expand Down Expand Up @@ -193,8 +198,11 @@ export class DocLinksService {
alertsKibanaDiskThreshold: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/kibana-alerts.html#kibana-alerts-disk-usage-threshold`,
alertsKibanaJvmThreshold: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/kibana-alerts.html#kibana-alerts-jvm-memory-threshold`,
alertsKibanaMissingData: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/kibana-alerts.html#kibana-alerts-missing-monitoring-data`,
metricbeatBlog: `${ELASTIC_WEBSITE_URL}blog/external-collection-for-elastic-stack-monitoring-is-now-available-via-metricbeat`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: As this URL doesn't rely on ${DOC_LINK_VERSION}, and there might be more metricbeat blog links in the future, it might make more sense to keep the prior implementation where the consuming code is just using ELASTIC_WEBSITE_URL directly with the blog path. Or alternatively to export a ELASTIC_WEBSITE_BLOG_URL to be used with a corresponding path. But no strong feelings on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far I haven't found a lot of blog links, so I think this announcement was exceptional. If more of them get added in the future, I agree that we should consider having a different base url that all of them can share (though I'd still vote for having keywords in the shared file rather than having the blog URLs sprinkled across the code.. we don't test those so it's easy to lose track of them).

monitorElasticsearch: `${ELASTICSEARCH_DOCS}configuring-metricbeat.html`,
monitorKibana: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/monitoring-metricbeat.html`,
monitorLogstash: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}/monitoring-with-metricbeat.html`,
troubleshootKibana: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/monitor-troubleshooting.html`,
},
security: {
apiKeyServiceSettings: `${ELASTICSEARCH_DOCS}security-settings.html#api-key-service-settings`,
Expand Down Expand Up @@ -256,6 +264,7 @@ export interface DocLinksStart {
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly elasticsearchModule: string;
readonly startup: string;
readonly exportedFields: string;
};
Expand All @@ -264,6 +273,10 @@ export interface DocLinksStart {
};
readonly metricbeat: {
readonly base: string;
readonly configure: string;
readonly httpEndpoint: string;
readonly install: string;
readonly start: string;
};
readonly enterpriseSearch: {
readonly base: string;
Expand Down
5 changes: 5 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ export interface DocLinksStart {
readonly installation: string;
readonly configuration: string;
readonly elasticsearchOutput: string;
readonly elasticsearchModule: string;
readonly startup: string;
readonly exportedFields: string;
};
Expand All @@ -482,6 +483,10 @@ export interface DocLinksStart {
};
readonly metricbeat: {
readonly base: string;
readonly configure: string;
readonly httpEndpoint: string;
readonly install: string;
readonly start: string;
};
readonly enterpriseSearch: {
readonly base: string;
Expand Down
16 changes: 4 additions & 12 deletions x-pack/plugins/monitoring/public/alerts/lib/alerts_toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface EnableAlertResponse {
}

const showTlsAndEncryptionError = () => {
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = Legacy.shims.docLinks;
const settingsUrl = Legacy.shims.docLinks.links.alerting.generalSettings;

Legacy.shims.toastNotifications.addWarning({
title: toMountPoint(
Expand All @@ -35,11 +35,7 @@ const showTlsAndEncryptionError = () => {
})}
</p>
<EuiSpacer size="xs" />
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-action-settings-kb.html#general-alert-action-settings`}
external
target="_blank"
>
<EuiLink href={settingsUrl} external target="_blank">
{i18n.translate('xpack.monitoring.healthCheck.encryptionErrorAction', {
defaultMessage: 'Learn how.',
})}
Expand All @@ -50,7 +46,7 @@ const showTlsAndEncryptionError = () => {
};

const showUnableToDisableWatcherClusterAlertsError = () => {
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = Legacy.shims.docLinks;
const settingsUrl = Legacy.shims.docLinks.links.alerting.generalSettings;

Legacy.shims.toastNotifications.addWarning({
title: toMountPoint(
Expand All @@ -67,11 +63,7 @@ const showUnableToDisableWatcherClusterAlertsError = () => {
})}
</p>
<EuiSpacer size="xs" />
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-action-settings-kb.html#general-alert-action-settings`}
external
target="_blank"
>
<EuiLink href={settingsUrl} external target="_blank">
{i18n.translate('xpack.monitoring.healthCheck.unableToDisableWatches.action', {
defaultMessage: 'Learn more.',
})}
Expand Down

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

44 changes: 11 additions & 33 deletions x-pack/plugins/monitoring/public/components/logs/reason.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { Legacy } from '../../legacy_shims';
import { Monospace } from '../metricbeat_migration/instruction_steps/components/monospace/monospace';

export const Reason = ({ reason }) => {
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = Legacy.shims.docLinks;
const filebeatUrl = Legacy.shims.docLinks.links.filebeat.installation;
const elasticsearchUrl = Legacy.shims.docLinks.links.filebeat.elasticsearchModule;
const troubleshootUrl = Legacy.shims.docLinks.links.monitoring.troubleshootKibana;
let title = i18n.translate('xpack.monitoring.logs.reason.defaultTitle', {
defaultMessage: 'No log data found',
});
Expand All @@ -22,10 +24,7 @@ export const Reason = ({ reason }) => {
defaultMessage="We did not find any log data and we are unable to diagnose why. {link}"
values={{
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation-configuration.html`}
>
<EuiLink target="_blank" href={filebeatUrl}>
<FormattedMessage
id="xpack.monitoring.logs.reason.defaultMessageLink"
defaultMessage="Please verify your setup is correct."
Expand All @@ -46,10 +45,7 @@ export const Reason = ({ reason }) => {
defaultMessage="Set up {link}, then configure your Elasticsearch output to your monitoring cluster."
values={{
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-installation-configuration.html`}
>
<EuiLink target="_blank" href={filebeatUrl}>
{i18n.translate('xpack.monitoring.logs.reason.noIndexPatternLink', {
defaultMessage: 'Filebeat',
})}
Expand Down Expand Up @@ -81,10 +77,7 @@ export const Reason = ({ reason }) => {
defaultMessage="Follow {link} to set up Elasticsearch."
values={{
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}
>
<EuiLink target="_blank" href={elasticsearchUrl}>
{i18n.translate('xpack.monitoring.logs.reason.noTypeLink', {
defaultMessage: 'these directions',
})}
Expand All @@ -104,10 +97,7 @@ export const Reason = ({ reason }) => {
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`}
>
<EuiLink target="_blank" href={elasticsearchUrl}>
{i18n.translate('xpack.monitoring.logs.reason.notUsingStructuredLogsLink', {
defaultMessage: 'points to JSON logs',
})}
Expand All @@ -126,10 +116,7 @@ export const Reason = ({ reason }) => {
defaultMessage="Check that your {link} is correct."
values={{
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}
>
<EuiLink target="_blank" href={elasticsearchUrl}>
{i18n.translate('xpack.monitoring.logs.reason.noClusterLink', {
defaultMessage: 'setup',
})}
Expand All @@ -148,10 +135,7 @@ export const Reason = ({ reason }) => {
defaultMessage="Check that your {link} is correct."
values={{
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}
>
<EuiLink target="_blank" href={elasticsearchUrl}>
{i18n.translate('xpack.monitoring.logs.reason.noNodeLink', {
defaultMessage: 'setup',
})}
Expand All @@ -170,10 +154,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: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/beats/filebeat/${DOC_LINK_VERSION}/filebeat-module-elasticsearch.html`}
>
<EuiLink target="_blank" href={elasticsearchUrl}>
{i18n.translate('xpack.monitoring.logs.reason.noIndexLink', {
defaultMessage: 'setup',
})}
Expand All @@ -192,10 +173,7 @@ export const Reason = ({ reason }) => {
defaultMessage="There is an issue reading from your filebeat indices. {link}."
values={{
link: (
<EuiLink
target="_blank"
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/monitor-troubleshooting.html`}
>
<EuiLink target="_blank" href={troubleshootUrl}>
{i18n.translate('xpack.monitoring.logs.reason.correctIndexNameLink', {
defaultMessage: 'Click here for more information',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ jest.mock('../../legacy_shims', () => ({
docLinks: {
ELASTIC_WEBSITE_URL: 'https://www.elastic.co/',
DOC_LINK_VERSION: 'current',
links: {
filebeat: {
elasticsearchModule: 'jest-metadata-mock-url',
installation: 'jest-metadata-mock-url',
},
monitoring: {
troubleshootKibana: 'jest-metadata-mock-url',
},
},
},
},
},
Expand Down
Loading