get-calendar-event.asciidoc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-get-calendar-event]]
  4. = Get scheduled events API
  5. ++++
  6. <titleabbrev>Get scheduled events</titleabbrev>
  7. ++++
  8. Retrieves information about the scheduled events in calendars.
  9. [[ml-get-calendar-event-request]]
  10. == {api-request-title}
  11. `GET _ml/calendars/<calendar_id>/events` +
  12. `GET _ml/calendars/_all/events`
  13. [[ml-get-calendar-event-prereqs]]
  14. == {api-prereq-title}
  15. Requires the `monitor_ml` cluster privilege. This privilege is included in the
  16. `machine_learning_user` built-in role.
  17. [[ml-get-calendar-event-desc]]
  18. == {api-description-title}
  19. You can get scheduled event information for multiple calendars in a single
  20. API request by using a comma-separated list of ids or a wildcard expression.
  21. You can get scheduled event information for all calendars by using `_all` or `*`
  22. as the `<calendar_id>`.
  23. For more information, see
  24. {ml-docs}/ml-ad-finding-anomalies.html#ml-ad-calendars[Calendars and scheduled events].
  25. [[ml-get-calendar-event-path-parms]]
  26. == {api-path-parms-title}
  27. `<calendar_id>`::
  28. (Required, string)
  29. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=calendar-id]
  30. [[ml-get-calendar-event-query-parms]]
  31. == {api-query-parms-title}
  32. `end`::
  33. (Optional, string) Specifies to get events with timestamps earlier than this
  34. time.
  35. `from`::
  36. (Optional, integer) Skips the specified number of events. Defaults to `0`.
  37. `job_id`::
  38. (Optional, string) Specifies to get events for a specific {anomaly-job}
  39. identifier or job group. It must be used with a calendar identifier of `_all`
  40. or `*`.
  41. `size`::
  42. (Optional, integer) Specifies the maximum number of events to obtain. Defaults
  43. to `100`.
  44. `start`::
  45. (Optional, string) Specifies to get events with timestamps after this time.
  46. [[ml-get-calendar-event-request-body]]
  47. == {api-request-body-title}
  48. `end`::
  49. (Optional, string) Specifies to get events with timestamps earlier than this
  50. time. Defaults to unset, which means results are not
  51. limited to specific timestamps.
  52. `job_id`::
  53. (Optional, string) Specifies to get events for a specific {anomaly-job}
  54. identifier or job group. It must be used with a calendar identifier of `_all`
  55. or `*`.
  56. `page.from`::
  57. (Optional, integer) Skips the specified number of events. Defaults to `0`.
  58. `page.size`::
  59. (Optional, integer) Specifies the maximum number of events to obtain.
  60. Defaults to `100`.
  61. `start`::
  62. (Optional, string) Specifies to get events with timestamps after this time.
  63. Defaults to unset, which means results are not limited to specific
  64. timestamps.
  65. [[ml-get-calendar-event-results]]
  66. == {api-response-body-title}
  67. The API returns an array of scheduled event resources, which have the
  68. following properties:
  69. `calendar_id`::
  70. (string)
  71. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=calendar-id]
  72. `description`::
  73. (string) A description of the scheduled event.
  74. `end_time`::
  75. (date) The timestamp for the end of the scheduled event in milliseconds since
  76. the epoch or ISO 8601 format.
  77. `event_id`::
  78. (string) An automatically-generated identifier for the scheduled event.
  79. `start_time`::
  80. (date) The timestamp for the beginning of the scheduled event in milliseconds
  81. since the epoch or ISO 8601 format.
  82. [[ml-get-calendar-event-example]]
  83. == {api-examples-title}
  84. [source,console]
  85. --------------------------------------------------
  86. GET _ml/calendars/planned-outages/events
  87. --------------------------------------------------
  88. // TEST[skip:setup:calendar_outages_addevent]
  89. The API returns the following results:
  90. [source,console-result]
  91. ----
  92. {
  93. "count": 3,
  94. "events": [
  95. {
  96. "description": "event 1",
  97. "start_time": 1513641600000,
  98. "end_time": 1513728000000,
  99. "calendar_id": "planned-outages",
  100. "event_id": "LS8LJGEBMTCMA-qz49st"
  101. },
  102. {
  103. "description": "event 2",
  104. "start_time": 1513814400000,
  105. "end_time": 1513900800000,
  106. "calendar_id": "planned-outages",
  107. "event_id": "Li8LJGEBMTCMA-qz49st"
  108. },
  109. {
  110. "description": "event 3",
  111. "start_time": 1514160000000,
  112. "end_time": 1514246400000,
  113. "calendar_id": "planned-outages",
  114. "event_id": "Ly8LJGEBMTCMA-qz49st"
  115. }
  116. ]
  117. }
  118. ----
  119. // TESTRESPONSE[s/LS8LJGEBMTCMA-qz49st/$body.$_path/]
  120. // TESTRESPONSE[s/Li8LJGEBMTCMA-qz49st/$body.$_path/]
  121. // TESTRESPONSE[s/Ly8LJGEBMTCMA-qz49st/$body.$_path/]
  122. The following example retrieves scheduled events that occur within a specific
  123. period of time:
  124. [source,console]
  125. --------------------------------------------------
  126. GET _ml/*/planned-outages/events?start=1635638400000&end=1635724800000
  127. --------------------------------------------------
  128. // TEST[skip:setup:calendar_outages_addevent]