mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
parent
e8ebaeb59a
commit
94fb794386
3 changed files with 61 additions and 1 deletions
|
@ -451,6 +451,18 @@ export const elasticsearchJsPlugin = (Client, config, components) => {
|
|||
method: 'POST',
|
||||
});
|
||||
|
||||
ml.records = ca({
|
||||
url: {
|
||||
fmt: '/_ml/anomaly_detectors/<%=jobId%>/results/records',
|
||||
req: {
|
||||
jobId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
ml.buckets = ca({
|
||||
urls: [
|
||||
{
|
||||
|
|
|
@ -376,11 +376,57 @@ export function jobRoutes({ xpackMainPlugin, router }: RouteInitialization) {
|
|||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @apiGroup AnomalyDetectors
|
||||
*
|
||||
* @api {post} /api/ml/anomaly_detectors/:jobId/results/records Retrieves anomaly records for a job.
|
||||
* @apiName GetRecords
|
||||
* @apiDescription Retrieves anomaly records for a job.
|
||||
*
|
||||
* @apiParam {String} jobId Job ID.
|
||||
*
|
||||
* @apiSuccess {Number} count
|
||||
* @apiSuccess {Object[]} records
|
||||
*/
|
||||
router.post(
|
||||
{
|
||||
path: '/api/ml/anomaly_detectors/{jobId}/results/records',
|
||||
validate: {
|
||||
params: schema.object({
|
||||
jobId: schema.string(),
|
||||
}),
|
||||
body: schema.object({
|
||||
desc: schema.maybe(schema.boolean()),
|
||||
end: schema.maybe(schema.string()),
|
||||
exclude_interim: schema.maybe(schema.boolean()),
|
||||
'page.from': schema.maybe(schema.number()),
|
||||
'page.size': schema.maybe(schema.number()),
|
||||
record_score: schema.maybe(schema.number()),
|
||||
sort: schema.maybe(schema.string()),
|
||||
start: schema.maybe(schema.string()),
|
||||
}),
|
||||
},
|
||||
},
|
||||
licensePreRoutingFactory(xpackMainPlugin, async (context, request, response) => {
|
||||
try {
|
||||
const results = await context.ml!.mlClient.callAsCurrentUser('ml.records', {
|
||||
jobId: request.params.jobId,
|
||||
...request.body,
|
||||
});
|
||||
return response.ok({
|
||||
body: results,
|
||||
});
|
||||
} catch (e) {
|
||||
return response.customError(wrapError(e));
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* @apiGroup AnomalyDetectors
|
||||
*
|
||||
* @api {post} /api/ml/anomaly_detectors/:jobId/results/buckets Obtain bucket scores for the specified job ID
|
||||
* @apiName GetOverallBuckets
|
||||
* @apiName GetBuckets
|
||||
* @apiDescription The get buckets API presents a chronological view of the records, grouped by bucket.
|
||||
*
|
||||
* @apiParam {String} jobId Job ID.
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
"DeleteAnomalyDetectorsJob",
|
||||
"ValidateAnomalyDetector",
|
||||
"ForecastAnomalyDetector",
|
||||
"GetRecords",
|
||||
"GetBuckets",
|
||||
"GetOverallBuckets",
|
||||
"GetCategories",
|
||||
"FileDataVisualizer",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue