ml-time-functions.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. [role="xpack"]
  2. [[ml-time-functions]]
  3. = Time functions
  4. The time functions detect events that happen at unusual times, either of the day
  5. or of the week. These functions can be used to find unusual patterns of behavior,
  6. typically associated with suspicious user activity.
  7. The {ml-features} include the following time functions:
  8. * <<ml-time-of-day,`time_of_day`>>
  9. * <<ml-time-of-week,`time_of_week`>>
  10. [NOTE]
  11. ====
  12. * NOTE: You cannot create forecasts for {anomaly-jobs} that contain time
  13. functions.
  14. * The `time_of_day` function is not aware of the difference between days, for
  15. instance work days and weekends. When modeling different days, use the
  16. `time_of_week` function. In general, the `time_of_week` function is more suited
  17. to modeling the behavior of people rather than machines, as people vary their
  18. behavior according to the day of the week.
  19. * Shorter bucket spans (for example, 10 minutes) are recommended when performing
  20. a `time_of_day` or `time_of_week` analysis. The time of the events being modeled
  21. are not affected by the bucket span, but a shorter bucket span enables quicker
  22. alerting on unusual events.
  23. * Unusual events are flagged based on the previous pattern of the data, not on
  24. what we might think of as unusual based on human experience. So, if events
  25. typically occur between 3 a.m. and 5 a.m., an event occurring at 3 p.m. is
  26. flagged as unusual.
  27. * When Daylight Saving Time starts or stops, regular events can be flagged as
  28. anomalous. This situation occurs because the actual time of the event (as
  29. measured against a UTC baseline) has changed. This situation is treated as a
  30. step change in behavior and the new times will be learned quickly.
  31. ====
  32. [discrete]
  33. [[ml-time-of-day]]
  34. == Time_of_day
  35. The `time_of_day` function detects when events occur that are outside normal
  36. usage patterns. For example, it detects unusual activity in the middle of the
  37. night.
  38. The function expects daily behavior to be similar. If you expect the behavior of
  39. your data to differ on Saturdays compared to Wednesdays, the `time_of_week`
  40. function is more appropriate.
  41. This function supports the following properties:
  42. * `by_field_name` (optional)
  43. * `over_field_name` (optional)
  44. * `partition_field_name` (optional)
  45. For more information about those properties, see the
  46. {ref}/ml-put-job.html#ml-put-job-request-body[create {anomaly-jobs} API].
  47. .Example 1: Analyzing events with the time_of_day function
  48. [source,js]
  49. --------------------------------------------------
  50. {
  51. "function" : "time_of_day",
  52. "by_field_name" : "process"
  53. }
  54. --------------------------------------------------
  55. // NOTCONSOLE
  56. If you use this `time_of_day` function in a detector in your {anomaly-job}, it
  57. models when events occur throughout a day for each process. It detects when an
  58. event occurs for a process that is at an unusual time in the day compared to
  59. its past behavior.
  60. [discrete]
  61. [[ml-time-of-week]]
  62. == Time_of_week
  63. The `time_of_week` function detects when events occur that are outside normal
  64. usage patterns. For example, it detects login events on the weekend.
  65. This function supports the following properties:
  66. * `by_field_name` (optional)
  67. * `over_field_name` (optional)
  68. * `partition_field_name` (optional)
  69. For more information about those properties, see the
  70. {ref}/ml-put-job.html#ml-put-job-request-body[create {anomaly-jobs} API].
  71. .Example 2: Analyzing events with the time_of_week function
  72. [source,js]
  73. --------------------------------------------------
  74. {
  75. "function" : "time_of_week",
  76. "by_field_name" : "eventcode",
  77. "over_field_name" : "workstation"
  78. }
  79. --------------------------------------------------
  80. // NOTCONSOLE
  81. If you use this `time_of_week` function in a detector in your {anomaly-job}, it
  82. models when events occur throughout the week for each `eventcode`. It detects
  83. when a workstation event occurs at an unusual time during the week for that
  84. `eventcode` compared to other workstations. It detects events for a
  85. particular workstation that are outside the normal usage pattern.