1
0

ml-sum-functions.asciidoc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. [role="xpack"]
  2. [[ml-sum-functions]]
  3. = Sum functions
  4. The sum functions detect anomalies when the sum of a field in a bucket is
  5. anomalous.
  6. If you want to monitor unusually high totals, use high-sided functions.
  7. If want to look at drops in totals, use low-sided functions.
  8. If your data is sparse, use `non_null_sum` functions. Buckets without values are
  9. ignored; buckets with a zero value are analyzed.
  10. The {ml-features} include the following sum functions:
  11. * xref:ml-sum[`sum`, `high_sum`, `low_sum`]
  12. * xref:ml-nonnull-sum[`non_null_sum`, `high_non_null_sum`, `low_non_null_sum`]
  13. [float]
  14. [[ml-sum]]
  15. == Sum, high_sum, low_sum
  16. The `sum` function detects anomalies where the sum of a field in a bucket is
  17. anomalous.
  18. If you want to monitor unusually high sum values, use the `high_sum` function.
  19. If you want to monitor unusually low sum values, use the `low_sum` function.
  20. These functions support the following properties:
  21. * `field_name` (required)
  22. * `by_field_name` (optional)
  23. * `over_field_name` (optional)
  24. * `partition_field_name` (optional)
  25. For more information about those properties, see the
  26. {ref}/ml-put-job.html#ml-put-job-request-body[create {anomaly-jobs} API].
  27. .Example 1: Analyzing total expenses with the sum function
  28. [source,js]
  29. --------------------------------------------------
  30. {
  31. "function" : "sum",
  32. "field_name" : "expenses",
  33. "by_field_name" : "costcenter",
  34. "over_field_name" : "employee"
  35. }
  36. --------------------------------------------------
  37. // NOTCONSOLE
  38. If you use this `sum` function in a detector in your {anomaly-job}, it
  39. models total expenses per employees for each cost center. For each time bucket,
  40. it detects when an employee’s expenses are unusual for a cost center compared
  41. to other employees.
  42. .Example 2: Analyzing total bytes with the high_sum function
  43. [source,js]
  44. --------------------------------------------------
  45. {
  46. "function" : "high_sum",
  47. "field_name" : "cs_bytes",
  48. "over_field_name" : "cs_host"
  49. }
  50. --------------------------------------------------
  51. // NOTCONSOLE
  52. If you use this `high_sum` function in a detector in your {anomaly-job}, it
  53. models total `cs_bytes`. It detects `cs_hosts` that transfer unusually high
  54. volumes compared to other `cs_hosts`. This example looks for volumes of data
  55. transferred from a client to a server on the internet that are unusual compared
  56. to other clients. This scenario could be useful to detect data exfiltration or
  57. to find users that are abusing internet privileges.
  58. [float]
  59. [[ml-nonnull-sum]]
  60. == Non_null_sum, high_non_null_sum, low_non_null_sum
  61. The `non_null_sum` function is useful if your data is sparse. Buckets without
  62. values are ignored and buckets with a zero value are analyzed.
  63. If you want to monitor unusually high totals, use the `high_non_null_sum`
  64. function.
  65. If you want to look at drops in totals, use the `low_non_null_sum` function.
  66. These functions support the following properties:
  67. * `field_name` (required)
  68. * `by_field_name` (optional)
  69. * `partition_field_name` (optional)
  70. For more information about those properties, see the
  71. {ref}/ml-put-job.html#ml-put-job-request-body[create {anomaly-jobs} API].
  72. NOTE: Population analysis (that is to say, use of the `over_field_name` property)
  73. is not applicable for this function.
  74. .Example 3: Analyzing employee approvals with the high_non_null_sum function
  75. [source,js]
  76. --------------------------------------------------
  77. {
  78. "function" : "high_non_null_sum",
  79. "fieldName" : "amount_approved",
  80. "byFieldName" : "employee"
  81. }
  82. --------------------------------------------------
  83. // NOTCONSOLE
  84. If you use this `high_non_null_sum` function in a detector in your {anomaly-job},
  85. it models the total `amount_approved` for each employee. It ignores any buckets
  86. where the amount is null. It detects employees who approve unusually high
  87. amounts compared to their past behavior.