get-calendar-event.asciidoc 4.2 KB

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