metric.asciidoc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. [role="xpack"]
  2. [[ml-metric-functions]]
  3. === Metric functions
  4. The metric functions include functions such as mean, min and max. These values
  5. are calculated for each bucket. Field values that cannot be converted to
  6. double precision floating point numbers are ignored.
  7. The {ml-features} include the following metric functions:
  8. * <<ml-metric-min,`min`>>
  9. * <<ml-metric-max,`max`>>
  10. * xref:ml-metric-median[`median`, `high_median`, `low_median`]
  11. * xref:ml-metric-mean[`mean`, `high_mean`, `low_mean`]
  12. * <<ml-metric-metric,`metric`>>
  13. * xref:ml-metric-varp[`varp`, `high_varp`, `low_varp`]
  14. NOTE: You cannot add rules with conditions to detectors that use the `metric`
  15. function.
  16. [float]
  17. [[ml-metric-min]]
  18. ==== Min
  19. The `min` function detects anomalies in the arithmetic minimum of a value.
  20. The minimum value is calculated for each bucket.
  21. High- and low-sided functions are not applicable.
  22. This function supports the following properties:
  23. * `field_name` (required)
  24. * `by_field_name` (optional)
  25. * `over_field_name` (optional)
  26. * `partition_field_name` (optional)
  27. For more information about those properties, see
  28. {ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects].
  29. .Example 1: Analyzing minimum transactions with the min function
  30. [source,js]
  31. --------------------------------------------------
  32. {
  33. "function" : "min",
  34. "field_name" : "amt",
  35. "by_field_name" : "product"
  36. }
  37. --------------------------------------------------
  38. // NOTCONSOLE
  39. If you use this `min` function in a detector in your job, it detects where the
  40. smallest transaction is lower than previously observed. You can use this
  41. function to detect items for sale at unintentionally low prices due to data
  42. entry mistakes. It models the minimum amount for each product over time.
  43. [float]
  44. [[ml-metric-max]]
  45. ==== Max
  46. The `max` function detects anomalies in the arithmetic maximum of a value.
  47. The maximum value is calculated for each bucket.
  48. High- and low-sided functions are not applicable.
  49. This function supports the following properties:
  50. * `field_name` (required)
  51. * `by_field_name` (optional)
  52. * `over_field_name` (optional)
  53. * `partition_field_name` (optional)
  54. For more information about those properties, see
  55. {ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects].
  56. .Example 2: Analyzing maximum response times with the max function
  57. [source,js]
  58. --------------------------------------------------
  59. {
  60. "function" : "max",
  61. "field_name" : "responsetime",
  62. "by_field_name" : "application"
  63. }
  64. --------------------------------------------------
  65. // NOTCONSOLE
  66. If you use this `max` function in a detector in your job, it detects where the
  67. longest `responsetime` is longer than previously observed. You can use this
  68. function to detect applications that have `responsetime` values that are
  69. unusually lengthy. It models the maximum `responsetime` for each application
  70. over time and detects when the longest `responsetime` is unusually long compared
  71. to previous applications.
  72. .Example 3: Two detectors with max and high_mean functions
  73. [source,js]
  74. --------------------------------------------------
  75. {
  76. "function" : "max",
  77. "field_name" : "responsetime",
  78. "by_field_name" : "application"
  79. },
  80. {
  81. "function" : "high_mean",
  82. "field_name" : "responsetime",
  83. "by_field_name" : "application"
  84. }
  85. --------------------------------------------------
  86. // NOTCONSOLE
  87. The analysis in the previous example can be performed alongside `high_mean`
  88. functions by application. By combining detectors and using the same influencer
  89. this job can detect both unusually long individual response times and average
  90. response times for each bucket.
  91. [float]
  92. [[ml-metric-median]]
  93. ==== Median, high_median, low_median
  94. The `median` function detects anomalies in the statistical median of a value.
  95. The median value is calculated for each bucket.
  96. If you want to monitor unusually high median values, use the `high_median`
  97. function.
  98. If you are just interested in unusually low median values, use the `low_median`
  99. function.
  100. These functions support the following properties:
  101. * `field_name` (required)
  102. * `by_field_name` (optional)
  103. * `over_field_name` (optional)
  104. * `partition_field_name` (optional)
  105. For more information about those properties, see
  106. {ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects].
  107. .Example 4: Analyzing response times with the median function
  108. [source,js]
  109. --------------------------------------------------
  110. {
  111. "function" : "median",
  112. "field_name" : "responsetime",
  113. "by_field_name" : "application"
  114. }
  115. --------------------------------------------------
  116. // NOTCONSOLE
  117. If you use this `median` function in a detector in your job, it models the
  118. median `responsetime` for each application over time. It detects when the median
  119. `responsetime` is unusual compared to previous `responsetime` values.
  120. [float]
  121. [[ml-metric-mean]]
  122. ==== Mean, high_mean, low_mean
  123. The `mean` function detects anomalies in the arithmetic mean of a value.
  124. The mean value is calculated for each bucket.
  125. If you want to monitor unusually high average values, use the `high_mean`
  126. function.
  127. If you are just interested in unusually low average values, use the `low_mean`
  128. function.
  129. These functions support the following properties:
  130. * `field_name` (required)
  131. * `by_field_name` (optional)
  132. * `over_field_name` (optional)
  133. * `partition_field_name` (optional)
  134. For more information about those properties, see
  135. {ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects].
  136. .Example 5: Analyzing response times with the mean function
  137. [source,js]
  138. --------------------------------------------------
  139. {
  140. "function" : "mean",
  141. "field_name" : "responsetime",
  142. "by_field_name" : "application"
  143. }
  144. --------------------------------------------------
  145. // NOTCONSOLE
  146. If you use this `mean` function in a detector in your job, it models the mean
  147. `responsetime` for each application over time. It detects when the mean
  148. `responsetime` is unusual compared to previous `responsetime` values.
  149. .Example 6: Analyzing response times with the high_mean function
  150. [source,js]
  151. --------------------------------------------------
  152. {
  153. "function" : "high_mean",
  154. "field_name" : "responsetime",
  155. "by_field_name" : "application"
  156. }
  157. --------------------------------------------------
  158. // NOTCONSOLE
  159. If you use this `high_mean` function in a detector in your job, it models the
  160. mean `responsetime` for each application over time. It detects when the mean
  161. `responsetime` is unusually high compared to previous `responsetime` values.
  162. .Example 7: Analyzing response times with the low_mean function
  163. [source,js]
  164. --------------------------------------------------
  165. {
  166. "function" : "low_mean",
  167. "field_name" : "responsetime",
  168. "by_field_name" : "application"
  169. }
  170. --------------------------------------------------
  171. // NOTCONSOLE
  172. If you use this `low_mean` function in a detector in your job, it models the
  173. mean `responsetime` for each application over time. It detects when the mean
  174. `responsetime` is unusually low compared to previous `responsetime` values.
  175. [float]
  176. [[ml-metric-metric]]
  177. ==== Metric
  178. The `metric` function combines `min`, `max`, and `mean` functions. You can use
  179. it as a shorthand for a combined analysis. If you do not specify a function in
  180. a detector, this is the default function.
  181. High- and low-sided functions are not applicable. You cannot use this function
  182. when a `summary_count_field_name` is specified.
  183. This function supports the following properties:
  184. * `field_name` (required)
  185. * `by_field_name` (optional)
  186. * `over_field_name` (optional)
  187. * `partition_field_name` (optional)
  188. For more information about those properties, see
  189. {ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects].
  190. .Example 8: Analyzing response times with the metric function
  191. [source,js]
  192. --------------------------------------------------
  193. {
  194. "function" : "metric",
  195. "field_name" : "responsetime",
  196. "by_field_name" : "application"
  197. }
  198. --------------------------------------------------
  199. // NOTCONSOLE
  200. If you use this `metric` function in a detector in your job, it models the
  201. mean, min, and max `responsetime` for each application over time. It detects
  202. when the mean, min, or max `responsetime` is unusual compared to previous
  203. `responsetime` values.
  204. [float]
  205. [[ml-metric-varp]]
  206. ==== Varp, high_varp, low_varp
  207. The `varp` function detects anomalies in the variance of a value which is a
  208. measure of the variability and spread in the data.
  209. If you want to monitor unusually high variance, use the `high_varp` function.
  210. If you are just interested in unusually low variance, use the `low_varp` function.
  211. These functions support the following properties:
  212. * `field_name` (required)
  213. * `by_field_name` (optional)
  214. * `over_field_name` (optional)
  215. * `partition_field_name` (optional)
  216. For more information about those properties, see
  217. {ref}/ml-job-resource.html#ml-detectorconfig[Detector Configuration Objects].
  218. .Example 9: Analyzing response times with the varp function
  219. [source,js]
  220. --------------------------------------------------
  221. {
  222. "function" : "varp",
  223. "field_name" : "responsetime",
  224. "by_field_name" : "application"
  225. }
  226. --------------------------------------------------
  227. // NOTCONSOLE
  228. If you use this `varp` function in a detector in your job, it models the
  229. variance in values of `responsetime` for each application over time. It detects
  230. when the variance in `responsetime` is unusual compared to past application
  231. behavior.
  232. .Example 10: Analyzing response times with the high_varp function
  233. [source,js]
  234. --------------------------------------------------
  235. {
  236. "function" : "high_varp",
  237. "field_name" : "responsetime",
  238. "by_field_name" : "application"
  239. }
  240. --------------------------------------------------
  241. // NOTCONSOLE
  242. If you use this `high_varp` function in a detector in your job, it models the
  243. variance in values of `responsetime` for each application over time. It detects
  244. when the variance in `responsetime` is unusual compared to past application
  245. behavior.
  246. .Example 11: Analyzing response times with the low_varp function
  247. [source,js]
  248. --------------------------------------------------
  249. {
  250. "function" : "low_varp",
  251. "field_name" : "responsetime",
  252. "by_field_name" : "application"
  253. }
  254. --------------------------------------------------
  255. // NOTCONSOLE
  256. If you use this `low_varp` function in a detector in your job, it models the
  257. variance in values of `responsetime` for each application over time. It detects
  258. when the variance in `responsetime` is unusual compared to past application
  259. behavior.