Skip to content

Commit

Permalink
[Logs / Metrics] New Platform migration (full cutover) (#54583)
Browse files Browse the repository at this point in the history
* Fully migrates metrics and logs to the NP

Co-authored-by: Jason Rhodes <[email protected]>
Co-authored-by: John Schulz <[email protected]>
Co-authored-by: Felix Stürmer <[email protected]>
  • Loading branch information
4 people authored Feb 18, 2020
1 parent 4f27e19 commit 0a6c748
Show file tree
Hide file tree
Showing 858 changed files with 1,946 additions and 1,782 deletions.
2 changes: 2 additions & 0 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
public async navigateToUrlWithBrowserHistory(
appName: string,
subUrl?: string,
search?: string,
{
basePath = '',
ensureCurrentUrl = true,
Expand All @@ -203,6 +204,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
const appConfig = {
// subUrl following the basePath, assumes no hashes. Ex: 'app/endpoint/management'
pathname: `${basePath}${config.get(['apps', appName]).pathname}${subUrl}`,
search,
};

await this.navigate({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"xpack.grokDebugger": "legacy/plugins/grokdebugger",
"xpack.idxMgmt": "legacy/plugins/index_management",
"xpack.indexLifecycleMgmt": "legacy/plugins/index_lifecycle_management",
"xpack.infra": "legacy/plugins/infra",
"xpack.infra": "plugins/infra",
"xpack.data": "plugins/data_enhanced",
"xpack.lens": "legacy/plugins/lens",
"xpack.licenseMgmt": "legacy/plugins/license_management",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { DetailView } from './DetailView';
import { ErrorDistribution } from './Distribution';
import { useLocation } from '../../../hooks/useLocation';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { useTrackPageview } from '../../../../../infra/public';
import { useTrackPageview } from '../../../../../../../plugins/observability/public';

const Titles = styled.div`
margin-bottom: ${px(units.plus)};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useFetcher } from '../../../hooks/useFetcher';
import { ErrorDistribution } from '../ErrorGroupDetails/Distribution';
import { ErrorGroupList } from './List';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { useTrackPageview } from '../../../../../infra/public';
import { useTrackPageview } from '../../../../../../../plugins/observability/public';
import { PROJECTION } from '../../../../common/projections/typings';
import { LocalUIFilters } from '../../shared/LocalUIFilters';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useFetcher } from '../../../hooks/useFetcher';
import { NoServicesMessage } from './NoServicesMessage';
import { ServiceList } from './ServiceList';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { useTrackPageview } from '../../../../../infra/public';
import { useTrackPageview } from '../../../../../../../plugins/observability/public';
import { PROJECTION } from '../../../../common/projections/typings';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { useApmPluginContext } from '../../../hooks/useApmPluginContext';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { isRumAgentName } from '../../../../../../common/agent_name';
import { ALL_OPTION_VALUE } from '../../../../../../common/agent_configuration_constants';
import { saveConfig } from './saveConfig';
import { useApmPluginContext } from '../../../../../hooks/useApmPluginContext';
import { useUiTracker } from '../../../../../../../../../plugins/observability/public';

const defaultSettings = {
TRANSACTION_SAMPLE_RATE: '1.0',
Expand All @@ -59,6 +60,9 @@ export function AddEditFlyout({

const callApmApiFromHook = useCallApmApi();

// get a telemetry UI event tracker
const trackApmEvent = useUiTracker({ app: 'apm' });

// config conditions (service)
const [serviceName, setServiceName] = useState<string>(
selectedConfig ? selectedConfig.service.name || ALL_OPTION_VALUE : ''
Expand Down Expand Up @@ -133,7 +137,8 @@ export function AddEditFlyout({
transactionMaxSpans,
configurationId: selectedConfig ? selectedConfig.id : undefined,
agentName,
toasts
toasts,
trackApmEvent
});
setIsSaving(false);
onSaved();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import { i18n } from '@kbn/i18n';
import { NotificationsStart } from 'kibana/public';
import { APMClient } from '../../../../../services/rest/createCallApmApi';
import { trackEvent } from '../../../../../../../infra/public/hooks/use_track_metric';
import { isRumAgentName } from '../../../../../../common/agent_name';
import {
getOptionLabel,
omitAllOption
} from '../../../../../../common/agent_configuration_constants';
import { UiTracker } from '../../../../../../../../../plugins/observability/public';

interface Settings {
transaction_sample_rate: number;
Expand All @@ -29,7 +29,8 @@ export async function saveConfig({
transactionMaxSpans,
configurationId,
agentName,
toasts
toasts,
trackApmEvent
}: {
callApmApi: APMClient;
serviceName: string;
Expand All @@ -40,8 +41,9 @@ export async function saveConfig({
configurationId?: string;
agentName?: string;
toasts: NotificationsStart['toasts'];
trackApmEvent: UiTracker;
}) {
trackEvent({ app: 'apm', name: 'save_agent_configuration' });
trackApmEvent({ metric: 'save_agent_configuration' });

try {
const settings: Settings = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { isEmpty } from 'lodash';
import { useFetcher } from '../../../../hooks/useFetcher';
import { AgentConfigurationListAPIResponse } from '../../../../../server/lib/settings/agent_configuration/list_configurations';
import { AgentConfigurationList } from './AgentConfigurationList';
import { useTrackPageview } from '../../../../../../infra/public';
import { useTrackPageview } from '../../../../../../../../plugins/observability/public';
import { AddEditFlyout } from './AddEditFlyout';

export type Config = AgentConfigurationListAPIResponse[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useMemo } from 'react';
import { FETCH_STATUS, useFetcher } from '../../../hooks/useFetcher';
import { TraceList } from './TraceList';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { useTrackPageview } from '../../../../../infra/public';
import { useTrackPageview } from '../../../../../../../plugins/observability/public';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { PROJECTION } from '../../../../common/projections/typings';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useUrlParams } from '../../../hooks/useUrlParams';
import { FETCH_STATUS } from '../../../hooks/useFetcher';
import { TransactionBreakdown } from '../../shared/TransactionBreakdown';
import { ChartsSyncContextProvider } from '../../../context/ChartsSyncContext';
import { useTrackPageview } from '../../../../../infra/public';
import { useTrackPageview } from '../../../../../../../plugins/observability/public';
import { PROJECTION } from '../../../../common/projections/typings';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { HeightRetainer } from '../../shared/HeightRetainer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { getHasMLJob } from '../../../services/rest/ml';
import { history } from '../../../utils/history';
import { useLocation } from '../../../hooks/useLocation';
import { ChartsSyncContextProvider } from '../../../context/ChartsSyncContext';
import { useTrackPageview } from '../../../../../infra/public';
import { useTrackPageview } from '../../../../../../../plugins/observability/public';
import { fromQuery, toQuery } from '../../shared/Links/url_helpers';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { PROJECTION } from '../../../../common/projections/typings';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import { InfraLink } from './InfraLink';

test('InfraLink produces the correct URL', async () => {
const href = await getRenderedHref(
() => <InfraLink path="/some/path" query={{ time: 1554687198 }} />,
() => (
<InfraLink app="metrics" path="/some/path" query={{ time: 1554687198 }} />
),
{
search: '?rangeFrom=now-5h&rangeTo=now-2h'
} as Location
);

expect(href).toMatchInlineSnapshot(
`"/basepath/app/infra#/some/path?time=1554687198"`
`"/basepath/app/metrics/some/path?time=1554687198"`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/

import { EuiLink, EuiLinkAnchorProps } from '@elastic/eui';
import { compact } from 'lodash';
import React from 'react';
import url from 'url';
import { fromQuery } from './url_helpers';
import { useApmPluginContext } from '../../../hooks/useApmPluginContext';
import { AppMountContextBasePath } from '../../../context/ApmPluginContext';
import { InfraAppId } from '../../../../../../../plugins/infra/public';

interface InfraQueryParams {
time?: number;
Expand All @@ -20,29 +20,32 @@ interface InfraQueryParams {
}

interface Props extends EuiLinkAnchorProps {
app: InfraAppId;
path?: string;
query: InfraQueryParams;
children?: React.ReactNode;
}

export const getInfraHref = ({
app,
basePath,
query,
path
}: {
app: InfraAppId;
basePath: AppMountContextBasePath;
query: InfraQueryParams;
path?: string;
}) => {
const nextSearch = fromQuery(query);
return url.format({
pathname: basePath.prepend('/app/infra'),
hash: compact([path, nextSearch]).join('?')
pathname: basePath.prepend(`/app/${app}${path || ''}`),
search: nextSearch
});
};

export function InfraLink({ path, query = {}, ...rest }: Props) {
export function InfraLink({ app, path, query = {}, ...rest }: Props) {
const { core } = useApmPluginContext();
const href = getInfraHref({ basePath: core.http.basePath, query, path });
const href = getInfraHref({ app, basePath: core.http.basePath, query, path });
return <EuiLink {...rest} href={href} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { AppMountContextBasePath } from '../../../../context/ApmPluginContext';

describe('Transaction action menu', () => {
const basePath = ({
prepend: jest.fn()
prepend: (url: string) => {
return `some-basepath${url}`;
}
} as unknown) as AppMountContextBasePath;
const date = '2020-02-06T11:00:00.000Z';
const timestamp = { us: new Date(date).getTime() };
Expand Down Expand Up @@ -40,7 +42,7 @@ describe('Transaction action menu', () => {
key: 'traceLogs',
label: 'Trace logs',
href:
'#/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123',
'some-basepath/app/logs/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123',
condition: true
}
]
Expand All @@ -54,7 +56,7 @@ describe('Transaction action menu', () => {
key: 'sampleDocument',
label: 'View sample document',
href:
'#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))',
'some-basepath/app/kibana#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))',
condition: true
}
]
Expand Down Expand Up @@ -89,14 +91,15 @@ describe('Transaction action menu', () => {
{
key: 'podLogs',
label: 'Pod logs',
href: '#/link-to/pod-logs/123?time=1580986800',
href:
'some-basepath/app/logs/link-to/pod-logs/123?time=1580986800',
condition: true
},
{
key: 'podMetrics',
label: 'Pod metrics',
href:
'#/link-to/pod-detail/123?from=1580986500000&to=1580987100000',
'some-basepath/app/metrics/link-to/pod-detail/123?from=1580986500000&to=1580987100000',
condition: true
}
]
Expand All @@ -110,7 +113,7 @@ describe('Transaction action menu', () => {
key: 'traceLogs',
label: 'Trace logs',
href:
'#/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123',
'some-basepath/app/logs/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123',
condition: true
}
]
Expand All @@ -124,7 +127,7 @@ describe('Transaction action menu', () => {
key: 'sampleDocument',
label: 'View sample document',
href:
'#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))',
'some-basepath/app/kibana#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))',
condition: true
}
]
Expand Down Expand Up @@ -158,14 +161,15 @@ describe('Transaction action menu', () => {
{
key: 'hostLogs',
label: 'Host logs',
href: '#/link-to/host-logs/foo?time=1580986800',
href:
'some-basepath/app/logs/link-to/host-logs/foo?time=1580986800',
condition: true
},
{
key: 'hostMetrics',
label: 'Host metrics',
href:
'#/link-to/host-detail/foo?from=1580986500000&to=1580987100000',
'some-basepath/app/metrics/link-to/host-detail/foo?from=1580986500000&to=1580987100000',
condition: true
}
]
Expand All @@ -179,7 +183,7 @@ describe('Transaction action menu', () => {
key: 'traceLogs',
label: 'Trace logs',
href:
'#/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123',
'some-basepath/app/logs/link-to/logs?time=1580986800&filter=trace.id:%22123%22%20OR%20123',
condition: true
}
]
Expand All @@ -193,7 +197,7 @@ describe('Transaction action menu', () => {
key: 'sampleDocument',
label: 'View sample document',
href:
'#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))',
'some-basepath/app/kibana#/discover?_g=(refreshInterval:(pause:true,value:\'0\'),time:(from:now-24h,to:now))&_a=(index:apm_static_index_pattern_id,interval:auto,query:(language:kuery,query:\'processor.event:"transaction" AND transaction.id:"123" AND trace.id:"123"\'))',
condition: true
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const getSections = ({
{ defaultMessage: 'Pod logs' }
),
href: getInfraHref({
app: 'logs',
basePath,
path: `/link-to/pod-logs/${podId}`,
query: { time }
Expand All @@ -95,6 +96,7 @@ export const getSections = ({
{ defaultMessage: 'Pod metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/pod-detail/${podId}`,
query: infraMetricsQuery
Expand All @@ -111,6 +113,7 @@ export const getSections = ({
{ defaultMessage: 'Container logs' }
),
href: getInfraHref({
app: 'logs',
basePath,
path: `/link-to/container-logs/${containerId}`,
query: { time }
Expand All @@ -124,6 +127,7 @@ export const getSections = ({
{ defaultMessage: 'Container metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/container-detail/${containerId}`,
query: infraMetricsQuery
Expand All @@ -140,6 +144,7 @@ export const getSections = ({
{ defaultMessage: 'Host logs' }
),
href: getInfraHref({
app: 'logs',
basePath,
path: `/link-to/host-logs/${hostName}`,
query: { time }
Expand All @@ -153,6 +158,7 @@ export const getSections = ({
{ defaultMessage: 'Host metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/host-detail/${hostName}`,
query: infraMetricsQuery
Expand All @@ -169,6 +175,7 @@ export const getSections = ({
{ defaultMessage: 'Trace logs' }
),
href: getInfraHref({
app: 'logs',
basePath,
path: `/link-to/logs`,
query: {
Expand Down
Loading

0 comments on commit 0a6c748

Please sign in to comment.