Skip to content
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

Reporting/diagnostics #74314

Merged
merged 41 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
643d3cd
WIP: Adding in new reporting diag tool
Jul 7, 2020
6ee796a
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
Jul 13, 2020
ae1a3e6
WIP: chrome-binary test + log capturing/error handling
Jul 14, 2020
8bcd274
More wip on diagnostic tool
Jul 27, 2020
b10c351
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
Aug 3, 2020
61fe997
More work adding in diagnose routes
Aug 4, 2020
77ad9c5
Alter link in description + minor rename of chrome => browser
Aug 4, 2020
0d434aa
Wiring UI to API + some polish on UI flow
Aug 5, 2020
0e661c8
WIP: Add in screenshot diag route
Aug 10, 2020
a395b42
Merge branch 'master' into reporting/diagnostics
Aug 11, 2020
b3131c9
Adding in screenshot diag route, hooking up client to it
Aug 17, 2020
5bd3f2f
Merge branch 'master' into reporting/diagnostics
Aug 20, 2020
7f6ac93
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
Aug 21, 2020
6a03654
Add missing lib check + memory check
Aug 21, 2020
09b9e00
Working screenshot test + config check for RAM
Aug 21, 2020
f0ead22
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
joelgriffith Aug 24, 2020
c5aab98
Small test helper consolidation + screenshot diag test
joelgriffith Aug 24, 2020
0cddac1
Delete old i18n translations
joelgriffith Aug 24, 2020
21638ec
PR feedback, browser tests, rename, re-organize import statements and…
joelgriffith Aug 25, 2020
b67ce10
Lite rename for consistency
Aug 31, 2020
9a303eb
Remove old validate check i18n
Aug 31, 2020
5ab2442
Add config check
Aug 31, 2020
4e092ba
i18n all the things!
Sep 1, 2020
451a679
Docs on diagnostics tool
Sep 1, 2020
c1db6e9
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
Sep 1, 2020
f9b81f3
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
Sep 2, 2020
14e0712
Fixes, better readability, spelling and more for diagnostic tool
Sep 2, 2020
b72349e
Translate a few error messages
Sep 2, 2020
9ba6761
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
Sep 3, 2020
8bc5b26
Rename of test => start_logs for clarity. Move to observables
Sep 4, 2020
0b8dec0
Merge branch 'master' into reporting/diagnostics
Sep 4, 2020
5cce4f8
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
Sep 4, 2020
032442d
Merge branch 'master' into reporting/diagnostics
elasticmachine Sep 8, 2020
9200c04
Gathering logs even during process exit or crash
Sep 8, 2020
04c9276
Adds a test case for the browser exiting during the diag check
Sep 8, 2020
c4eecf8
Tap into browser logs for checking output
Sep 9, 2020
2c54609
Merge remote-tracking branch 'upstream/master' into reporting/diagnos…
Sep 9, 2020
1c86e84
Rename asciidoc diag id
Sep 9, 2020
27ab7c4
Remove duplicate shared object message
Sep 9, 2020
902a72b
Add better comment as to why we merge events + wait for a period of time
Sep 9, 2020
fefcfa8
Cloning logger for mirroring browser stderr to kibana output
Sep 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/plugins/reporting/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const API_BASE_URL_V1 = '/api/reporting/v1'; //
export const API_BASE_GENERATE_V1 = `${API_BASE_URL_V1}/generate`;
export const API_LIST_URL = '/api/reporting/jobs';
export const API_GENERATE_IMMEDIATE = `${API_BASE_URL_V1}/generate/immediate/csv/saved-object`;
export const API_DIAGNOSE_URL = `${API_BASE_URL}/diagnose`;

export const CONTENT_TYPE_CSV = 'text/csv';
export const CSV_REPORTING_ACTION = 'downloadCsvReport';
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/reporting/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ export const USES_HEADLESS_JOB_TYPES = [PDF_JOB_TYPE, PNG_JOB_TYPE];

// Actions
export const CSV_REPORTING_ACTION = 'downloadCsvReport';

// Diagnostic links/help for common reporting issues
export const BROWSER_TEST_COMMON_ISSUES: Map<string, string> = new Map();

