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

Removed Alerting & Event Log deprecated fields that should not be using #85652

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions x-pack/plugins/actions/server/usage/actions_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export async function getTotalCount(callCluster: LegacyAPICaller, kibanaIndex: s

const searchResult = await callCluster('search', {
index: kibanaIndex,
rest_total_hits_as_int: true,
body: {
query: {
bool: {
Expand Down Expand Up @@ -104,7 +103,6 @@ export async function getInUseTotalCount(callCluster: LegacyAPICaller, kibanaInd

const actionResults = await callCluster('search', {
index: kibanaIndex,
rest_total_hits_as_int: true,
body: {
query: {
bool: {
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/alerts/server/usage/alerts_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export async function getTotalCountAggregations(callCluster: LegacyAPICaller, ki

const results = await callCluster('search', {
index: kibanaInex,
rest_total_hits_as_int: true,
body: {
query: {
bool: {
Expand Down Expand Up @@ -289,7 +288,6 @@ export async function getTotalCountAggregations(callCluster: LegacyAPICaller, ki
export async function getTotalCountInUse(callCluster: LegacyAPICaller, kibanaInex: string) {
const searchResult: SearchResponse<unknown> = await callCluster('search', {
index: kibanaInex,
rest_total_hits_as_int: true,
body: {
query: {
bool: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ describe('queryEventsBySavedObject', () => {
},
},
"index": "index-name",
"rest_total_hits_as_int": true,
"track_total_hits": true,
}
`);
});
Expand Down Expand Up @@ -475,7 +475,7 @@ describe('queryEventsBySavedObject', () => {
},
},
"index": "index-name",
"rest_total_hits_as_int": true,
"track_total_hits": true,
}
`);
});
Expand Down Expand Up @@ -589,7 +589,7 @@ describe('queryEventsBySavedObject', () => {
},
},
"index": "index-name",
"rest_total_hits_as_int": true,
"track_total_hits": true,
}
`);
});
Expand Down Expand Up @@ -686,7 +686,7 @@ describe('queryEventsBySavedObject', () => {
},
},
"index": "index-name",
"rest_total_hits_as_int": true,
"track_total_hits": true,
}
`);
});
Expand Down
6 changes: 2 additions & 4 deletions x-pack/plugins/event_log/server/es/cluster_client_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,13 @@ export class ClusterClientAdapter {
hits: { hits, total },
}: SearchResponse<unknown> = await this.callEs('search', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use the ESSearchResponse type you won't need to cast to unknown.

At the top add:

import { ESSearchResponse } from '../../../../typings/elasticsearch';

Then you can replace this with:

Suggested change
}: SearchResponse<unknown> = await this.callEs('search', {
}: ESSearchResponse<unknown, {}> = await this.callEs('search', {

Then below, replace the cast with:

        total: total.value,

index,
// The SearchResponse type only supports total as an int,
// so we're forced to explicitly request that it return as an int
rest_total_hits_as_int: true,
track_total_hits: true,
body,
});
return {
page,
per_page: perPage,
total,
total: ((total as unknown) as { value: number; relation: string }).value || 0,
data: hits.map((hit) => hit._source) as IValidatedEvent[],
};
} catch (err) {
Expand Down