-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Add link to ingest pipeline dashboard from Stack Monitoring #149721
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4957c53
Add ingest pipeline tab to Stack Monitoring
joshdover 2f04b87
Remove prerelease flag during install
joshdover e2ba447
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 0c1aa74
Merge remote-tracking branch 'upstream/main' into ip-monitoring-link
joshdover 43aaf15
Merge branch 'main' into ip-monitoring-link
joshdover 09745b2
Re-enable button after failure
joshdover File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
158 changes: 158 additions & 0 deletions
158
x-pack/plugins/monitoring/public/application/pages/elasticsearch/ingest_pipeline_modal.tsx
This file contains hidden or 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,158 @@ | ||
| /* | ||
| * 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, { useState } from 'react'; | ||
| import { toMountPoint } from '@kbn/kibana-react-plugin/public'; | ||
| import type { CoreStart } from '@kbn/core/public'; | ||
| import { FormattedMessage } from '@kbn/i18n-react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { EuiCallOut, EuiConfirmModal, EuiSpacer } from '@elastic/eui'; | ||
| import { DashboardStart } from '@kbn/dashboard-plugin/public'; | ||
| import { FleetStart } from '@kbn/fleet-plugin/public'; | ||
|
|
||
| const INGEST_PIPELINE_DASHBOARD_ID = 'elasticsearch-metrics-ingest-pipelines'; | ||
|
|
||
| /** | ||
| * If the ingest pipeline dashboard is installed, navigate to it. Otherwise, prompt the user to install the package | ||
| * first, then navigate. If user does not have permission to install packages, show a message. | ||
| * @param services | ||
| * @returns | ||
| */ | ||
| export const ingestPipelineTabOnClick = async ( | ||
| services: Partial<CoreStart & { dashboard: DashboardStart; fleet: FleetStart }> | ||
| ) => { | ||
| const dashboard = await services.savedObjects!.client.get( | ||
| 'dashboard', | ||
| INGEST_PIPELINE_DASHBOARD_ID | ||
| ); | ||
| const dashboardFound = !dashboard.error && dashboard.attributes; | ||
|
|
||
| const navigateToDashboard = () => | ||
| services.dashboard!.locator!.navigate({ | ||
| dashboardId: INGEST_PIPELINE_DASHBOARD_ID, | ||
| }); | ||
|
|
||
| if (!dashboardFound) { | ||
| const installPackage = () => services.http!.post('/api/fleet/epm/packages/elasticsearch'); | ||
|
|
||
| const ref = services.overlays!.openModal( | ||
| toMountPoint( | ||
| <IngestPipelineModal | ||
| installPackage={installPackage} | ||
| navigateToDashboard={navigateToDashboard} | ||
| canInstallPackages={!!services.fleet?.authz.integrations.installPackages} | ||
| closeModal={() => ref.close()} | ||
| />, | ||
| { | ||
| theme$: services.theme?.theme$, | ||
| } | ||
| ) | ||
| ); | ||
|
|
||
| return await ref.onClose; | ||
| } else { | ||
| return navigateToDashboard(); | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * Modal to prompt the user to either install the Elasticsearch integration or contact an admin. | ||
| */ | ||
| export const IngestPipelineModal = ({ | ||
| canInstallPackages, | ||
| closeModal, | ||
| installPackage, | ||
| navigateToDashboard, | ||
| }: { | ||
| closeModal: () => void; | ||
| canInstallPackages: boolean; | ||
| installPackage: () => Promise<unknown>; | ||
| navigateToDashboard: () => void; | ||
| }) => { | ||
| const [installing, setInstalling] = useState(false); | ||
| const [error, setError] = useState<string>(); | ||
|
|
||
| if (!canInstallPackages) { | ||
| return ( | ||
| <EuiConfirmModal | ||
| title={i18n.translate( | ||
| 'xpack.monitoring.esNavigation.ingestPipelineModal.noPermissionToInstallPackage.packageRequiredTitle', | ||
| { defaultMessage: 'Elasticsearch integration is required' } | ||
| )} | ||
| confirmButtonText={i18n.translate( | ||
| 'xpack.monitoring.esNavigation.ingestPipelineModal.noPermissionToInstallPackage.confirmButtonText', | ||
| { defaultMessage: 'OK' } | ||
| )} | ||
| onCancel={closeModal} | ||
| onConfirm={closeModal} | ||
| > | ||
| <p> | ||
| <FormattedMessage | ||
| id="xpack.monitoring.esNavigation.ingestPipelineModal.noPermissionToInstallPackage.descriptionText" | ||
| defaultMessage="Viewing Ingest pipeline metrics requires installing the Elasticsearch integration. You must ask your administrator to install it." | ||
| /> | ||
| </p> | ||
| </EuiConfirmModal> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <EuiConfirmModal | ||
| title={i18n.translate( | ||
| 'xpack.monitoring.esNavigation.ingestPipelineModal.installPromptTitle', | ||
| { | ||
| defaultMessage: 'Install Elasticsearch integration?', | ||
| } | ||
| )} | ||
| confirmButtonText={i18n.translate( | ||
| 'xpack.monitoring.esNavigation.ingestPipelineModal.installButtonText', | ||
| { defaultMessage: 'Install' } | ||
| )} | ||
| cancelButtonText={i18n.translate( | ||
| 'xpack.monitoring.esNavigation.ingestPipelineModal.cancelButtonText', | ||
| { defaultMessage: 'Cancel' } | ||
| )} | ||
| confirmButtonDisabled={installing} | ||
| onCancel={closeModal} | ||
| onConfirm={async () => { | ||
| setInstalling(true); | ||
| try { | ||
| await installPackage(); | ||
| closeModal(); | ||
| navigateToDashboard(); | ||
| } catch (e) { | ||
| setError(e.body?.error || e.message); | ||
| setInstalling(false); | ||
| } | ||
| }} | ||
| > | ||
| {error && ( | ||
| <> | ||
| <EuiCallOut | ||
| title={ | ||
| <FormattedMessage | ||
| id="xpack.monitoring.esNavigation.ingestPipelineModal.errorCalloutText" | ||
| defaultMessage="Could not install the package due to an error: {error}" | ||
| values={{ error }} | ||
| /> | ||
| } | ||
| color="danger" | ||
| iconType="alert" | ||
| /> | ||
| <EuiSpacer /> | ||
| </> | ||
| )} | ||
| <p> | ||
| <FormattedMessage | ||
| id="xpack.monitoring.esNavigation.ingestPipelineModal.installPromptDescriptionText" | ||
| defaultMessage="Viewing Ingest pipeline metrics requires installing the Elasticsearch integration. Do you | ||
| want to install it now?" | ||
| /> | ||
| </p> | ||
| </EuiConfirmModal> | ||
| ); | ||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.