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

[Alerting][Docs] Moved alerting links from hard-coded to documentation link service. #92953

Merged
10 changes: 6 additions & 4 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,17 @@ export class DocLinksService {
guide: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/managing-alerts-and-actions.html`,
actionTypes: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/action-types.html`,
emailAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/email-action-type.html`,
emailActionConfig: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/email-action-type.html#configuring-email`,
generalSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-action-settings-kb.html#general-alert-action-settings`,
indexAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/index-action-type.html`,
indexThreshold: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-types.html#alert-type-index-threshold`,
esQuery: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-type-es-query.html`,
indexThreshold: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-type-index-threshold.html#index-action-configuration`,
pagerDutyAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/pagerduty-action-type.html`,
preconfiguredConnectors: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/pre-configured-action-types-and-connectors.html`,
serviceNowAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/servicenow-action-type.html`,
serviceNowAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/servicenow-action-type.html#configuring-servicenow`,
setupPrerequisites: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alerting-getting-started.html#alerting-setup-prerequisites`,
slackAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/slack-action-type.html`,
teamsAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/teams-action-type.html`,
slackAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/slack-action-type.html#configuring-slack`,
teamsAction: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/teams-action-type.html#configuring-teams`,
},
maps: {
guide: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/maps.html`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ describe('EsQueryAlertTypeExpression', () => {
docLinks: {
ELASTIC_WEBSITE_URL: '',
DOC_LINK_VERSION: '',
links: {
query: {
queryDsl: 'query-dsl.html',
},
},
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,7 @@ export const EsQueryAlertTypeExpression: React.FunctionComponent<
isInvalid={errors.esQuery.length > 0}
error={errors.esQuery}
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${docLinks.DOC_LINK_VERSION}/query-dsl.html`}
target="_blank"
>
<EuiLink href={docLinks.links.query.queryDsl} target="_blank">
<FormattedMessage
id="xpack.stackAlerts.esQuery.ui.queryPrompt.help"
defaultMessage="ES Query DSL documentation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export function getAlertType(): AlertTypeModel<EsQueryAlertParams> {
defaultMessage: 'Alert on matches against an ES query.',
}),
iconClass: 'logoElastic',
documentationUrl(docLinks) {
return `${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/alert-types.html#alert-type-es-query`;
},
documentationUrl: (docLinks) => docLinks.links.alerting.esQuery,
alertParamsExpression: lazy(() => import('./expression')),
validate: validateExpression,
defaultActionMessage: i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export function getAlertType(): AlertTypeModel<IndexThresholdAlertParams> {
defaultMessage: 'Alert when an aggregated query meets the threshold.',
}),
iconClass: 'alert',
documentationUrl(docLinks) {
return `${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/alert-types.html#alert-type-index-threshold`;
},
documentationUrl: (docLinks) => docLinks.links.alerting.indexThreshold,
YulNaumenko marked this conversation as resolved.
Show resolved Hide resolved
alertParamsExpression: lazy(() => import('./expression')),
validate: validateExpression,
defaultActionMessage: i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export const EmailActionConnectorFields: React.FunctionComponent<
}
)}
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/email-action-type.html#configuring-email`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.emailActionConfig} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.emailAction.configureAccountsHelpLabel"
defaultMessage="Configure email accounts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ const IndexActionConnectorFields: React.FunctionComponent<
defaultMessage="Use * to broaden your query."
/>
<EuiSpacer size="s" />
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/index-action-type.html`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.indexAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.configureIndexHelpLabel"
defaultMessage="Configuring index connector."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ export const IndexParamsFields = ({
errors={errors.documents as string[]}
onDocumentsChange={onDocumentsChange}
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/index-action-type.html#index-action-configuration`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.indexAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.indexAction.indexDocumentHelpLabel"
defaultMessage="Index document example."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ const PagerDutyActionConnectorFields: React.FunctionComponent<
id="routingKey"
fullWidth
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/pagerduty-action-type.html`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.pagerDutyAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.routingKeyNameHelpLabel"
defaultMessage="Configure a PagerDuty account"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ const ServiceNowConnectorFields: React.FC<
isInvalid={isApiUrlInvalid}
label={i18n.API_URL_LABEL}
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/servicenow-action-type.html#configuring-servicenow`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.serviceNowAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.serviceNowAction.apiUrlHelpLabel"
defaultMessage="Configure a Personal Developer Instance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ const SlackActionFields: React.FunctionComponent<
id="webhookUrl"
fullWidth
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/slack-action-type.html#configuring-slack`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.slackAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.slackAction.webhookUrlHelpLabel"
defaultMessage="Create a Slack Webhook URL"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ const TeamsActionFields: React.FunctionComponent<
id="webhookUrl"
fullWidth
helpText={
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/teams-action-type.html#configuring-teams`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.teamsAction} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.components.builtinActionTypes.teamsAction.webhookUrlHelpLabel"
defaultMessage="Create a Microsoft Teams Webhook URL"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,11 @@ export const HealthCheck: React.FunctionComponent<Props> = ({
};

interface PromptErrorProps {
docLinks: Pick<DocLinksStart, 'ELASTIC_WEBSITE_URL' | 'DOC_LINK_VERSION'>;
docLinks: DocLinksStart;
className?: string;
}

const EncryptionError = ({
// eslint-disable-next-line @typescript-eslint/naming-convention
docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
className,
}: PromptErrorProps) => (
const EncryptionError = ({ docLinks, className }: PromptErrorProps) => (
<EuiEmptyPrompt
iconType="watchesApp"
data-test-subj="actionNeededEmptyPrompt"
Expand Down Expand Up @@ -133,11 +129,7 @@ const EncryptionError = ({
' in your kibana.yml file and ensure the Encrypted Saved Objects plugin is enabled. ',
}
)}
<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={docLinks.links.alerting.generalSettings} external target="_blank">
{i18n.translate(
'xpack.triggersActionsUI.components.healthCheck.encryptionErrorAction',
{
Expand All @@ -151,11 +143,7 @@ const EncryptionError = ({
/>
);

const TlsError = ({
// eslint-disable-next-line @typescript-eslint/naming-convention
docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
className,
}: PromptErrorProps) => (
const TlsError = ({ docLinks, className }: PromptErrorProps) => (
<EuiEmptyPrompt
iconType="watchesApp"
data-test-subj="actionNeededEmptyPrompt"
Expand All @@ -176,11 +164,7 @@ const TlsError = ({
defaultMessage:
'Alerting relies on API keys, which require TLS between Elasticsearch and Kibana. ',
})}
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/configuring-tls.html`}
external
target="_blank"
>
<EuiLink href={docLinks.links.security.kibanaTLS} external target="_blank">
{i18n.translate('xpack.triggersActionsUI.components.healthCheck.tlsErrorAction', {
defaultMessage: 'Learn how to enable TLS.',
})}
Expand All @@ -191,11 +175,7 @@ const TlsError = ({
/>
);

const AlertsError = ({
// eslint-disable-next-line @typescript-eslint/naming-convention
docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
className,
}: PromptErrorProps) => (
const AlertsError = ({ docLinks, className }: PromptErrorProps) => (
<EuiEmptyPrompt
iconType="watchesApp"
data-test-subj="alertsNeededEmptyPrompt"
Expand All @@ -215,11 +195,7 @@ const AlertsError = ({
{i18n.translate('xpack.triggersActionsUI.components.healthCheck.alertsError', {
defaultMessage: 'To create an alert, set alerts and actions plugins enabled. ',
})}
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alert-action-settings-kb.html`}
external
target="_blank"
>
<EuiLink href={docLinks.links.alerting.generalSettings} external target="_blank">
{i18n.translate('xpack.triggersActionsUI.components.healthCheck.alertsErrorAction', {
defaultMessage: 'Learn how to enable Alerts and Actions.',
})}
Expand All @@ -230,11 +206,7 @@ const AlertsError = ({
/>
);

const TlsAndEncryptionError = ({
// eslint-disable-next-line @typescript-eslint/naming-convention
docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
className,
}: PromptErrorProps) => (
const TlsAndEncryptionError = ({ docLinks, className }: PromptErrorProps) => (
<EuiEmptyPrompt
iconType="watchesApp"
data-test-subj="actionNeededEmptyPrompt"
Expand All @@ -255,11 +227,7 @@ const TlsAndEncryptionError = ({
defaultMessage:
'You must enable Transport Layer Security between Kibana and Elasticsearch and configure an encryption key in your kibana.yml file. ',
})}
<EuiLink
href={`${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/alerting-getting-started.html#alerting-setup-prerequisites`}
external
target="_blank"
>
<EuiLink href={docLinks.links.alerting.setupPrerequisites} external target="_blank">
{i18n.translate(
'xpack.triggersActionsUI.components.healthCheck.tlsAndEncryptionErrorAction',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const TriggersActionsUIHome: React.FunctionComponent<RouteComponentProps<
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/managing-alerts-and-actions.html`}
href={docLinks.links.alerting.guide}
target="_blank"
iconType="help"
data-test-subj="documentationLink"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ export const ActionConnectorForm = ({
values={{
actionType: actionTypeName ?? connector.actionTypeId,
docLink: (
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/action-types.html`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.actionTypes} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.sections.actionConnectorForm.actions.actionConfigurationWarningHelpLinkText"
defaultMessage="Learn more."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,7 @@ export const ConnectorEditFlyout = ({
}
)}
</EuiText>
<EuiLink
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/pre-configured-action-types-and-connectors.html`}
target="_blank"
>
<EuiLink href={docLinks.links.alerting.preconfiguredConnectors} target="_blank">
<FormattedMessage
id="xpack.triggersActionsUI.sections.editConnectorForm.preconfiguredHelpLabel"
defaultMessage="Learn more about preconfigured connectors."
Expand Down