| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 | [role="xpack"][[ml-metric-functions]]=== Metric functionsThe metric functions include functions such as mean, min and max. These valuesare calculated for each bucket. Field values that cannot be converted todouble precision floating point numbers are ignored.The {xpackml} features include the following metric functions:* <<ml-metric-min,`min`>>* <<ml-metric-max,`max`>>* xref:ml-metric-median[`median`, `high_median`, `low_median`]* xref:ml-metric-mean[`mean`, `high_mean`, `low_mean`]* <<ml-metric-metric,`metric`>>* xref:ml-metric-varp[`varp`, `high_varp`, `low_varp`]NOTE: You cannot add rules with conditions to detectors that use the `metric` function. [float][[ml-metric-min]]==== MinThe `min` function detects anomalies in the arithmetic minimum of a value.The minimum value is calculated for each bucket.High- and low-sided functions are not applicable.This function supports the following properties:* `field_name` (required)* `by_field_name` (optional)* `over_field_name` (optional)* `partition_field_name` (optional)For more information about those properties, see{ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects]..Example 1: Analyzing minimum transactions with the min function[source,js]--------------------------------------------------{  "function" : "min",  "field_name" : "amt",  "by_field_name" : "product"}--------------------------------------------------// NOTCONSOLEIf you use this `min` function in a detector in your job, it detects where thesmallest transaction is lower than previously observed. You can use thisfunction to detect items for sale at unintentionally low prices due to dataentry mistakes. It models the minimum amount for each product over time.[float][[ml-metric-max]]==== MaxThe `max` function detects anomalies in the arithmetic maximum of a value.The maximum value is calculated for each bucket.High- and low-sided functions are not applicable.This function supports the following properties:* `field_name` (required)* `by_field_name` (optional)* `over_field_name` (optional)* `partition_field_name` (optional)For more information about those properties, see{ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects]..Example 2: Analyzing maximum response times with the max function[source,js]--------------------------------------------------{  "function" : "max",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEIf you use this `max` function in a detector in your job, it detects where thelongest `responsetime` is longer than previously observed. You can use thisfunction to detect applications that have `responsetime` values that areunusually lengthy. It models the maximum `responsetime` for each applicationover time and detects when the longest `responsetime` is unusually long comparedto previous applications..Example 3: Two detectors with max and high_mean functions[source,js]--------------------------------------------------{  "function" : "max",  "field_name" : "responsetime",  "by_field_name" : "application"},{  "function" : "high_mean",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEThe analysis in the previous example can be performed alongside `high_mean`functions by application. By combining detectors and using the same influencerthis job can detect both unusually long individual response times and averageresponse times for each bucket.[float][[ml-metric-median]]==== Median, high_median, low_medianThe `median` function detects anomalies in the statistical median of a value.The median value is calculated for each bucket.If you want to monitor unusually high median values, use the `high_median`function.If you are just interested in unusually low median values, use the `low_median`function.These functions support the following properties:* `field_name` (required)* `by_field_name` (optional)* `over_field_name` (optional)* `partition_field_name` (optional)For more information about those properties, see{ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects]..Example 4: Analyzing response times with the median function[source,js]--------------------------------------------------{  "function" : "median",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEIf you use this `median` function in a detector in your job, it models themedian `responsetime` for each application over time. It detects when the median`responsetime` is unusual compared to previous `responsetime` values.[float][[ml-metric-mean]]==== Mean, high_mean, low_meanThe `mean` function detects anomalies in the arithmetic mean of a value.The mean value is calculated for each bucket.If you want to monitor unusually high average values, use the `high_mean`function.If you are just interested in unusually low average values, use the `low_mean`function.These functions support the following properties:* `field_name` (required)* `by_field_name` (optional)* `over_field_name` (optional)* `partition_field_name` (optional)For more information about those properties, see{ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects]..Example 5: Analyzing response times with the mean function[source,js]--------------------------------------------------{  "function" : "mean",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEIf you use this `mean` function in a detector in your job, it models the mean`responsetime` for each application over time. It detects when the mean`responsetime` is unusual compared to previous `responsetime` values..Example 6: Analyzing response times with the high_mean function[source,js]--------------------------------------------------{  "function" : "high_mean",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEIf you use this `high_mean` function in a detector in your job, it models themean `responsetime` for each application over time. It detects when the mean`responsetime` is unusually high compared to previous `responsetime` values..Example 7: Analyzing response times with the low_mean function[source,js]--------------------------------------------------{  "function" : "low_mean",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEIf you use this `low_mean` function in a detector in your job, it models themean `responsetime` for each application over time. It detects when the mean`responsetime` is unusually low compared to previous `responsetime` values.[float][[ml-metric-metric]]==== MetricThe `metric` function combines `min`, `max`, and `mean` functions. You can useit as a shorthand for a combined analysis. If you do not specify a function ina detector, this is the default function.High- and low-sided functions are not applicable. You cannot use this functionwhen a `summary_count_field_name` is specified.This function supports the following properties:* `field_name` (required)* `by_field_name` (optional)* `over_field_name` (optional)* `partition_field_name` (optional)For more information about those properties, see{ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects]..Example 8: Analyzing response times with the metric function[source,js]--------------------------------------------------{  "function" : "metric",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEIf you use this `metric` function in a detector in your job, it models themean, min, and max `responsetime` for each application over time. It detectswhen the mean, min, or max `responsetime` is unusual compared to previous`responsetime` values.[float][[ml-metric-varp]]==== Varp, high_varp, low_varpThe `varp` function detects anomalies in the variance of a value which is ameasure of the variability and spread in the data.If you want to monitor unusually high variance, use the `high_varp` function.If you are just interested in unusually low variance, use the `low_varp` function.These functions support the following properties:* `field_name` (required)* `by_field_name` (optional)* `over_field_name` (optional)* `partition_field_name` (optional)For more information about those properties, see{ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects]..Example 9: Analyzing response times with the varp function[source,js]--------------------------------------------------{  "function" : "varp",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEIf you use this `varp` function in a detector in your job, it models thevariance in values of `responsetime` for each application over time. It detectswhen the variance in `responsetime` is unusual compared to past applicationbehavior..Example 10: Analyzing response times with the high_varp function[source,js]--------------------------------------------------{  "function" : "high_varp",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEIf you use this `high_varp` function in a detector in your job, it models thevariance in values of `responsetime` for each application over time. It detectswhen the variance in `responsetime` is unusual compared to past applicationbehavior..Example 11: Analyzing response times with the low_varp function[source,js]--------------------------------------------------{  "function" : "low_varp",  "field_name" : "responsetime",  "by_field_name" : "application"}--------------------------------------------------// NOTCONSOLEIf you use this `low_varp` function in a detector in your job, it models thevariance in values of `responsetime` for each application over time. It detectswhen the variance in `responsetime` is unusual compared to past applicationbehavior.
 |