Skip to content

Commit 640c0fd

Browse files
committed
Type fixes: 4th wave
1 parent 926661a commit 640c0fd

File tree

47 files changed

+1059
-1138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1059
-1138
lines changed

x-pack/platform/plugins/private/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.ts

+70-72
Original file line numberDiff line numberDiff line change
@@ -30,90 +30,88 @@ export async function fetchCCRReadExceptions(
3030
const params = {
3131
index: indexPatterns,
3232
filter_path: ['aggregations.remote_clusters.buckets'],
33-
body: {
34-
size: 0,
35-
query: {
36-
bool: {
37-
filter: [
38-
{
39-
bool: {
40-
should: [
41-
{
42-
nested: {
43-
ignore_unmapped: true,
44-
path: 'ccr_stats.read_exceptions',
45-
query: {
46-
exists: {
47-
field: 'ccr_stats.read_exceptions.exception',
48-
},
33+
size: 0,
34+
query: {
35+
bool: {
36+
filter: [
37+
{
38+
bool: {
39+
should: [
40+
{
41+
nested: {
42+
ignore_unmapped: true,
43+
path: 'ccr_stats.read_exceptions',
44+
query: {
45+
exists: {
46+
field: 'ccr_stats.read_exceptions.exception',
4947
},
5048
},
5149
},
52-
{
53-
nested: {
54-
ignore_unmapped: true,
55-
path: 'elasticsearch.ccr.read_exceptions',
56-
query: {
57-
exists: {
58-
field: 'elasticsearch.ccr.read_exceptions.exception',
59-
},
50+
},
51+
{
52+
nested: {
53+
ignore_unmapped: true,
54+
path: 'elasticsearch.ccr.read_exceptions',
55+
query: {
56+
exists: {
57+
field: 'elasticsearch.ccr.read_exceptions.exception',
6058
},
6159
},
6260
},
63-
],
64-
minimum_should_match: 1,
65-
},
66-
},
67-
createDatasetFilter('ccr_stats', 'ccr', getElasticsearchDataset('ccr')),
68-
{
69-
range: {
70-
timestamp: {
71-
format: 'epoch_millis',
72-
gte: startMs,
73-
lte: endMs,
7461
},
75-
},
62+
],
63+
minimum_should_match: 1,
7664
},
77-
],
78-
},
79-
},
80-
aggs: {
81-
remote_clusters: {
82-
terms: {
83-
field: 'ccr_stats.remote_cluster',
84-
size,
8565
},
86-
aggs: {
87-
follower_indices: {
88-
terms: {
89-
field: 'ccr_stats.follower_index',
90-
size,
66+
createDatasetFilter('ccr_stats', 'ccr', getElasticsearchDataset('ccr')),
67+
{
68+
range: {
69+
timestamp: {
70+
format: 'epoch_millis',
71+
gte: startMs,
72+
lte: endMs,
9173
},
92-
aggs: {
93-
hits: {
94-
top_hits: {
95-
sort: [
96-
{
97-
timestamp: {
98-
order: 'desc' as const,
99-
unmapped_type: 'long' as const,
100-
},
74+
},
75+
},
76+
],
77+
},
78+
},
79+
aggs: {
80+
remote_clusters: {
81+
terms: {
82+
field: 'ccr_stats.remote_cluster',
83+
size,
84+
},
85+
aggs: {
86+
follower_indices: {
87+
terms: {
88+
field: 'ccr_stats.follower_index',
89+
size,
90+
},
91+
aggs: {
92+
hits: {
93+
top_hits: {
94+
sort: [
95+
{
96+
timestamp: {
97+
order: 'desc' as const,
98+
unmapped_type: 'long' as const,
10199
},
102-
],
103-
_source: {
104-
includes: [
105-
'cluster_uuid',
106-
'elasticsearch.cluster.id',
107-
'ccr_stats.read_exceptions',
108-
'elasticsearch.ccr.read_exceptions',
109-
'ccr_stats.shard_id',
110-
'elasticsearch.ccr.shard_id',
111-
'ccr_stats.leader_index',
112-
'elasticsearch.ccr.leader.index',
113-
],
114100
},
115-
size: 1,
101+
],
102+
_source: {
103+
includes: [
104+
'cluster_uuid',
105+
'elasticsearch.cluster.id',
106+
'ccr_stats.read_exceptions',
107+
'elasticsearch.ccr.read_exceptions',
108+
'ccr_stats.shard_id',
109+
'elasticsearch.ccr.shard_id',
110+
'ccr_stats.leader_index',
111+
'elasticsearch.ccr.leader.index',
112+
],
116113
},
114+
size: 1,
117115
},
118116
},
119117
},
@@ -126,7 +124,7 @@ export async function fetchCCRReadExceptions(
126124
try {
127125
if (filterQuery) {
128126
const filterQueryObject = JSON.parse(filterQuery);
129-
params.body.query.bool.filter.push(filterQueryObject);
127+
params.query.bool.filter.push(filterQueryObject);
130128
}
131129
} catch (e) {
132130
// meh

x-pack/platform/plugins/private/monitoring/server/lib/alerts/fetch_cluster_health.ts

+30-32
Original file line numberDiff line numberDiff line change
@@ -34,49 +34,47 @@ export async function fetchClusterHealth(
3434
'hits.hits._source.elasticsearch.cluster.id',
3535
'hits.hits._index',
3636
],
37-
body: {
38-
size: clusters.length,
39-
sort: [
40-
{
41-
timestamp: {
42-
order: 'desc' as const,
43-
unmapped_type: 'long' as const,
44-
},
37+
size: clusters.length,
38+
sort: [
39+
{
40+
timestamp: {
41+
order: 'desc' as const,
42+
unmapped_type: 'long' as const,
4543
},
46-
],
47-
query: {
48-
bool: {
49-
filter: [
50-
{
51-
terms: {
52-
cluster_uuid: clusters.map((cluster) => cluster.clusterUuid),
53-
},
44+
},
45+
],
46+
query: {
47+
bool: {
48+
filter: [
49+
{
50+
terms: {
51+
cluster_uuid: clusters.map((cluster) => cluster.clusterUuid),
5452
},
55-
createDatasetFilter(
56-
'cluster_stats',
57-
'cluster_stats',
58-
getElasticsearchDataset('cluster_stats')
59-
),
60-
{
61-
range: {
62-
timestamp: {
63-
gte: `now-${duration}`,
64-
},
53+
},
54+
createDatasetFilter(
55+
'cluster_stats',
56+
'cluster_stats',
57+
getElasticsearchDataset('cluster_stats')
58+
),
59+
{
60+
range: {
61+
timestamp: {
62+
gte: `now-${duration}`,
6563
},
6664
},
67-
],
68-
},
69-
},
70-
collapse: {
71-
field: 'cluster_uuid',
65+
},
66+
],
7267
},
7368
},
69+
collapse: {
70+
field: 'cluster_uuid',
71+
},
7472
};
7573

7674
try {
7775
if (filterQuery) {
7876
const filterQueryObject = JSON.parse(filterQuery);
79-
params.body.query.bool.filter.push(filterQueryObject);
77+
params.query.bool.filter.push(filterQueryObject);
8078
}
8179
} catch (e) {
8280
// meh

x-pack/platform/plugins/private/monitoring/server/lib/alerts/fetch_clusters.ts

+16-18
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,24 @@ export async function fetchClusters(
3939
'hits.hits._source.cluster_name',
4040
'hits.hits._source.elasticsearch.cluster.name',
4141
],
42-
body: {
43-
size: 1000,
44-
query: {
45-
bool: {
46-
filter: [
47-
createDatasetFilter(
48-
'cluster_stats',
49-
'cluster_stats',
50-
getElasticsearchDataset('cluster_stats')
51-
),
52-
{
53-
range: rangeFilter,
54-
},
55-
],
56-
},
57-
},
58-
collapse: {
59-
field: 'cluster_uuid',
42+
size: 1000,
43+
query: {
44+
bool: {
45+
filter: [
46+
createDatasetFilter(
47+
'cluster_stats',
48+
'cluster_stats',
49+
getElasticsearchDataset('cluster_stats')
50+
),
51+
{
52+
range: rangeFilter,
53+
},
54+
],
6055
},
6156
},
57+
collapse: {
58+
field: 'cluster_uuid',
59+
},
6260
};
6361

6462
const response = await esClient.search(params);

0 commit comments

Comments
 (0)