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][RUM] adjust data types for uiFilters and range in APM requests #99257

Merged
19 changes: 17 additions & 2 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 @@ -14,7 +14,11 @@ import { ProcessorEvent } from '../../../common/processor_event';
import { rangeQuery } from '../../../server/utils/queries';
import { TRANSACTION_PAGE_LOAD } from '../../../common/transaction_types';

export async function hasRumData({ setup }: { setup: Setup & SetupTimeRange }) {
export async function hasRumData({
setup,
}: {
setup: Setup & Partial<SetupTimeRange>;
}) {
try {
const { start, end } = setup;

Expand All @@ -31,7 +35,18 @@ export async function hasRumData({ setup }: { setup: Setup & SetupTimeRange }) {
},
aggs: {
services: {
filter: rangeQuery(start, end)[0],
...(start && end
? { filter: rangeQuery(start, end)[0] }
: {
// accounts for scenarios in which start and end are undefined
filter: {
range: {
'@timestamp': {
format: 'epoch_millis',
},
},
},
}),
aggs: {
mostTraffic: {
terms: {
Expand Down
7 changes: 6 additions & 1 deletion x-pack/plugins/apm/server/routes/rum_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import * as t from 'io-ts';
import { jsonRt } from '@kbn/io-ts-utils';
import { isoToEpochRt } from '@kbn/io-ts-utils';
import { LocalUIFilterName } from '../../common/ui_filter';
import {
Setup,
Expand Down Expand Up @@ -264,7 +265,11 @@ const rumJSErrors = createApmServerRoute({
const rumHasDataRoute = createApmServerRoute({
endpoint: 'GET /api/apm/observability_overview/has_rum_data',
params: t.partial({
query: t.intersection([uiFiltersRt, rangeRt]),
query: t.partial({
uiFilters: t.string,
start: isoToEpochRt,
end: isoToEpochRt,
}),
}),
options: { tags: ['access:apm'] },
handler: async (resources) => {
Expand Down