ml-metric-functions.asciidoc 10 KB

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