-
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
[Infrastructure UI] Hosts view: Add links to apm and uptime for a single host #154269
Changes from 12 commits
470ccf9
9a76488
df1c905
b23fc14
b2fe4cd
63f2fa5
789fb3d
069acdd
2f8017d
856dfa8
0bd97a7
7992002
3cea485
dc8b3ad
81bc888
5e5d444
27074f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,29 @@ | |
*/ | ||
|
||
import React from 'react'; | ||
import { EuiFlyout, EuiFlyoutHeader, EuiTitle, EuiFlyoutBody } from '@elastic/eui'; | ||
import { EuiSpacer, EuiTabs, EuiTab } from '@elastic/eui'; | ||
import { | ||
EuiFlyout, | ||
EuiFlyoutHeader, | ||
EuiTitle, | ||
EuiFlyoutBody, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiLink, | ||
EuiTab, | ||
EuiSpacer, | ||
EuiTabs, | ||
} from '@elastic/eui'; | ||
import { EuiIcon } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { css } from '@emotion/react'; | ||
import { useKibanaContextForPlugin } from '../../../../../hooks/use_kibana'; | ||
import { useUnifiedSearchContext } from '../../hooks/use_unified_search'; | ||
import { navigateToUptime } from './links/navigate_to_uptime'; | ||
import { LinkToApmServices } from './links/link_to_apm_services'; | ||
import { useLazyRef } from '../../../../../hooks/use_lazy_ref'; | ||
import { metadataTab } from './metadata'; | ||
import type { InventoryItemType } from '../../../../../../common/inventory_models/types'; | ||
import type { HostNodeRow } from '../../hooks/use_hosts_table'; | ||
import { useUnifiedSearchContext } from '../../hooks/use_unified_search'; | ||
import { processesTab } from './processes'; | ||
import { Metadata } from './metadata/metadata'; | ||
import { Processes } from './processes/processes'; | ||
|
@@ -28,6 +44,7 @@ const NODE_TYPE = 'host' as InventoryItemType; | |
|
||
export const Flyout = ({ node, closeFlyout }: Props) => { | ||
const { getDateRangeAsTimestamp } = useUnifiedSearchContext(); | ||
const { share } = useKibanaContextForPlugin().services; | ||
|
||
const currentTimeRange = { | ||
...getDateRangeAsTimestamp(), | ||
|
@@ -57,9 +74,33 @@ export const Flyout = ({ node, closeFlyout }: Props) => { | |
return ( | ||
<EuiFlyout onClose={closeFlyout} ownFocus={false}> | ||
<EuiFlyoutHeader hasBorder> | ||
<EuiTitle size="xs"> | ||
<h2>{node.name}</h2> | ||
</EuiTitle> | ||
<EuiFlexGroup justifyContent="spaceBetween"> | ||
<EuiFlexItem> | ||
<EuiTitle size="xs"> | ||
<h2>{node.name}</h2> | ||
</EuiTitle> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<LinkToApmServices hostName={node.name} apmField={'host.hostname'} /> | ||
</EuiFlexItem> | ||
<EuiFlexItem | ||
grow={false} | ||
css={css` | ||
padding-right: 20px; | ||
`} | ||
> | ||
<EuiLink | ||
data-test-subj="infraHostsViewFlyoutUptimeLink" | ||
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. I guess the naming standard for 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. I guess the conventions here mentions its without 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. Yeah. It's probably too late to change those places with dashes since telemetry is already being collected. Unless Roshan hasn't done anything with it yet, then we might be able to standardise it (or change the convention). Or since the feature is not GA, we may have some room to fix where it's not following the convention. 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. Hmm yeah, I saw the telemetry guide that's why I used that naming convention - also mentioned in the processes PR But as this is only used in the hosts view I can change to 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. Renamed here |
||
onClick={() => navigateToUptime(share.url.locators, NODE_TYPE, node)} | ||
> | ||
<EuiIcon type="popout" />{' '} | ||
jennypavlova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<FormattedMessage | ||
id="xpack.infra.hostsViewPage.flyout.uptimeLinkLabel" | ||
defaultMessage="Uptime" | ||
/> | ||
</EuiLink> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiSpacer size="s" /> | ||
<EuiTabs style={{ marginBottom: '-25px' }} size="s"> | ||
{tabEntries} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React from 'react'; | ||
import { stringify } from 'querystring'; | ||
import { encode } from '@kbn/rison'; | ||
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; | ||
import { EuiIcon, EuiLink } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { useKibanaContextForPlugin } from '../../../../../../hooks/use_kibana'; | ||
|
||
interface LinkToApmServicesProps { | ||
hostName: string; | ||
apmField: string; | ||
} | ||
|
||
export const LinkToApmServices = ({ hostName, apmField }: LinkToApmServicesProps) => { | ||
const { services } = useKibanaContextForPlugin(); | ||
const { http } = services; | ||
|
||
const queryString = new URLSearchParams( | ||
encode( | ||
stringify({ | ||
kuery: `${apmField}:"${hostName}"`, | ||
}) | ||
) | ||
); | ||
|
||
const linkToApmServices = http.basePath.prepend(`/app/apm/services?${queryString}`); | ||
|
||
return ( | ||
<RedirectAppLinks coreStart={services}> | ||
<EuiLink href={linkToApmServices} data-test-subj="infraHostsViewFlyoutApmServicesLink"> | ||
<EuiIcon type="popout" />{' '} | ||
jennypavlova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<FormattedMessage | ||
id="xpack.infra.hostsViewPage.flyout.apmServicesLinkLabel" | ||
defaultMessage="APM Services" | ||
/> | ||
</EuiLink> | ||
</RedirectAppLinks> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { uptimeOverviewLocatorID } from '@kbn/observability-plugin/public'; | ||
import { LocatorClient } from '@kbn/share-plugin/common/url_service/locators'; | ||
import type { InventoryItemType } from '../../../../../../../common/inventory_models/types'; | ||
import type { HostNodeRow } from '../../../hooks/use_hosts_table'; | ||
|
||
export const navigateToUptime = ( | ||
locators: LocatorClient, | ||
nodeType: InventoryItemType, | ||
node: HostNodeRow | ||
) => { | ||
return locators.get(uptimeOverviewLocatorID)!.navigate({ [nodeType]: node.name, ip: node.ip }); | ||
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. How about creating a link component here that knows how to redirect to Uptime, similar to the 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. Good idea, thanks! I moved it to a separate component like the APM link 👍 |
||
}; |
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.
Perhaps we could use euiTheme standards instead. wdyt?
euiTheme.size.l
->24px
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.
Yes, looks fine also with 24px, changed 👍