forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding fleet information on APM tutorial
- Loading branch information
1 parent
3f484a7
commit 07f91b5
Showing
12 changed files
with
242 additions
and
93 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
src/plugins/home/public/application/components/apm_fleet/index.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,101 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import { | ||
EuiButton, | ||
EuiCard, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiLoadingSpinner, | ||
EuiPanel, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React, { useEffect, useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { getServices } from '../../kibana_services'; | ||
|
||
const CentralizedContainer = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
interface APIResponse { | ||
hasData: boolean; | ||
} | ||
|
||
export function APMFleet() { | ||
const { getBasePath } = getServices(); | ||
const basePath = getBasePath(); | ||
const [data, setData] = useState<APIResponse | undefined>(); | ||
const [isLoading, setIsLoading] = useState(false); | ||
|
||
useEffect(() => { | ||
async function fetchData() { | ||
setIsLoading(true); | ||
try { | ||
const response = await fetch(`${basePath}/api/apm/fleet/hasData`); | ||
setData((await response.json()) as APIResponse); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error('Error while fetching fleet details.', e); | ||
} | ||
setIsLoading(false); | ||
} | ||
fetchData(); | ||
}, [basePath]); | ||
|
||
if (isLoading) { | ||
return ( | ||
<CentralizedContainer> | ||
<EuiLoadingSpinner /> | ||
</CentralizedContainer> | ||
); | ||
} | ||
// When APM integration is enable in Fleet | ||
if (data?.hasData) { | ||
return ( | ||
<EuiButton iconType="gear" fill href={`${basePath}/app/fleet#/policies`}> | ||
{i18n.translate('xpack.apm.tutorial.apmServer.fleet.manageApmIntegration.button', { | ||
defaultMessage: 'Manage APM integration in Fleet', | ||
})} | ||
</EuiButton> | ||
); | ||
} | ||
// When APM integration is not installed in Fleet or for some reason the API didn't work out | ||
return ( | ||
<EuiPanel> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={7}> | ||
<EuiCard | ||
display="plain" | ||
textAlign="left" | ||
title={i18n.translate('xpack.apm.tutorial.apmServer.fleet.title', { | ||
defaultMessage: 'Elastic APM (beta) now available in Fleet!', | ||
})} | ||
description={i18n.translate('xpack.apm.tutorial.apmServer.fleet.message', { | ||
defaultMessage: | ||
'The APM integration installs Elasticsearch templates and Ingest Node pipelines for APM data.', | ||
})} | ||
footer={ | ||
<EuiButton | ||
iconType="analyzeEvent" | ||
color="secondary" | ||
href={`${basePath}/app/fleet#/integrations/detail/apm-0.2.0/overview`} | ||
> | ||
{i18n.translate('xpack.apm.tutorial.apmServer.fleet.apmIntegration.button', { | ||
defaultMessage: 'APM integration', | ||
})} | ||
</EuiButton> | ||
} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={3} style={{ background: 'red' }} /> | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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 { createApmServerRoute } from './create_apm_server_route'; | ||
import { createApmServerRouteRepository } from './create_apm_server_route_repository'; | ||
|
||
const hasFleetDataRoute = createApmServerRoute({ | ||
endpoint: 'GET /api/apm/fleet/hasData', | ||
options: { tags: [] }, | ||
handler: async (resources) => { | ||
const { core } = resources.context; | ||
const savedObjectsClient = core.savedObjects.client; | ||
const fleetPluginStart = await resources.plugins.fleet.start(); | ||
|
||
const packagePolicies = await fleetPluginStart.packagePolicyService.list( | ||
savedObjectsClient, | ||
{ kuery: 'ingest-package-policies.package.name:apm' } | ||
); | ||
return { hasData: packagePolicies.total > 0 }; | ||
}, | ||
}); | ||
|
||
export const ApmFleetRouteRepository = createApmServerRouteRepository().add( | ||
hasFleetDataRoute | ||
); |
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
Oops, something went wrong.