Skip to content

Commit

Permalink
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
Browse files Browse the repository at this point in the history
…-fix'
  • Loading branch information
kibanamachine committed Oct 5, 2022
1 parent 0668a58 commit a10fb33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import {
AggregationsMultiBucketAggregateBase,
AggregationsStringRareTermsBucketKeys
AggregationsStringRareTermsBucketKeys,
} from '@elastic/elasticsearch/lib/api/types';

import { ElasticsearchClient } from '@kbn/core/server';
Expand Down Expand Up @@ -38,7 +38,7 @@ export const getMlInferenceErrors = async (
const searchResult = await esClient.search<
unknown,
{
errors: AggregationsMultiBucketAggregateBase<ErrorAggregationBucket>
errors: AggregationsMultiBucketAggregateBase<ErrorAggregationBucket>;
}
>({
index: indexName,
Expand All @@ -48,21 +48,21 @@ export const getMlInferenceErrors = async (
terms: {
field: '_ingest.inference_errors.message.enum',
order: {
max_error_timestamp: 'desc'
max_error_timestamp: 'desc',
},
size: 20
size: 20,
},
aggs: {
max_error_timestamp: {
max: {
field: '_ingest.inference_errors.timestamp'
}
}
}
}
field: '_ingest.inference_errors.timestamp',
},
},
},
},
},
size: 0
}
size: 0,
},
});

const errorBuckets = searchResult.aggregations?.errors.buckets;
Expand All @@ -71,13 +71,11 @@ export const getMlInferenceErrors = async (
}

// Buckets are either in an array or in a Record, we transform them to an array
const buckets = Array.isArray(errorBuckets)
? errorBuckets
: Object.values(errorBuckets);
const buckets = Array.isArray(errorBuckets) ? errorBuckets : Object.values(errorBuckets);

return buckets.map((bucket) => ({
message: bucket.key,
doc_count: bucket.doc_count,
timestamp: bucket.max_error_timestamp?.value_as_string,
}));
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import {
IngestPutPipelineRequest,
IngestSimulateRequest
IngestSimulateRequest,
} from '@elastic/elasticsearch/lib/api/types';

import { schema } from '@kbn/config-schema';
Expand All @@ -28,6 +28,7 @@ import { fetchIndex } from '../../lib/indices/fetch_index';
import { fetchIndices } from '../../lib/indices/fetch_indices';
import { fetchMlInferencePipelineProcessors } from '../../lib/indices/fetch_ml_inference_pipeline_processors';
import { generateApiKey } from '../../lib/indices/generate_api_key';
import { getMlInferenceErrors } from '../../lib/ml_inference_pipeline/get_inference_errors';
import { createIndexPipelineDefinitions } from '../../lib/pipelines/create_pipeline_definitions';
import { getCustomPipelines } from '../../lib/pipelines/get_custom_pipelines';
import { getPipeline } from '../../lib/pipelines/get_pipeline';
Expand All @@ -43,7 +44,6 @@ import {
isResourceNotFoundException,
} from '../../utils/identify_exceptions';
import { getPrefixedInferencePipelineProcessorName } from '../../utils/ml_inference_pipeline_utils';
import { getMlInferenceErrors } from '../../lib/ml_inference_pipeline/get_inference_errors';

export function registerIndexRoutes({
router,
Expand Down Expand Up @@ -543,7 +543,7 @@ export function registerIndexRoutes({

return response.ok({
body: {
errors
errors,
},
headers: { 'content-type': 'application/json' },
});
Expand Down

0 comments on commit a10fb33

Please sign in to comment.