2020-07-09 14:22:34 +02:00
/ *
* Copyright Elasticsearch B . V . and / or licensed to Elasticsearch B . V . under one
2021-02-04 03:12:39 +01:00
* or more contributor license agreements . Licensed under the Elastic License
* 2.0 ; you may not use this file except in compliance with the Elastic License
* 2.0 .
2020-07-09 14:22:34 +02:00
* /
2020-07-21 08:41:15 +02:00
import { i18n } from '@kbn/i18n' ;
2021-04-18 16:40:54 +02:00
import { ANOMALY_SEVERITY } from './ml_constants' ;
2020-09-18 14:02:37 +02:00
import {
getSeverityType ,
getSeverityColor as mlGetSeverityColor ,
} from '../../ml/common' ;
import { ServiceHealthStatus } from './service_health_status' ;
2020-07-21 08:41:15 +02:00
2020-07-09 14:22:34 +02:00
export interface ServiceAnomalyStats {
transactionType? : string ;
anomalyScore? : number ;
actualValue? : number ;
jobId? : string ;
2020-09-18 14:02:37 +02:00
healthStatus : ServiceHealthStatus ;
2020-07-09 14:22:34 +02:00
}
2020-07-21 08:41:15 +02:00
2020-09-18 14:02:37 +02:00
export function getSeverity ( score : number | undefined ) {
if ( score === undefined ) {
return ANOMALY_SEVERITY . UNKNOWN ;
2020-09-14 16:10:04 +02:00
}
2020-09-18 14:02:37 +02:00
return getSeverityType ( score ) ;
2020-09-14 16:10:04 +02:00
}
2020-09-18 14:02:37 +02:00
export function getSeverityColor ( score : number ) {
return mlGetSeverityColor ( score ) ;
2020-09-14 16:10:04 +02:00
}
2020-07-30 16:09:54 +02:00
export const ML_ERRORS = {
INVALID_LICENSE : i18n.translate (
'xpack.apm.anomaly_detection.error.invalid_license' ,
2020-07-21 08:41:15 +02:00
{
2020-07-30 16:09:54 +02:00
defaultMessage : ` To use anomaly detection, you must be subscribed to an Elastic Platinum license. With it, you'll be able to monitor your services with the aid of machine learning. ` ,
2020-07-21 08:41:15 +02:00
}
) ,
MISSING_READ_PRIVILEGES : i18n.translate (
'xpack.apm.anomaly_detection.error.missing_read_privileges' ,
{
defaultMessage :
2020-07-30 16:09:54 +02:00
'You must have "read" privileges to Machine Learning and APM in order to view Anomaly Detection jobs' ,
2020-07-21 08:41:15 +02:00
}
) ,
MISSING_WRITE_PRIVILEGES : i18n.translate (
'xpack.apm.anomaly_detection.error.missing_write_privileges' ,
{
defaultMessage :
'You must have "write" privileges to Machine Learning and APM in order to create Anomaly Detection jobs' ,
}
) ,
ML_NOT_AVAILABLE : i18n.translate (
'xpack.apm.anomaly_detection.error.not_available' ,
{
defaultMessage : 'Machine learning is not available' ,
}
) ,
ML_NOT_AVAILABLE_IN_SPACE : i18n.translate (
'xpack.apm.anomaly_detection.error.not_available_in_space' ,
{
defaultMessage : 'Machine learning is not available in the selected space' ,
}
) ,
} ;