| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 | ["appendix",role="exclude",id="ml-time-functions"]= Time functionsThe time functions detect events that happen at unusual times, either of the dayor of the week. These functions can be used to find unusual patterns of behavior,typically associated with suspicious user activity.The {ml-features} include the following time functions:* <<ml-time-of-day,`time_of_day`>>* <<ml-time-of-week,`time_of_week`>>[NOTE]====* NOTE: You cannot create forecasts for {anomaly-jobs} that contain timefunctions. * The `time_of_day` function is not aware of the difference between days, forinstance work days and weekends. When modeling different days, use the`time_of_week` function. In general, the `time_of_week` function is more suitedto modeling the behavior of people rather than machines, as people vary theirbehavior according to the day of the week.* Shorter bucket spans (for example, 10 minutes) are recommended when performinga `time_of_day` or `time_of_week` analysis. The time of the events being modeledare not affected by the bucket span, but a shorter bucket span enables quickeralerting on unusual events.* Unusual events are flagged based on the previous pattern of the data, not onwhat we might think of as unusual based on human experience. So, if eventstypically occur between 3 a.m. and 5 a.m., an event occurring at 3 p.m. is flagged as unusual.* When Daylight Saving Time starts or stops, regular events can be flagged asanomalous. This situation occurs because the actual time of the event (asmeasured against a UTC baseline) has changed. This situation is treated as astep change in behavior and the new times will be learned quickly.====[discrete][[ml-time-of-day]]== Time_of_dayThe `time_of_day` function detects when events occur that are outside normalusage patterns. For example, it detects unusual activity in the middle of thenight.The function expects daily behavior to be similar. If you expect the behavior ofyour data to differ on Saturdays compared to Wednesdays, the `time_of_week`function is more appropriate.This function supports the following properties:* `by_field_name` (optional)* `over_field_name` (optional)* `partition_field_name` (optional)For more information about those properties, see the{ref}/ml-put-job.html#ml-put-job-request-body[create {anomaly-jobs} API]..Example 1: Analyzing events with the time_of_day function[source,js]--------------------------------------------------{  "function" : "time_of_day",  "by_field_name" : "process"}--------------------------------------------------// NOTCONSOLEIf you use this `time_of_day` function in a detector in your {anomaly-job}, itmodels when events occur throughout a day for each process. It detects when anevent occurs for a process that is at an unusual time in the day compared toits past behavior.[discrete][[ml-time-of-week]]== Time_of_weekThe `time_of_week` function detects when events occur that are outside normalusage patterns. For example, it detects login events on the weekend.This function supports the following properties:* `by_field_name` (optional)* `over_field_name` (optional)* `partition_field_name` (optional)For more information about those properties, see the{ref}/ml-put-job.html#ml-put-job-request-body[create {anomaly-jobs} API]..Example 2: Analyzing events with the time_of_week function[source,js]--------------------------------------------------{  "function" : "time_of_week",  "by_field_name" : "eventcode",  "over_field_name" : "workstation"}--------------------------------------------------// NOTCONSOLEIf you use this `time_of_week` function in a detector in your {anomaly-job}, itmodels when events occur throughout the week for each `eventcode`. It detectswhen a workstation event occurs at an unusual time during the week for that`eventcode` compared to other workstations. It detects events for aparticular workstation that are outside the normal usage pattern.
 |