Skip to content

Commit f7b99c2

Browse files
[Logs UI] Replace legacy es client usage in category examples (#100716) (#101055)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>
1 parent 8a205e3 commit f7b99c2

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import type { estypes } from '@elastic/elasticsearch';
9-
import type { ILegacyScopedClusterClient } from 'src/core/server';
9+
import type { ElasticsearchClient } from 'src/core/server';
1010
import {
1111
compareDatasetsByMaximumAnomalyScore,
1212
getJobId,
@@ -136,7 +136,7 @@ export async function getLogEntryCategoryDatasets(
136136

137137
export async function getLogEntryCategoryExamples(
138138
context: {
139-
core: { elasticsearch: { legacy: { client: ILegacyScopedClusterClient } } };
139+
core: { elasticsearch: { client: { asCurrentUser: ElasticsearchClient } } };
140140
infra: {
141141
mlAnomalyDetectors: MlAnomalyDetectors;
142142
mlSystem: MlSystem;
@@ -402,7 +402,7 @@ async function fetchTopLogEntryCategoryHistograms(
402402
}
403403

404404
async function fetchLogEntryCategoryExamples(
405-
requestContext: { core: { elasticsearch: { legacy: { client: ILegacyScopedClusterClient } } } },
405+
requestContext: { core: { elasticsearch: { client: { asCurrentUser: ElasticsearchClient } } } },
406406
indices: string,
407407
runtimeMappings: estypes.RuntimeFields,
408408
timestampField: string,
@@ -417,19 +417,20 @@ async function fetchLogEntryCategoryExamples(
417417
const {
418418
hits: { hits },
419419
} = decodeOrThrow(logEntryCategoryExamplesResponseRT)(
420-
await requestContext.core.elasticsearch.legacy.client.callAsCurrentUser(
421-
'search',
422-
createLogEntryCategoryExamplesQuery(
423-
indices,
424-
runtimeMappings,
425-
timestampField,
426-
tiebreakerField,
427-
startTime,
428-
endTime,
429-
categoryQuery,
430-
exampleCount
420+
(
421+
await requestContext.core.elasticsearch.client.asCurrentUser.search(
422+
createLogEntryCategoryExamplesQuery(
423+
indices,
424+
runtimeMappings,
425+
timestampField,
426+
tiebreakerField,
427+
startTime,
428+
endTime,
429+
categoryQuery,
430+
exampleCount
431+
)
431432
)
432-
)
433+
).body
433434
);
434435

435436
const esSearchSpan = finalizeEsSearchSpan();

0 commit comments

Comments
 (0)