-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Remove dependency on infra in monitoring plugin #203551
Changes from all commits
9667162
33b2454
b6de1ee
2705a6f
d8292b7
6f4d06b
fd270cb
714bd91
4f8b7db
0d64665
eb5d104
5a902a1
4cb26b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,7 @@ const clusterColumns = [ | |
}, | ||
]; | ||
|
||
function getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices) { | ||
function getDiscoverLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices) { | ||
const params = []; | ||
if (clusterUuid) { | ||
params.push(`elasticsearch.cluster.uuid:${clusterUuid}`); | ||
|
@@ -126,6 +126,10 @@ function getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices) | |
const filter = params.join(' and '); | ||
const discoverLocator = sharePlugin.url.locators.get('DISCOVER_APP_LOCATOR'); | ||
|
||
if (!discoverLocator) { | ||
return; | ||
} | ||
|
||
const base = discoverLocator.getRedirectUrl({ | ||
dataViewSpec: { | ||
id: logsIndices, | ||
|
@@ -175,7 +179,7 @@ export class LogsContent extends PureComponent { | |
} | ||
|
||
renderCallout() { | ||
const { capabilities: uiCapabilities, infra, kibanaServices } = Legacy.shims; | ||
const { capabilities: uiCapabilities, kibanaServices } = Legacy.shims; | ||
const show = uiCapabilities.discover && uiCapabilities.discover.show; | ||
|
||
const { | ||
|
@@ -190,8 +194,9 @@ export class LogsContent extends PureComponent { | |
if (!enabled || !show) { | ||
return null; | ||
} | ||
const discoverLink = getDiscoverLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices); | ||
|
||
return infra ? ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ Rendering the callout was guarded by whether So it's now guarded by whether we can successfully generate a discover link or not. |
||
return discoverLink ? ( | ||
<EuiCallOut | ||
size="m" | ||
title={i18n.translate('xpack.monitoring.logs.listing.calloutTitle', { | ||
|
@@ -205,9 +210,7 @@ export class LogsContent extends PureComponent { | |
defaultMessage="Visit {link} to dive deeper." | ||
values={{ | ||
link: ( | ||
<EuiLink | ||
href={getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices)} | ||
> | ||
<EuiLink href={discoverLink}> | ||
{i18n.translate('xpack.monitoring.logs.listing.calloutLinkText', { | ||
defaultMessage: 'Discover', | ||
})} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ export function enableAlertsRoute(server: MonitoringCore, npRoute: RouteDependen | |
async (context, request, response) => { | ||
try { | ||
const alertingContext = await context.alerting; | ||
const infraContext = await context.infra; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ This is the only place the infra plugin was used on the server side - it filled in the space it in some server info logs about rule creation. Theoretically it would be possible to add the spaces plugin as dependency to get the same information, but it doesn't seem worth it doing so as this is strictly about info logging. So I just removed the space id from the log line |
||
const actionContext = await context.actions; | ||
|
||
const alerts = RulesFactory.getAll(); | ||
|
@@ -39,7 +38,7 @@ export function enableAlertsRoute(server: MonitoringCore, npRoute: RouteDependen | |
|
||
if (!isSufficientlySecure || !hasPermanentEncryptionKey) { | ||
server.log.info( | ||
`Skipping rule creation for "${infraContext.spaceId}" space; Stack Monitoring rules require API keys to be enabled and an encryption key to be configured.` | ||
`Skipping rule creation; Stack Monitoring rules require API keys to be enabled and an encryption key to be configured.` | ||
); | ||
return response.ok({ | ||
body: { | ||
|
@@ -90,9 +89,7 @@ export function enableAlertsRoute(server: MonitoringCore, npRoute: RouteDependen | |
alerts.map((alert) => alert.createIfDoesNotExist(rulesClient, actionsClient, actions)) | ||
); | ||
|
||
server.log.info( | ||
`Created ${createdAlerts.length} alerts for "${infraContext.spaceId}" space` | ||
); | ||
server.log.info(`Created ${createdAlerts.length} alerts`); | ||
|
||
return response.ok({ body: { createdAlerts } }); | ||
} catch (err) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ If for some reason the discover locator is not available,
sharePlugin.url.locators.get
will return undefined - this is catching this case.