-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Infrastructure UI] Hosts view: Add links to apm and uptime for a sin…
…gle host (#154269) Closes #150985 ## Summary This PR adds links to APM Traces and Uptime. <img width="1909" alt="image" src="https://user-images.githubusercontent.com/14139027/229580612-a3d0c03a-4f68-4b09-b333-ffa79c8454e6.png"> # Testing 1. Open Hosts view 2. Click on the button to open the flyout for a single host - Click on the APM traces link and verify the query parameters are correct - Click on the uptime link and verify the query parameters are correct https://user-images.githubusercontent.com/14139027/229581672-3c50ea55-e834-4431-aac6-3ed3ff9f96cc.mov --------- Co-authored-by: Carlos Crespo <[email protected]>
- Loading branch information
1 parent
b8409c9
commit 8c2ff54
Showing
7 changed files
with
166 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
.../public/pages/metrics/hosts/components/host_details_flyout/links/link_to_apm_services.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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 { css } from '@emotion/react'; | ||
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; | ||
import { EuiIcon, EuiLink, useEuiTheme } 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 { euiTheme } = useEuiTheme(); | ||
|
||
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="hostsView-flyout-apm-services-link"> | ||
<EuiIcon | ||
type="popout" | ||
css={css` | ||
margin-right: ${euiTheme.size.xs}; | ||
`} | ||
/> | ||
<FormattedMessage | ||
id="xpack.infra.hostsViewPage.flyout.apmServicesLinkLabel" | ||
defaultMessage="APM Services" | ||
/> | ||
</EuiLink> | ||
</RedirectAppLinks> | ||
); | ||
}; |
47 changes: 47 additions & 0 deletions
47
.../infra/public/pages/metrics/hosts/components/host_details_flyout/links/link_to_uptime.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 { EuiLink, EuiIcon, useEuiTheme } from '@elastic/eui'; | ||
import { css } from '@emotion/react'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { uptimeOverviewLocatorID } from '@kbn/observability-plugin/public'; | ||
import { useKibanaContextForPlugin } from '../../../../../../hooks/use_kibana'; | ||
import type { InventoryItemType } from '../../../../../../../common/inventory_models/types'; | ||
import type { HostNodeRow } from '../../../hooks/use_hosts_table'; | ||
|
||
interface LinkTUptimeProps { | ||
nodeType: InventoryItemType; | ||
node: HostNodeRow; | ||
} | ||
|
||
export const LinkToUptime = ({ nodeType, node }: LinkTUptimeProps) => { | ||
const { share } = useKibanaContextForPlugin().services; | ||
const { euiTheme } = useEuiTheme(); | ||
|
||
return ( | ||
<EuiLink | ||
data-test-subj="hostsView-flyout-uptime-link" | ||
onClick={() => | ||
share.url.locators | ||
.get(uptimeOverviewLocatorID)! | ||
.navigate({ [nodeType]: node.name, ip: node.ip }) | ||
} | ||
> | ||
<EuiIcon | ||
type="popout" | ||
css={css` | ||
margin-right: ${euiTheme.size.xs}; | ||
`} | ||
/> | ||
<FormattedMessage | ||
id="xpack.infra.hostsViewPage.flyout.uptimeLinkLabel" | ||
defaultMessage="Uptime" | ||
/> | ||
</EuiLink> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters