forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transactions.ts
58 lines (53 loc) · 1.45 KB
/
transactions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { Setup } from '../../server/lib/helpers/setup_request';
import {
SERVICE_NAME,
TRANSACTION_TYPE,
PROCESSOR_EVENT,
TRANSACTION_NAME
} from '../elasticsearch_fieldnames';
import { rangeFilter } from '../../server/lib/helpers/range_filter';
export function getTransactionsProjection({
setup,
serviceName,
transactionName,
transactionType
}: {
setup: Setup;
serviceName?: string;
transactionName?: string;
transactionType?: string;
}) {
const { start, end, uiFiltersES, config } = setup;
const transactionNameFilter = transactionName
? [{ term: { [TRANSACTION_NAME]: transactionName } }]
: [];
const transactionTypeFilter = transactionType
? [{ term: { [TRANSACTION_TYPE]: transactionType } }]
: [];
const serviceNameFilter = serviceName
? [{ term: { [SERVICE_NAME]: serviceName } }]
: [];
const bool = {
filter: [
{ range: rangeFilter(start, end) },
{ term: { [PROCESSOR_EVENT]: 'transaction' } },
...transactionNameFilter,
...transactionTypeFilter,
...serviceNameFilter,
...uiFiltersES
]
};
return {
index: config.get<string>('apm_oss.transactionIndices'),
body: {
query: {
bool
}
}
};
}