BROWSER_TEST_COMMON_ISSUES.set(
'Could not find the default font',
`Chrome couldn't find a default font, please see https://www.elastic.co/guide/en/kibana/current/reporting-troubleshooting.html#reporting-troubleshooting-system-dependencies to fix this issue.`
joelgriffith marked this conversation as resolved.
Show resolved Hide resolved
);
195 changes: 195 additions & 0 deletions x-pack/plugins/reporting/public/components/report_helper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
/*
* 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 React, { useState, Fragment } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiButton,
EuiButtonEmpty,
EuiCallOut,
EuiFlyout,
EuiFlyoutBody,
EuiFlyoutHeader,
EuiSpacer,
EuiSteps,
EuiText,
EuiTitle,
} from '@elastic/eui';
import { ReportingAPIClient } from '../lib/reporting_api_client';

interface Props {
apiClient: ReportingAPIClient;
}

type status = 'danger' | 'incomplete' | 'complete';

interface State {
isFlyoutVisible: boolean;
configStatus: status;
chromeStatus: status;
screenshotStatus: status;
error: string;
isBusy: boolean;
}

const diceRoll = () => {
return Math.floor(Math.random() * Math.floor(10)) <= 7;
};

const initialState: State = {
isFlyoutVisible: false,
configStatus: 'incomplete',
chromeStatus: 'incomplete',
screenshotStatus: 'incomplete',
error: '',
isBusy: false,
};

export const ReportHelper = ({ apiClient }: Props) => {
const [state, setStateBase] = useState(initialState);
const { configStatus, isBusy, screenshotStatus, chromeStatus, error, isFlyoutVisible } = state;
const setState = (s: Partial<typeof state>) =>
setStateBase({
...state,
...s,
});

const closeFlyout = () => setState({ ...initialState, isFlyoutVisible: false });
const showFlyout = () => setState({ isFlyoutVisible: true });
const sleepRun = (fn: any) => () => {
setState({ isBusy: true });
setTimeout(() => {
const isGood = diceRoll();
setState({ isBusy: false });

if (isGood) {
setState({ error: '' });
return fn();
}
setState({ error: 'Unable to load configuration properly for user...' });
}, 1500);
};

const steps = [
{
title: 'Verify Kibana Configuration',
children: (
<Fragment>
<p>This ensure your Kibana configuration is setup properly for reports</p>
<EuiSpacer />
<EuiButton
disabled={isBusy || configStatus === 'complete'}
isLoading={isBusy && configStatus === 'incomplete'}
onClick={sleepRun(() => setState({ configStatus: 'complete' }))}
iconType={configStatus === 'complete' ? 'check' : undefined}
>
Verify Configuration
</EuiButton>
</Fragment>
),
status: error && configStatus !== 'complete' ? 'danger' : configStatus,
},
];

if (configStatus === 'complete') {
steps.push({
title: 'Check Chromium',
children: (
<Fragment>
<p>This validates that the chromium binary can run properly</p>
<EuiSpacer />
<EuiButton
disabled={isBusy || chromeStatus === 'complete'}
onClick={sleepRun(() => setState({ chromeStatus: 'complete' }))}
isLoading={isBusy && chromeStatus === 'incomplete'}
iconType={chromeStatus === 'complete' ? 'check' : undefined}
>
Check Chromium
</EuiButton>
</Fragment>
),
status: error && chromeStatus !== 'complete' ? 'danger' : chromeStatus,
});
}

if (chromeStatus === 'complete') {
steps.push({
title: 'Check Screen Capture Capabilities',
children: (
<Fragment>
<p>The final step checks if we can properly capture Kibana screens.</p>
<EuiSpacer />
<EuiButton
disabled={isBusy || screenshotStatus === 'complete'}
onClick={sleepRun(() => setState({ screenshotStatus: 'complete' }))}
isLoading={isBusy && screenshotStatus === 'incomplete'}
iconType={screenshotStatus === 'complete' ? 'check' : undefined}
>
Capture Screen
</EuiButton>
</Fragment>
),
status: error && screenshotStatus !== 'complete' ? 'danger' : screenshotStatus,
});
}

if (screenshotStatus === 'complete') {
steps.push({
title: 'All set!',
children: (
<Fragment>
<p>Excellent! Everything looks like shipshape for reporting to function!</p>
</Fragment>
),
status: error ? 'danger' : screenshotStatus,
});
}

if (error) {
steps.push({
title: "Whoops! Looks like something isn't working properly.",
children: (
<EuiCallOut color="danger" iconType="alert">
<p>{error}</p>
</EuiCallOut>
),
status: 'danger',
});
}

let flyout;
if (isFlyoutVisible) {
flyout = (
<EuiFlyout onClose={closeFlyout} aria-labelledby="reportingHelperTitle" size="m">
<EuiFlyoutHeader hasBorder>
<EuiTitle size="m">
<h2>Report Helper</h2>
joelgriffith marked this conversation as resolved.
Show resolved Hide resolved
</EuiTitle>
<EuiSpacer size="s" />
<EuiText color="subdued">
<p>
Automatically run a series of diagnostics to troubleshoot common reporting problems.
</p>
</EuiText>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiSteps steps={steps} />
</EuiFlyoutBody>
</EuiFlyout>
);
}
return (
<div>
{flyout}
<EuiButtonEmpty size="xs" flush="left" onClick={showFlyout}>
<FormattedMessage
id="xpack.reporting.listing.helpButtonText"
defaultMessage="Check Reporting"
/>
</EuiButtonEmpty>
</div>
);
};
37 changes: 24 additions & 13 deletions x-pack/plugins/reporting/public/components/report_listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import {
EuiBasicTable,
EuiFlexItem,
EuiFlexGroup,
EuiPageContent,
EuiSpacer,
EuiText,
Expand All @@ -31,6 +33,7 @@ import {
ReportErrorButton,
ReportInfoButton,
} from './buttons';
import { ReportHelper } from './report_helper';

export interface Job {
id: string;
Expand Down Expand Up @@ -135,19 +138,27 @@ class ReportListingUi extends Component<Props, State> {
public render() {
return (
<EuiPageContent horizontalPosition="center" className="euiPageBody--restrictWidth-default">
<EuiTitle>
<h1>
<FormattedMessage id="xpack.reporting.listing.reportstitle" defaultMessage="Reports" />
</h1>
</EuiTitle>
<EuiText color="subdued" size="s">
<p>
<FormattedMessage
id="xpack.reporting.listing.reports.subtitle"
defaultMessage="Find reports generated in Kibana applications here"
/>
</p>
</EuiText>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiTitle>
<h1>
<FormattedMessage
id="xpack.reporting.listing.reportstitle"
defaultMessage="Reports"
/>
</h1>
</EuiTitle>
<EuiText color="subdued" size="s">
<p>
<FormattedMessage
id="xpack.reporting.listing.reports.subtitle"
defaultMessage="Find reports generated in Kibana applications here"
/>
<ReportHelper apiClient={this.props.apiClient} />
</p>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
joelgriffith marked this conversation as resolved.
Show resolved Hide resolved
<EuiSpacer />
{this.renderTable()}
</EuiPageContent>
Expand Down
24 changes: 24 additions & 0 deletions x-pack/plugins/reporting/public/lib/reporting_api_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,28 @@ export class ReportingAPIClient {
* provides the raw server basePath to allow it to be stripped out from relativeUrls in job params
*/
public getServerBasePath = () => this.http.basePath.serverBasePath;

/*
* Diagnostic-related API calls
*/
public verifyConfig = () =>
this.http.post(`${API_LIST_URL}/diagnose/config`, {
asSystemRequest: true,
});

/*
* Diagnostic-related API calls
*/
public verifyBrowser = () =>
this.http.post(`${API_LIST_URL}/diagnose/browser`, {
asSystemRequest: true,
});

/*
* Diagnostic-related API calls
*/
public verifyScreenCapture = () =>
this.http.post(`${API_LIST_URL}/diagnose/screen-capture`, {
asSystemRequest: true,
});
}
Loading