-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Reporting/diagnostics #74314
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
joelgriffith
merged 41 commits into
elastic:master
from
joelgriffith:reporting/diagnostics
Sep 9, 2020
Merged
Reporting/diagnostics #74314
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
643d3cd
WIP: Adding in new reporting diag tool
6ee796a
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
ae1a3e6
WIP: chrome-binary test + log capturing/error handling
8bcd274
More wip on diagnostic tool
b10c351
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
61fe997
More work adding in diagnose routes
77ad9c5
Alter link in description + minor rename of chrome => browser
0d434aa
Wiring UI to API + some polish on UI flow
0e661c8
WIP: Add in screenshot diag route
a395b42
Merge branch 'master' into reporting/diagnostics
b3131c9
Adding in screenshot diag route, hooking up client to it
5bd3f2f
Merge branch 'master' into reporting/diagnostics
7f6ac93
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
6a03654
Add missing lib check + memory check
09b9e00
Working screenshot test + config check for RAM
f0ead22
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
joelgriffith c5aab98
Small test helper consolidation + screenshot diag test
joelgriffith 0cddac1
Delete old i18n translations
joelgriffith 21638ec
PR feedback, browser tests, rename, re-organize import statements and…
joelgriffith b67ce10
Lite rename for consistency
9a303eb
Remove old validate check i18n
5ab2442
Add config check
4e092ba
i18n all the things!
451a679
Docs on diagnostics tool
c1db6e9
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
f9b81f3
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
14e0712
Fixes, better readability, spelling and more for diagnostic tool
b72349e
Translate a few error messages
9ba6761
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
8bc5b26
Rename of test => start_logs for clarity. Move to observables
0b8dec0
Merge branch 'master' into reporting/diagnostics
5cce4f8
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
032442d
Merge branch 'master' into reporting/diagnostics
elasticmachine 9200c04
Gathering logs even during process exit or crash
04c9276
Adds a test case for the browser exiting during the diag check
c4eecf8
Tap into browser logs for checking output
2c54609
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
1c86e84
Rename asciidoc diag id
27ab7c4
Remove duplicate shared object message
902a72b
Add better comment as to why we merge events + wait for a period of time
fefcfa8
Cloning logger for mirroring browser stderr to kibana output
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
281 changes: 281 additions & 0 deletions
281
x-pack/plugins/reporting/public/components/report_diagnostic.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,281 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import { i18n } from '@kbn/i18n'; | ||
| import React, { useState, Fragment } from 'react'; | ||
| import { FormattedMessage } from '@kbn/i18n/react'; | ||
| import { | ||
| EuiButton, | ||
| EuiButtonEmpty, | ||
| EuiCallOut, | ||
| EuiCodeBlock, | ||
| EuiFlyout, | ||
| EuiFlyoutBody, | ||
| EuiFlyoutHeader, | ||
| EuiSpacer, | ||
| EuiSteps, | ||
| EuiText, | ||
| EuiTitle, | ||
| } from '@elastic/eui'; | ||
| import { ReportingAPIClient, DiagnoseResponse } from '../lib/reporting_api_client'; | ||
|
|
||
| interface Props { | ||
| apiClient: ReportingAPIClient; | ||
| } | ||
|
|
||
| type ResultStatus = 'danger' | 'incomplete' | 'complete'; | ||
|
|
||
| enum statuses { | ||
| configStatus = 'configStatus', | ||
| chromeStatus = 'chromeStatus', | ||
| screenshotStatus = 'screenshotStatus', | ||
| } | ||
|
|
||
| interface State { | ||
| isFlyoutVisible: boolean; | ||
| configStatus: ResultStatus; | ||
| chromeStatus: ResultStatus; | ||
| screenshotStatus: ResultStatus; | ||
| help: string[]; | ||
| logs: string; | ||
| isBusy: boolean; | ||
| success: boolean; | ||
| } | ||
|
|
||
| const initialState: State = { | ||
| [statuses.configStatus]: 'incomplete', | ||
| [statuses.chromeStatus]: 'incomplete', | ||
| [statuses.screenshotStatus]: 'incomplete', | ||
| isFlyoutVisible: false, | ||
| help: [], | ||
| logs: '', | ||
| isBusy: false, | ||
| success: true, | ||
| }; | ||
|
|
||
| export const ReportDiagnostic = ({ apiClient }: Props) => { | ||
| const [state, setStateBase] = useState(initialState); | ||
| const setState = (s: Partial<typeof state>) => | ||
| setStateBase({ | ||
| ...state, | ||
| ...s, | ||
| }); | ||
| const { | ||
| configStatus, | ||
| isBusy, | ||
| screenshotStatus, | ||
| chromeStatus, | ||
| isFlyoutVisible, | ||
| help, | ||
| logs, | ||
| success, | ||
| } = state; | ||
|
|
||
| const closeFlyout = () => setState({ ...initialState, isFlyoutVisible: false }); | ||
| const showFlyout = () => setState({ isFlyoutVisible: true }); | ||
| const apiWrapper = (apiMethod: () => Promise<DiagnoseResponse>, statusProp: statuses) => () => { | ||
| setState({ isBusy: true, [statusProp]: 'incomplete' }); | ||
| apiMethod() | ||
| .then((response) => { | ||
| setState({ | ||
| isBusy: false, | ||
| help: response.help, | ||
| logs: response.logs, | ||
| success: response.success, | ||
| [statusProp]: response.success ? 'complete' : 'danger', | ||
| }); | ||
| }) | ||
| .catch((error) => { | ||
| setState({ | ||
| isBusy: false, | ||
| help: [ | ||
| i18n.translate('xpack.reporting.listing.diagnosticApiCallFailure', { | ||
| defaultMessage: `There was a problem running the diagnostic: {error}`, | ||
| values: { error }, | ||
| }), | ||
| ], | ||
| logs: `${error.message}`, | ||
| success: false, | ||
| [statusProp]: 'danger', | ||
| }); | ||
| }); | ||
| }; | ||
|
|
||
| const steps = [ | ||
| { | ||
| title: i18n.translate('xpack.reporting.listing.diagnosticConfigTitle', { | ||
| defaultMessage: 'Verify Kibana Configuration', | ||
| }), | ||
| children: ( | ||
| <Fragment> | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticConfigMessage" | ||
| defaultMessage="This check ensures your Kibana configuration is setup properly for reports." | ||
| /> | ||
| <EuiSpacer /> | ||
| <EuiButton | ||
| disabled={isBusy || configStatus === 'complete'} | ||
| isLoading={isBusy && configStatus === 'incomplete'} | ||
| onClick={apiWrapper(apiClient.verifyConfig, statuses.configStatus)} | ||
| iconType={configStatus === 'complete' ? 'check' : undefined} | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticConfigButton" | ||
| defaultMessage="Verify Configuration" | ||
| /> | ||
| </EuiButton> | ||
| </Fragment> | ||
| ), | ||
| status: !success && configStatus !== 'complete' ? 'danger' : configStatus, | ||
| }, | ||
| ]; | ||
|
|
||
| if (configStatus === 'complete') { | ||
| steps.push({ | ||
| title: i18n.translate('xpack.reporting.listing.diagnosticBrowserTitle', { | ||
| defaultMessage: 'Check Browser', | ||
| }), | ||
| children: ( | ||
| <Fragment> | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticBrowserMessage" | ||
| defaultMessage="Reporting utilizes a headless browser to generate PDF and PNGS. This check validates | ||
| that the browser can launch successfully." | ||
| /> | ||
| <EuiSpacer /> | ||
| <EuiButton | ||
| disabled={isBusy || chromeStatus === 'complete'} | ||
| onClick={apiWrapper(apiClient.verifyBrowser, statuses.chromeStatus)} | ||
| isLoading={isBusy && chromeStatus === 'incomplete'} | ||
| iconType={chromeStatus === 'complete' ? 'check' : undefined} | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticBrowserButton" | ||
| defaultMessage="Check Browser" | ||
| /> | ||
| </EuiButton> | ||
| </Fragment> | ||
| ), | ||
| status: !success && chromeStatus !== 'complete' ? 'danger' : chromeStatus, | ||
| }); | ||
| } | ||
|
|
||
| if (chromeStatus === 'complete') { | ||
| steps.push({ | ||
| title: i18n.translate('xpack.reporting.listing.diagnosticScreenshotTitle', { | ||
| defaultMessage: 'Check Screen Capture Capabilities', | ||
| }), | ||
| children: ( | ||
| <Fragment> | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticScreenshotMessage" | ||
| defaultMessage="This check ensures the headless browser can capture a screenshot of a page." | ||
| /> | ||
| <EuiSpacer /> | ||
| <EuiButton | ||
| disabled={isBusy || screenshotStatus === 'complete'} | ||
| onClick={apiWrapper(apiClient.verifyScreenCapture, statuses.screenshotStatus)} | ||
| isLoading={isBusy && screenshotStatus === 'incomplete'} | ||
| iconType={screenshotStatus === 'complete' ? 'check' : undefined} | ||
| > | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticScreenshotButton" | ||
| defaultMessage="Capture Screenshot" | ||
| /> | ||
| </EuiButton> | ||
| </Fragment> | ||
| ), | ||
| status: !success && screenshotStatus !== 'complete' ? 'danger' : screenshotStatus, | ||
| }); | ||
| } | ||
|
|
||
| if (screenshotStatus === 'complete') { | ||
| steps.push({ | ||
| title: i18n.translate('xpack.reporting.listing.diagnosticSuccessTitle', { | ||
| defaultMessage: 'All set!', | ||
| }), | ||
| children: ( | ||
| <Fragment> | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticSuccessMessage" | ||
| defaultMessage="Excellent! Everything looks like shipshape for reporting to function!" | ||
| /> | ||
| </Fragment> | ||
| ), | ||
| status: !success ? 'danger' : screenshotStatus, | ||
| }); | ||
| } | ||
|
|
||
| if (!success) { | ||
| steps.push({ | ||
| title: i18n.translate('xpack.reporting.listing.diagnosticFailureTitle', { | ||
| defaultMessage: "Whoops! Looks like something isn't working properly.", | ||
| }), | ||
| children: ( | ||
| <Fragment> | ||
| {help.length ? ( | ||
| <Fragment> | ||
| <EuiCallOut color="danger" iconType="alert"> | ||
| <p>{help.join('\n')}</p> | ||
| </EuiCallOut> | ||
| </Fragment> | ||
| ) : null} | ||
| {logs.length ? ( | ||
| <Fragment> | ||
| <EuiSpacer /> | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticFailureDescription" | ||
| defaultMessage="Here are some more details about the issue:" | ||
| /> | ||
| <EuiSpacer /> | ||
| <EuiCodeBlock>{logs}</EuiCodeBlock> | ||
| </Fragment> | ||
| ) : null} | ||
| </Fragment> | ||
| ), | ||
| status: 'danger', | ||
| }); | ||
| } | ||
|
|
||
| let flyout; | ||
| if (isFlyoutVisible) { | ||
| flyout = ( | ||
| <EuiFlyout onClose={closeFlyout} aria-labelledby="reportingHelperTitle" size="m"> | ||
| <EuiFlyoutHeader hasBorder> | ||
| <EuiTitle size="m"> | ||
| <h2> | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticTitle" | ||
| defaultMessage="Reporting Diagnostics" | ||
| /> | ||
| </h2> | ||
| </EuiTitle> | ||
| <EuiSpacer size="s" /> | ||
| <EuiText color="subdued"> | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticDescription" | ||
| defaultMessage="Automatically run a series of diagnostics to troubleshoot common reporting problems." | ||
| /> | ||
| </EuiText> | ||
| </EuiFlyoutHeader> | ||
| <EuiFlyoutBody> | ||
| <EuiSteps steps={steps} /> | ||
| </EuiFlyoutBody> | ||
| </EuiFlyout> | ||
| ); | ||
| } | ||
| return ( | ||
| <div> | ||
| {flyout} | ||
| <EuiButtonEmpty size="xs" flush="left" onClick={showFlyout}> | ||
| <FormattedMessage | ||
| id="xpack.reporting.listing.diagnosticButton" | ||
| defaultMessage="Run reporting diagnostics..." | ||
| /> | ||
| </EuiButtonEmpty> | ||
| </div> | ||
| ); | ||
| }; |
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
Oops, something went wrong.
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.
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.
Any thoughts or feelings about having the label just be
Reporting diagnosticsinstead of the longer phrase?