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

[APM] Initial diagnostics tool #157500

Merged
merged 44 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bd9b807
[APM] Initial diagnostics tool
sorenlouv May 11, 2023
4ff210d
Small fixes
sorenlouv May 12, 2023
eda4a91
Catch 404 error
sorenlouv May 12, 2023
aed8e60
Copy changes
sorenlouv May 12, 2023
eb81a04
Minor polish
sorenlouv May 15, 2023
ddea99b
refactor to server
sorenlouv May 15, 2023
7cb41df
Fix tests
sorenlouv May 15, 2023
f81075b
Replace unit tests with API tests
sorenlouv May 17, 2023
a0f2665
Rename ExpectedIndexTemplateStates to DefaultApmIndexTemplateStates
sorenlouv May 17, 2023
1753479
Fix copy
sorenlouv May 17, 2023
b9f366b
Added test for incorrect mappings
sorenlouv May 18, 2023
8a82388
Improve grep matcher
sorenlouv May 19, 2023
a197698
Fix api test
sorenlouv May 19, 2023
123a79d
Add detection of problematic ingest pipelines
sorenlouv May 25, 2023
bd97c09
Improve warnings
sorenlouv May 25, 2023
c72a725
Export interface
sorenlouv May 25, 2023
97ed6b6
Add api test for ingest pipelines
sorenlouv May 26, 2023
c795109
Split out index patterns
sorenlouv May 26, 2023
d6ecdd7
Minor design tweaks
sorenlouv May 26, 2023
2ec22c0
Add ability to import/export diagnostics report
sorenlouv May 26, 2023
d80b98b
Address feedback
sorenlouv May 26, 2023
4b1ee1d
Add version info to package status
sorenlouv May 26, 2023
d2ec351
Fix lint issues
sorenlouv May 28, 2023
8e63a59
Replace apmEventClient
sorenlouv May 29, 2023
2f1f3e2
Split out in modules
sorenlouv May 29, 2023
698e108
Move logic to client
sorenlouv May 30, 2023
65aff5d
Copy change
sorenlouv May 31, 2023
21d9a03
Add script to run against separate Kibana
sorenlouv Jun 1, 2023
7a65666
Re-enable synthtrace
sorenlouv Jun 1, 2023
a5b445c
Fix yargs
sorenlouv Jun 1, 2023
69a8735
Added cypress test
sorenlouv Jun 1, 2023
1173e15
Fix some bugs
sorenlouv Jun 1, 2023
2265286
Update x-pack/plugins/apm/public/components/app/diagnostics/index.tsx
sorenlouv Jun 2, 2023
ddca201
Simplify layout with `TabStatus` component
sorenlouv Jun 2, 2023
2aa3658
Fix integration tests
sorenlouv Jun 2, 2023
61a8623
Add empty state test
sorenlouv Jun 2, 2023
3088e9e
Fix test
sorenlouv Jun 2, 2023
0809fad
Fix api test
sorenlouv Jun 2, 2023
075134c
Fix tests
sorenlouv Jun 2, 2023
9aa5835
Fix bug with missing indices
sorenlouv Jun 2, 2023
e39984f
Ignore unavailable indices
sorenlouv Jun 5, 2023
101f4aa
Fix e2e tests
sorenlouv Jun 5, 2023
26df392
Improve bundle name
sorenlouv Jun 5, 2023
aad75bb
Fix filename casing
sorenlouv Jun 5, 2023
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
Next Next commit
[APM] Initial diagnostics tool
More stuff
  • Loading branch information
sorenlouv committed Jun 5, 2023
commit bd9b80723f7354883007becb747b435808c594d1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.
*/

export function getDefaultIndexTemplateNames() {
const indexTemplateNames = [
'traces-apm',
'traces-apm.sampled',
'metrics-apm.app',
'metrics-apm.internal',
'logs-apm.error',
'logs-apm.app',
];

const rollupIndexTemplateNames = ['1m', '10m', '60m'].flatMap((interval) => {
return [
'metrics-apm.transaction',
'metrics-apm.service_transaction',
'metrics-apm.service_destination',
'metrics-apm.service_summary',
].map((ds) => `${ds}.${interval}`);
});

return [...indexTemplateNames, ...rollupIndexTemplateNames];
}

