Skip to content

Commit

Permalink
improve queries
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Li <joshuali925@gmail.com>
  • Loading branch information
joshuali925 committed Aug 14, 2024
1 parent 94e5a16 commit 1df4c3f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function ServiceDetailFlyout(props: ServiceFlyoutProps) {
handleServiceViewRequest(serviceName, http, serviceDSL, setFields, mode);
handleServiceMapRequest(http, serviceDSL, mode, '', setServiceMap, serviceName);
const spanDSL = filtersToDsl(mode, filters, query, startTime, endTime, 'app', appConfigs);
spanDSL.query.bool.must.push({
spanDSL.query.bool.filter.push({
term: {
serviceName,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,10 @@ export const filtersToDsl = (
},
},
};
DSL.query.bool.must.push(timeFilter);
DSL.query.bool.filter.push(timeFilter);
DSL.custom.timeFilter.push(timeFilter);
if (query.length > 0) {
DSL.query.bool.must.push({
DSL.query.bool.filter.push({
query_string: {
query,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,21 +405,21 @@ export function ServiceView(props: ServiceViewProps) {
processTimeStamp(props.endTime, mode)
);
if (mode === 'data_prepper') {
spanDSL.query.bool.must.push({
spanDSL.query.bool.filter.push({
term: {
serviceName: props.serviceName,
},
});
} else if (mode === 'jaeger') {
spanDSL.query.bool.must.push({
spanDSL.query.bool.filter.push({
term: {
'process.serviceName': props.serviceName,
},
});
}
spanFilters.map(({ field, value }) => {
if (value != null) {
spanDSL.query.bool.must.push({
spanDSL.query.bool.filter.push({
term: {
[field]: value,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function SpanDetailPanel(props: {
};
spanFilters.map(({ field, value }) => {
if (value != null) {
spanDSL.query.bool.must.push({
spanDSL.query.bool.filter.push({
term: {
[field]: value,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export const getServicesQuery = (
};
if (mode === 'jaeger') {
if (serviceName) {
query.query.bool.must.push({
query.query.bool.filter.push({
term: {
'process.serviceName': serviceName,
},
});
}
DSL?.custom?.serviceNames?.map((service: string) => {
query.query.bool.must.push({
query.query.bool.filter.push({
term: {
'process.serviceName': service,
},
Expand All @@ -68,14 +68,14 @@ export const getServicesQuery = (
});
} else {
if (serviceName) {
query.query.bool.must.push({
query.query.bool.filter.push({
term: {
serviceName,
},
});
}
DSL?.custom?.serviceNames?.map((service: string) => {
query.query.bool.must.push({
query.query.bool.filter.push({
term: {
serviceName: service,
},
Expand Down Expand Up @@ -457,8 +457,8 @@ export const getServiceMetricsQuery = (
},
};
if (DSL.custom?.timeFilter.length > 0) {
jaegerQuery.query.bool.must.push(...DSL.custom.timeFilter);
dataPrepperQuery.query.bool.must.push(...DSL.custom.timeFilter);
jaegerQuery.query.bool.filter.push(...DSL.custom.timeFilter);
dataPrepperQuery.query.bool.filter.push(...DSL.custom.timeFilter);
}
return mode === 'jaeger' ? jaegerQuery : dataPrepperQuery;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const getTracesQuery = (
order: {
[field]: direction,
},
execution_hint: 'map',
},
aggs: {
latency: {
Expand Down Expand Up @@ -118,6 +119,7 @@ export const getTracesQuery = (
},
},
},
track_total_hits: false,
};
const dataPrepperQuery: any = {
size: 0,
Expand All @@ -137,6 +139,7 @@ export const getTracesQuery = (
order: {
[field]: direction,
},
execution_hint: 'map',
},
aggs: {
latency: {
Expand Down Expand Up @@ -173,14 +176,15 @@ export const getTracesQuery = (
},
},
},
track_total_hits: false,
};
if (traceId) {
jaegerQuery.query.bool.must.push({
jaegerQuery.query.bool.filter.push({
term: {
traceID: traceId,
},
});
dataPrepperQuery.query.bool.must.push({
dataPrepperQuery.query.bool.filter.push({
term: {
traceId,
},
Expand Down
1 change: 1 addition & 0 deletions server/routes/trace_analytics_dsl_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export function registerTraceAnalyticsDslRouter(router: IRouter, dataSourceEnabl
})
),
script_fields: schema.maybe(schema.any()),
track_total_hits: schema.maybe(schema.boolean()),
}),
query: schema.object({
dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
Expand Down

0 comments on commit 1df4c3f

Please sign in to comment.