diff --git a/public/components/dashboard/dashboard.tsx b/public/components/dashboard/dashboard.tsx index 2844f150b..4ff047a6e 100644 --- a/public/components/dashboard/dashboard.tsx +++ b/public/components/dashboard/dashboard.tsx @@ -133,11 +133,19 @@ export function Dashboard(props: DashboardProps) { if (tableItems.length === 0 || Object.keys(percentileMap).length === 0) return; for (let i = 0; i < props.filters.length; i++) { if (props.filters[i].custom) { - const newFilter = JSON.parse( - JSON.stringify(props.filters[i]).replace( - /{"range":{"durationInNanos":{"[gl]te?"/g, - `{"range":{"durationInNanos":{"${condition}"` - ) + const newFilter = JSON.parse(JSON.stringify(props.filters[i])); + newFilter.custom.query.bool.should.forEach((should) => + should.bool.must.forEach((must) => { + const range = must?.range?.['traceGroup.durationInNanos']; + if (range) { + const duration = range.lt || range.lte || range.gt || range.gte; + if (duration || duration === 0) { + must.range['traceGroup.durationInNanos'] = { + [condition]: duration, + }; + } + } + }) ); newFilter.value = condition === 'gte' ? '>= 95th' : '< 95th'; const newFilters = [...props.filters, ...additionalFilters]; diff --git a/public/requests/queries/traces_queries.ts b/public/requests/queries/traces_queries.ts index 90ca1bb65..6d481e5a3 100644 --- a/public/requests/queries/traces_queries.ts +++ b/public/requests/queries/traces_queries.ts @@ -92,7 +92,13 @@ export const getTracesQuery = (traceId = null, sort?: PropertySort) => { latency: { max: { script: { - source: "Math.round(doc['traceGroup.durationInNanos'].value / 10000) / 100.0", + source: ` + if (doc.containsKey('traceGroup.durationInNanos') && !doc['traceGroup.durationInNanos'].empty) { + return Math.round(doc['traceGroup.durationInNanos'].value / 10000) / 100.0 + } + + return 0 + `, lang: 'painless', }, }, diff --git a/public/requests/services_request_handler.ts b/public/requests/services_request_handler.ts index 9df8c9b5c..b0a12fff5 100644 --- a/public/requests/services_request_handler.ts +++ b/public/requests/services_request_handler.ts @@ -48,21 +48,23 @@ export const handleServicesRequest = async ( const serviceObject: ServiceObject = await handleServiceMapRequest(http, DSL); if (setServiceMap) setServiceMap(serviceObject); return Promise.all( - response.aggregations.service.buckets.map((bucket) => { - const connectedServices = [ - ...serviceObject[bucket.key].targetServices, - ...serviceObject[bucket.key].destServices, - ]; - return { - name: bucket.key, - average_latency: serviceObject[bucket.key].latency, - error_rate: serviceObject[bucket.key].error_rate, - throughput: serviceObject[bucket.key].throughput, - traces: bucket.trace_count.value, - connected_services: connectedServices.join(', '), - number_of_connected_services: connectedServices.length, - }; - }) + response.aggregations.service.buckets + .filter((bucket) => serviceObject[bucket.key]) + .map((bucket) => { + const connectedServices = [ + ...serviceObject[bucket.key].targetServices, + ...serviceObject[bucket.key].destServices, + ]; + return { + name: bucket.key, + average_latency: serviceObject[bucket.key].latency, + error_rate: serviceObject[bucket.key].error_rate, + throughput: serviceObject[bucket.key].throughput, + traces: bucket.trace_count.value, + connected_services: connectedServices.join(', '), + number_of_connected_services: connectedServices.length, + }; + }) ); }) .then((newItems) => { @@ -111,10 +113,12 @@ export const handleServiceMapRequest = async (http, DSL, items?, setItems?, curr bucket.resource.buckets.map((resource) => { resource.domain.buckets.map((domain) => { const targetService = targets[resource.key + ':' + domain.key]; - if (map[bucket.key].targetServices.indexOf(targetService) === -1) - map[bucket.key].targetServices.push(targetService); - if (map[targetService].destServices.indexOf(bucket.key) === -1) - map[targetService].destServices.push(bucket.key); + if (targetService) { + if (map[bucket.key].targetServices.indexOf(targetService) === -1) + map[bucket.key].targetServices.push(targetService); + if (map[targetService].destServices.indexOf(bucket.key) === -1) + map[targetService].destServices.push(bucket.key); + } }); }); })