export function getIsValidIndexTemplateName(templateName: string) {
const defaultTemplateNames = getDefaultIndexTemplateNames();
return defaultTemplateNames.some((defaultName) =>
templateName.startsWith(defaultName)
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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 { IndicesDataStream } from '@elastic/elasticsearch/lib/api/types';
import {
EuiBadge,
EuiBasicTable,
EuiBasicTableColumn,
EuiCallOut,
} from '@elastic/eui';
import React from 'react';
import { APIReturnType } from '../../../services/rest/create_call_apm_api';
import { getIsValidIndexTemplateName } from '../../../../common/diagnostics/get_default_index_template_names';
import { useFetcher } from '../../../hooks/use_fetcher';

type APIResponseType =
APIReturnType<'GET /internal/apm/diagnostics/data_streams'>;

export function DiagnosticsDataStreams() {
const { data } = useFetcher((callApmApi) => {
return callApmApi(`GET /internal/apm/diagnostics/data_streams`);
}, []);

return (
<>
<NonDataStreamIndicesCallout data={data} />
<DataStreamsTable data={data} />
</>
);
}

function NonDataStreamIndicesCallout({ data }: { data?: APIResponseType }) {
if (!data?.nonDataStreamIndices.length) {
return null;
}

return (
<EuiCallOut title="Non-data stream indices" color="warning" iconType="help">
The following indices are not backed by a data stream:{' '}
{data?.nonDataStreamIndices.join(', ')}
</EuiCallOut>
);
}

function DataStreamsTable({ data }: { data?: APIResponseType }) {
const columns: Array<EuiBasicTableColumn<IndicesDataStream>> = [
{
field: 'name',
name: 'Data stream name',
},
{
field: 'template',
name: 'Template name',
render: (templateName: string) => {
const isValid = getIsValidIndexTemplateName(templateName);
return isValid ? (
<>
<EuiBadge color="green">OK</EuiBadge>&nbsp;{templateName}
</>
) : (
<>
<EuiBadge color="warning">Non-standard template name!</EuiBadge>
&nbsp;
{templateName}
</>
);
},
},
];

return (
<EuiBasicTable
tableCaption="Demo of EuiBasicTable"
items={data?.dataStreams ?? []}
rowHeader="firstName"
columns={columns}
/>
);
}
88 changes: 88 additions & 0 deletions x-pack/plugins/apm/public/components/app/diagnostics/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { Outlet } from '@kbn/typed-react-router-config';
import React from 'react';
import { useApmRouter } from '../../../hooks/use_apm_router';
import { useApmRoutePath } from '../../../hooks/use_apm_route_path';
import { DiagnosticsSummary } from './summary_tab';
import { ApmMainTemplate } from '../../routing/templates/apm_main_template';
import { DiagnosticsIndexTemplates } from './index_templates_tab';
import { DiagnosticsInvalidFieldMappings } from './invalid_field_mappings_tab';
import { DiagnosticsDataStreams } from './data_stream_tab';

export const diagnosticsRoute = {
'/diagnostics': {
element: (
<DiagnosticsTemplate>
<Outlet />
</DiagnosticsTemplate>
),
children: {
'/diagnostics': {
element: <DiagnosticsSummary />,
},
'/diagnostics/index-templates': {
element: <DiagnosticsIndexTemplates />,
},
'/diagnostics/invalid-field-mappings': {
element: <DiagnosticsInvalidFieldMappings />,
},
'/diagnostics/data_streams': {
element: <DiagnosticsDataStreams />,
},
},
},
};

function DiagnosticsTemplate({ children }: { children: React.ReactChild }) {
const routePath = useApmRoutePath();
const router = useApmRouter();
return (
<ApmMainTemplate
pageTitle="Diagnostics"
environmentFilter={false}
showServiceGroupSaveButton={false}
selectedNavButton="serviceGroups"
pageHeader={{
tabs: [
{
href: router.link('/diagnostics'),
label: i18n.translate('xpack.apm.diagnostics.tab.summary', {
defaultMessage: 'Summary',
}),
isSelected: routePath === '/diagnostics',
},
{
href: router.link('/diagnostics/index-templates'),
label: i18n.translate('xpack.apm.diagnostics.tab.index_templates', {
defaultMessage: 'Index templates',
}),
isSelected: routePath === '/diagnostics/index-templates',
},
{
href: router.link('/diagnostics/invalid-field-mappings'),
label: i18n.translate('xpack.apm.diagnostics.tab.field_mappings', {
defaultMessage: 'Invalid field mappings',
}),
isSelected: routePath === '/diagnostics/invalid-field-mappings',
},
{
href: router.link('/diagnostics/data_streams'),
label: i18n.translate('xpack.apm.diagnostics.tab.datastreams', {
defaultMessage: 'Datastreams',
}),
isSelected: routePath === '/diagnostics/data_streams',
},
],
}}
>
{children}
</ApmMainTemplate>
);
}
Loading