Add scheduled events to the calendar Generally available; Added in 6.2.0

POST /_ml/calendars/{calendar_id}/events

Required authorization

  • Cluster privileges: manage_ml

Path parameters

  • calendar_id string Required

    A string that uniquely identifies a calendar.

application/json

Body Required

  • events array[object] Required

    A list of one of more scheduled events. The event’s start and end times can be specified as integer milliseconds since the epoch or as a string in ISO 8601 format.

    Hide events attributes Show events attributes object
    • calendar_id string

      A string that uniquely identifies a calendar.

    • event_id string
    • description string Required

      A description of the scheduled event.

    • end_time string | number

      The timestamp for the end of the scheduled event in milliseconds since the epoch or ISO 8601 format.

      One of:

      The timestamp for the end of the scheduled event in milliseconds since the epoch or ISO 8601 format.

      The timestamp for the end of the scheduled event in milliseconds since the epoch or ISO 8601 format.

    • start_time string | number

      The timestamp for the beginning of the scheduled event in milliseconds since the epoch or ISO 8601 format.

      One of:

      The timestamp for the beginning of the scheduled event in milliseconds since the epoch or ISO 8601 format.

      The timestamp for the beginning of the scheduled event in milliseconds since the epoch or ISO 8601 format.

    • skip_result boolean

      When true the model will not create results for this calendar period.

      Default value is true.

    • skip_model_update boolean

      When true the model will not be updated for this calendar period.

      Default value is true.

    • force_time_shift number

      Shift time by this many seconds. For example adjust time for daylight savings changes

Responses

  • 200 application/json
    Hide response attribute Show response attribute object
    • events array[object] Required
      Hide events attributes Show events attributes object
      • calendar_id string

        A string that uniquely identifies a calendar.

      • event_id string
      • description string Required

        A description of the scheduled event.

      • end_time string | number

        The timestamp for the end of the scheduled event in milliseconds since the epoch or ISO 8601 format.

        One of:

        The timestamp for the end of the scheduled event in milliseconds since the epoch or ISO 8601 format.

        The timestamp for the end of the scheduled event in milliseconds since the epoch or ISO 8601 format.

      • start_time string | number

        The timestamp for the beginning of the scheduled event in milliseconds since the epoch or ISO 8601 format.

        One of:

        The timestamp for the beginning of the scheduled event in milliseconds since the epoch or ISO 8601 format.

        The timestamp for the beginning of the scheduled event in milliseconds since the epoch or ISO 8601 format.

      • skip_result boolean

        When true the model will not create results for this calendar period.

        Default value is true.

      • skip_model_update boolean

        When true the model will not be updated for this calendar period.

        Default value is true.

      • force_time_shift number

        Shift time by this many seconds. For example adjust time for daylight savings changes

POST /_ml/calendars/{calendar_id}/events
POST _ml/calendars/planned-outages/events
{
  "events" : [
    {"description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000},
    {"description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000},
    {"description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000}
  ]
}
resp = client.ml.post_calendar_events(
    calendar_id="planned-outages",
    events=[
        {
            "description": "event 1",
            "start_time": 1513641600000,
            "end_time": 1513728000000
        },
        {
            "description": "event 2",
            "start_time": 1513814400000,
            "end_time": 1513900800000
        },
        {
            "description": "event 3",
            "start_time": 1514160000000,
            "end_time": 1514246400000
        }
    ],
)
const response = await client.ml.postCalendarEvents({
  calendar_id: "planned-outages",
  events: [
    {
      description: "event 1",
      start_time: 1513641600000,
      end_time: 1513728000000,
    },
    {
      description: "event 2",
      start_time: 1513814400000,
      end_time: 1513900800000,
    },
    {
      description: "event 3",
      start_time: 1514160000000,
      end_time: 1514246400000,
    },
  ],
});
response = client.ml.post_calendar_events(
  calendar_id: "planned-outages",
  body: {
    "events": [
      {
        "description": "event 1",
        "start_time": 1513641600000,
        "end_time": 1513728000000
      },
      {
        "description": "event 2",
        "start_time": 1513814400000,
        "end_time": 1513900800000
      },
      {
        "description": "event 3",
        "start_time": 1514160000000,
        "end_time": 1514246400000
      }
    ]
  }
)
$resp = $client->ml()->postCalendarEvents([
    "calendar_id" => "planned-outages",
    "body" => [
        "events" => array(
            [
                "description" => "event 1",
                "start_time" => 1513641600000,
                "end_time" => 1513728000000,
            ],
            [
                "description" => "event 2",
                "start_time" => 1513814400000,
                "end_time" => 1513900800000,
            ],
            [
                "description" => "event 3",
                "start_time" => 1514160000000,
                "end_time" => 1514246400000,
            ],
        ),
    ],
]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"events":[{"description":"event 1","start_time":1513641600000,"end_time":1513728000000},{"description":"event 2","start_time":1513814400000,"end_time":1513900800000},{"description":"event 3","start_time":1514160000000,"end_time":1514246400000}]}' "$ELASTICSEARCH_URL/_ml/calendars/planned-outages/events"
client.ml().postCalendarEvents(p -> p
    .calendarId("planned-outages")
    .events(List.of(CalendarEvent.of(c -> c
            .description("event 1")
            .endTime(DateTime.ofEpochMilli(1513728000000L))
            .startTime(DateTime.ofEpochMilli(1513641600000L))),CalendarEvent.of(c -> c
            .description("event 2")
            .endTime(DateTime.ofEpochMilli(1513900800000L))
            .startTime(DateTime.ofEpochMilli(1513814400000L))),CalendarEvent.of(c -> c
            .description("event 3")
            .endTime(DateTime.ofEpochMilli(1514246400000L))
            .startTime(DateTime.ofEpochMilli(1514160000000L)))))
);
Request example
An example body for a `POST _ml/calendars/planned-outages/events` request.
{
  "events" : [
    {"description": "event 1", "start_time": 1513641600000, "end_time": 1513728000000},
    {"description": "event 2", "start_time": 1513814400000, "end_time": 1513900800000},
    {"description": "event 3", "start_time": 1514160000000, "end_time": 1514246400000}
  ]
}