Skip to content

Commit

Permalink
[Observability][Exploratory View] revert exploratory view multi-series (
Browse files Browse the repository at this point in the history
elastic#107647)

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dominiqueclarke and kibanamachine authored Aug 10, 2021
1 parent 328c36d commit 1649661
Show file tree
Hide file tree
Showing 123 changed files with 2,590 additions and 3,866 deletions.
9 changes: 7 additions & 2 deletions packages/kbn-test/src/jest/utils/get_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ interface UrlParam {
username?: string;
}

interface App {
pathname?: string;
hash?: string;
}

/**
* Converts a config and a pathname to a url
* @param {object} config A url config
Expand All @@ -41,11 +46,11 @@ interface UrlParam {
* @return {string}
*/

function getUrl(config: UrlParam, app: UrlParam) {
function getUrl(config: UrlParam, app: App) {
return url.format(_.assign({}, config, app));
}

getUrl.noAuth = function getUrlNoAuth(config: UrlParam, app: UrlParam) {
getUrl.noAuth = function getUrlNoAuth(config: UrlParam, app: App) {
config = _.pickBy(config, function (val, param) {
return param !== 'auth';
});
Expand Down
10 changes: 1 addition & 9 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,7 @@ export class CommonPageObject extends FtrService {

async navigateToApp(
appName: string,
{
basePath = '',
shouldLoginIfPrompted = true,
hash = '',
search = '',
insertTimestamp = true,
} = {}
{ basePath = '', shouldLoginIfPrompted = true, hash = '', insertTimestamp = true } = {}
) {
let appUrl: string;
if (this.config.has(['apps', appName])) {
Expand All @@ -217,13 +211,11 @@ export class CommonPageObject extends FtrService {
appUrl = getUrl.noAuth(this.config.get('servers.kibana'), {
pathname: `${basePath}${appConfig.pathname}`,
hash: hash || appConfig.hash,
search,
});
} else {
appUrl = getUrl.noAuth(this.config.get('servers.kibana'), {
pathname: `${basePath}/app/${appName}`,
hash,
search,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { i18n } from '@kbn/i18n';
import {
createExploratoryViewUrl,
HeaderMenuPortal,
SeriesUrl,
} from '../../../../../../observability/public';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
import { AppMountParameters } from '../../../../../../../../src/core/public';
import { SERVICE_NAME } from '../../../../../common/elasticsearch_fieldnames';

const ANALYZE_DATA = i18n.translate('xpack.apm.analyzeDataButtonLabel', {
defaultMessage: 'Analyze data',
Expand All @@ -38,22 +38,15 @@ export function UXActionMenu({
services: { http },
} = useKibana();
const { urlParams } = useUrlParams();
const { rangeTo, rangeFrom, serviceName } = urlParams;
const { rangeTo, rangeFrom } = urlParams;

const uxExploratoryViewLink = createExploratoryViewUrl(
{
reportType: 'kpi-over-time',
allSeries: [
{
dataType: 'ux',
name: `${serviceName}-page-views`,
time: { from: rangeFrom!, to: rangeTo! },
reportDefinitions: {
[SERVICE_NAME]: serviceName ? [serviceName] : [],
},
selectedMetricField: 'Records',
},
],
'ux-series': ({
dataType: 'ux',
isNew: true,
time: { from: rangeFrom, to: rangeTo },
} as unknown) as SeriesUrl,
},
http?.basePath.get()
);
Expand All @@ -67,7 +60,6 @@ export function UXActionMenu({
<EuiHeaderLinks gutterSize="xs">
<EuiToolTip position="top" content={<p>{ANALYZE_MESSAGE}</p>}>
<EuiHeaderLink
data-test-subj="uxAnalyzeBtn"
color="text"
href={uxExploratoryViewLink}
iconType="visBarVerticalStacked"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,15 @@ export function PageLoadDistribution() {

const exploratoryViewLink = createExploratoryViewUrl(
{
reportType: 'kpi-over-time',
allSeries: [
{
name: `${serviceName}-page-views`,
dataType: 'ux',
time: { from: rangeFrom!, to: rangeTo! },
reportDefinitions: {
'service.name': serviceName as string[],
},
...(breakdown ? { breakdown: breakdown.fieldName } : {}),
[`${serviceName}-page-views`]: {
dataType: 'ux',
reportType: 'data-distribution',
time: { from: rangeFrom!, to: rangeTo! },
reportDefinitions: {
'service.name': serviceName as string[],
},
],
...(breakdown ? { breakdown: breakdown.fieldName } : {}),
},
},
http?.basePath.get()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,15 @@ export function PageViewsTrend() {

const exploratoryViewLink = createExploratoryViewUrl(
{
reportType: 'kpi-over-time',
allSeries: [
{
name: `${serviceName}-page-views`,
dataType: 'ux',
time: { from: rangeFrom!, to: rangeTo! },
reportDefinitions: {
'service.name': serviceName as string[],
},
...(breakdown ? { breakdown: breakdown.fieldName } : {}),
[`${serviceName}-page-views`]: {
dataType: 'ux',
reportType: 'kpi-over-time',
time: { from: rangeFrom!, to: rangeTo! },
reportDefinitions: {
'service.name': serviceName as string[],
},
],
...(breakdown ? { breakdown: breakdown.fieldName } : {}),
},
},
http?.basePath.get()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('AnalyzeDataButton', () => {
render(<Example agentName="rum-js" />);

expect((screen.getByRole('link') as HTMLAnchorElement).href).toEqual(
'http://localhost/app/observability/exploratory-view/configure#?reportType=kpi-over-time&sr=!((dt:ux,mt:transaction.duration.us,n:testServiceName-response-latency,op:average,rdf:(service.environment:!(testEnvironment),service.name:!(testServiceName)),time:(from:now-15m,to:now)))'
'http://localhost/app/observability/exploratory-view#?sr=(apm-series:(dt:ux,isNew:!t,op:average,rdf:(service.environment:!(testEnvironment),service.name:!(testServiceName)),rt:kpi-over-time,time:(from:now-15m,to:now)))'
);
});
});
Expand All @@ -48,7 +48,7 @@ describe('AnalyzeDataButton', () => {
render(<Example agentName="iOS/swift" />);

expect((screen.getByRole('link') as HTMLAnchorElement).href).toEqual(
'http://localhost/app/observability/exploratory-view/configure#?reportType=kpi-over-time&sr=!((dt:mobile,mt:transaction.duration.us,n:testServiceName-response-latency,op:average,rdf:(service.environment:!(testEnvironment),service.name:!(testServiceName)),time:(from:now-15m,to:now)))'
'http://localhost/app/observability/exploratory-view#?sr=(apm-series:(dt:mobile,isNew:!t,op:average,rdf:(service.environment:!(testEnvironment),service.name:!(testServiceName)),rt:kpi-over-time,time:(from:now-15m,to:now)))'
);
});
});
Expand All @@ -58,7 +58,7 @@ describe('AnalyzeDataButton', () => {
render(<Example environment={undefined} />);

expect((screen.getByRole('link') as HTMLAnchorElement).href).toEqual(
'http://localhost/app/observability/exploratory-view/configure#?reportType=kpi-over-time&sr=!((dt:mobile,mt:transaction.duration.us,n:testServiceName-response-latency,op:average,rdf:(service.name:!(testServiceName)),time:(from:now-15m,to:now)))'
'http://localhost/app/observability/exploratory-view#?sr=(apm-series:(dt:mobile,isNew:!t,op:average,rdf:(service.name:!(testServiceName)),rt:kpi-over-time,time:(from:now-15m,to:now)))'
);
});
});
Expand All @@ -68,7 +68,7 @@ describe('AnalyzeDataButton', () => {
render(<Example environment={ENVIRONMENT_NOT_DEFINED.value} />);

expect((screen.getByRole('link') as HTMLAnchorElement).href).toEqual(
'http://localhost/app/observability/exploratory-view/configure#?reportType=kpi-over-time&sr=!((dt:mobile,mt:transaction.duration.us,n:testServiceName-response-latency,op:average,rdf:(service.environment:!(ENVIRONMENT_NOT_DEFINED),service.name:!(testServiceName)),time:(from:now-15m,to:now)))'
'http://localhost/app/observability/exploratory-view#?sr=(apm-series:(dt:mobile,isNew:!t,op:average,rdf:(service.name:!(testServiceName)),rt:kpi-over-time,time:(from:now-15m,to:now)))'
);
});
});
Expand All @@ -78,7 +78,7 @@ describe('AnalyzeDataButton', () => {
render(<Example environment={ENVIRONMENT_ALL.value} />);

expect((screen.getByRole('link') as HTMLAnchorElement).href).toEqual(
'http://localhost/app/observability/exploratory-view/configure#?reportType=kpi-over-time&sr=!((dt:mobile,mt:transaction.duration.us,n:testServiceName-response-latency,op:average,rdf:(service.environment:!(ALL_VALUES),service.name:!(testServiceName)),time:(from:now-15m,to:now)))'
'http://localhost/app/observability/exploratory-view#?sr=(apm-series:(dt:mobile,isNew:!t,op:average,rdf:(service.environment:!(ALL_VALUES),service.name:!(testServiceName)),rt:kpi-over-time,time:(from:now-15m,to:now)))'
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { EuiButtonEmpty, EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public';
import { createExploratoryViewUrl } from '../../../../../../observability/public';
import {
createExploratoryViewUrl,
SeriesUrl,
} from '../../../../../../observability/public';
import { ALL_VALUES_SELECTED } from '../../../../../../observability/public';
import {
isIosAgentName,
Expand All @@ -18,7 +21,6 @@ import {
import {
SERVICE_ENVIRONMENT,
SERVICE_NAME,
TRANSACTION_DURATION,
} from '../../../../../common/elasticsearch_fieldnames';
import {
ENVIRONMENT_ALL,
Expand All @@ -27,11 +29,13 @@ import {
import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';

function getEnvironmentDefinition(environment: string) {
function getEnvironmentDefinition(environment?: string) {
switch (environment) {
case ENVIRONMENT_ALL.value:
return { [SERVICE_ENVIRONMENT]: [ALL_VALUES_SELECTED] };
case ENVIRONMENT_NOT_DEFINED.value:
case undefined:
return {};
default:
return { [SERVICE_ENVIRONMENT]: [environment] };
}
Expand All @@ -47,26 +51,21 @@ export function AnalyzeDataButton() {

if (
(isRumAgentName(agentName) || isIosAgentName(agentName)) &&
rangeFrom &&
canShowDashboard &&
rangeTo
canShowDashboard
) {
const href = createExploratoryViewUrl(
{
reportType: 'kpi-over-time',
allSeries: [
{
name: `${serviceName}-response-latency`,
selectedMetricField: TRANSACTION_DURATION,
dataType: isRumAgentName(agentName) ? 'ux' : 'mobile',
time: { from: rangeFrom, to: rangeTo },
reportDefinitions: {
[SERVICE_NAME]: [serviceName],
...(environment ? getEnvironmentDefinition(environment) : {}),
},
operationType: 'average',
'apm-series': {
dataType: isRumAgentName(agentName) ? 'ux' : 'mobile',
time: { from: rangeFrom, to: rangeTo },
reportType: 'kpi-over-time',
reportDefinitions: {
[SERVICE_NAME]: [serviceName],
...getEnvironmentDefinition(environment),
},
],
operationType: 'average',
isNew: true,
} as SeriesUrl,
},
basepath
);
Expand Down
6 changes: 1 addition & 5 deletions x-pack/plugins/apm/server/lib/rum_client/has_rum_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import moment from 'moment';
import { Setup, SetupTimeRange } from '../helpers/setup_request';
import {
SERVICE_NAME,
Expand All @@ -21,10 +20,7 @@ export async function hasRumData({
setup: Setup & Partial<SetupTimeRange>;
}) {
try {
const {
start = moment().subtract(24, 'h').valueOf(),
end = moment().valueOf(),
} = setup;
const { start, end } = setup;

const params = {
apm: {
Expand Down
12 changes: 10 additions & 2 deletions x-pack/plugins/observability/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@
},
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["xpack", "observability"],
"optionalPlugins": ["home", "discover", "lens", "licensing", "usageCollection"],
"configPath": [
"xpack",
"observability"
],
"optionalPlugins": [
"home",
"lens",
"licensing",
"usageCollection"
],
"requiredPlugins": [
"alerting",
"cases",
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1649661

Please sign in to comment.