Skip to content

Commit d267483

Browse files
committed
[Uptime] Use service.name to link from Uptime -> APM where available (elastic#73618)
With elastic/beats#19932 coming in 7.10 adding the `service.name` ECS field is very easy. We should prefer this field when cross linking to APM, hence this PR. Resolves elastic/uptime#220 # Conflicts: # x-pack/plugins/uptime/public/lib/helper/observability_integration/get_apm_href.ts
1 parent cde5e2e commit d267483

File tree

7 files changed

+40
-14
lines changed

7 files changed

+40
-14
lines changed

x-pack/plugins/uptime/common/runtime_types/monitor/state.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export const StateType = t.intersection([
3737
name: t.array(t.string),
3838
}),
3939
}),
40+
service: t.partial({
41+
name: t.string,
42+
}),
4043
}),
4144
]);
4245

x-pack/plugins/uptime/common/runtime_types/ping/ping.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ export const PingType = t.intersection([
196196
port: t.number,
197197
scheme: t.string,
198198
}),
199+
service: t.partial({
200+
name: t.string,
201+
}),
199202
}),
200203
]);
201204

x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/integration_group.test.tsx.snap

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/integration_group.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,17 @@ export const IntegrationGroup = ({ summary }: IntegrationGroupProps) => {
6464
href={getApmHref(summary, basePath, dateRangeStart, dateRangeEnd)}
6565
iconType="apmApp"
6666
message={i18n.translate('xpack.uptime.apmIntegrationAction.text', {
67-
defaultMessage: 'Check APM for domain',
67+
defaultMessage: 'Show APM Data',
6868
description:
69-
'A message explaining that when the user clicks the associated link, it will navigate to the APM app and search for the selected domain',
69+
'A message explaining that when the user clicks the associated link, it will navigate to the APM app',
7070
})}
7171
tooltipContent={i18n.translate(
7272
'xpack.uptime.monitorList.observabilityIntegrationsColumn.apmIntegrationLink.tooltip',
7373
{
74-
defaultMessage: 'Click here to check APM for the domain "{domain}".',
74+
defaultMessage:
75+
'Click here to check APM for the domain "{domain}" or explicitly defined "service name".',
7576
description:
76-
'A messsage shown in a tooltip explaining that the nested anchor tag will navigate to the APM app and search for the given URL domain.',
77+
'A messsage shown in a tooltip explaining that the nested anchor tag will navigate to the APM app and search for the given URL domain or explicitly defined service name.',
7778
values: {
7879
domain,
7980
},

x-pack/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_apm_href.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { MonitorSummary, makePing } from '../../../../../common/runtime_types';
99

1010
describe('getApmHref', () => {
1111
let summary: MonitorSummary;
12-
1312
beforeEach(() => {
1413
summary = {
1514
monitor_id: 'foo',
@@ -49,4 +48,18 @@ describe('getApmHref', () => {
4948
`"/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`
5049
);
5150
});
51+
52+
describe('with service.name', () => {
53+
const serviceName = 'MyServiceName';
54+
beforeEach(() => {
55+
summary.state.service = { name: serviceName };
56+
});
57+
58+
it('links to the named service', () => {
59+
const result = getApmHref(summary, 'foo', 'now-15m', 'now');
60+
expect(result).toMatchInlineSnapshot(
61+
`"foo/app/apm#/services?kuery=service.name:%20%22${serviceName}%22&rangeFrom=now-15m&rangeTo=now"`
62+
);
63+
});
64+
});
5265
});

x-pack/plugins/uptime/public/lib/helper/observability_integration/get_apm_href.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ export const getApmHref = (
1313
basePath: string,
1414
dateRangeStart: string,
1515
dateRangeEnd: string
16-
) =>
17-
addBasePath(
16+
) => {
17+
const clause = summary?.state?.service?.name
18+
? `service.name: "${summary.state.service.name}"`
19+
: `url.domain: "${summary.state.url?.domain}"`;
20+
21+
return addBasePath(
1822
basePath,
1923
`/app/apm#/services?kuery=${encodeURI(
20-
`url.domain: "${get(summary, 'state.url.domain')}"`
24+
clause
2125
)}&rangeFrom=${dateRangeStart}&rangeTo=${dateRangeEnd}`
2226
);
27+
};

x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export const summaryPingsToSummary = (summaryPings: Ping[]): MonitorSummary => {
9393
observer: {
9494
geo: { name: summaryPings.map((p) => p.observer?.geo?.name ?? '').filter((n) => n !== '') },
9595
},
96+
service: summaryPings.find((p) => p.service?.name)?.service,
9697
},
9798
};
9899
};

0 commit comments

Comments
 (0)