ml-time-functions.asciidoc 3.9 KB

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