time.asciidoc 3.9 KB

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