Language

Datadog Site

Site help

Downtimes

Les downtimes vous permettent de mieux contrôler les notifications d’un contrôleur en empêchant certains contextes de déclencher des alertes. Les paramètres de downtime, qui peuvent être planifiés avec une heure de début et de fin, désactivent toutes les notifications liées à des tags Datadog.

GET https://api.ap1.datadoghq.com/api/v1/downtimehttps://api.datadoghq.eu/api/v1/downtimehttps://api.ddog-gov.com/api/v1/downtimehttps://api.datadoghq.com/api/v1/downtimehttps://api.us3.datadoghq.com/api/v1/downtimehttps://api.us5.datadoghq.com/api/v1/downtime

Présentation

Récupérez tous les downtimes planifiés. This endpoint requires the monitors_read authorization scope.

Arguments

Chaînes de requête

Nom

Type

Description

current_only

boolean

Only return downtimes that are active when the request is made.

with_creator

boolean

Return creator information.

Réponse

OK

Expand All

Champ

Type

Description

active

boolean

If a scheduled downtime currently exists.

active_child

object

The downtime object definition of the active child for the original parent recurring downtime. This field will only exist on recurring downtimes.

active

boolean

If a scheduled downtime currently exists.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

{
  "active": true,
  "active_child": {
    "active": true,
    "canceled": 1412799983,
    "creator_id": 123456,
    "disabled": false,
    "downtime_type": 2,
    "end": 1412793983,
    "id": 1626,
    "message": "Message on the downtime",
    "monitor_id": 123456,
    "monitor_tags": [
      "*"
    ],
    "mute_first_recovery_notification": false,
    "notify_end_states": [
      "alert",
      "no data",
      "warn"
    ],
    "notify_end_types": [
      "canceled",
      "expired"
    ],
    "parent_id": 123,
    "recurrence": {
      "period": 1,
      "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
      "type": "weeks",
      "until_date": 1447786293,
      "until_occurrences": 2,
      "week_days": [
        "Mon",
        "Tue"
      ]
    },
    "scope": [
      "env:staging"
    ],
    "start": 1412792983,
    "timezone": "America/New_York",
    "updater_id": 123456
  },
  "canceled": 1412799983,
  "creator_id": 123456,
  "disabled": false,
  "downtime_type": 2,
  "end": 1412793983,
  "id": 1625,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "mute_first_recovery_notification": false,
  "notify_end_states": [
    "alert",
    "no data",
    "warn"
  ],
  "notify_end_types": [
    "canceled",
    "expired"
  ],
  "parent_id": 123,
  "recurrence": {
    "period": 1,
    "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
    "type": "weeks",
    "until_date": 1447786293,
    "until_occurrences": 2,
    "week_days": [
      "Mon",
      "Tue"
    ]
  },
  "scope": [
    "env:staging"
  ],
  "start": 1412792983,
  "timezone": "America/New_York",
  "updater_id": 123456
}

Forbidden

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/downtime" \ -H "Accept: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get all downtimes returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.downtimes_api import DowntimesApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DowntimesApi(api_client)
    response = api_instance.list_downtimes(
        with_creator=True,
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get all downtimes returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DowntimesAPI.new
opts = {
  with_creator: true,
}
p api_instance.list_downtimes(opts)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Get all downtimes
dog.get_all_downtimes

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Get all downtimes returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDowntimesApi(apiClient)
	resp, r, err := api.ListDowntimes(ctx, *datadogV1.NewListDowntimesOptionalParameters().WithWithCreator(true))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DowntimesApi.ListDowntimes`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.ListDowntimes`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get all downtimes returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DowntimesApi;
import com.datadog.api.client.v1.api.DowntimesApi.ListDowntimesOptionalParameters;
import com.datadog.api.client.v1.model.Downtime;
import java.util.List;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DowntimesApi apiInstance = new DowntimesApi(defaultClient);

    try {
      List<Downtime> result =
          apiInstance.listDowntimes(new ListDowntimesOptionalParameters().withCreator(true));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#listDowntimes");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Get all downtimes
print(api.Downtime.get_all())

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
/**
 * Get all downtimes returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DowntimesApi(configuration);

const params: v1.DowntimesApiListDowntimesRequest = {
  withCreator: true,
};

apiInstance
  .listDowntimes(params)
  .then((data: v1.Downtime[]) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"

POST https://api.ap1.datadoghq.com/api/v1/downtimehttps://api.datadoghq.eu/api/v1/downtimehttps://api.ddog-gov.com/api/v1/downtimehttps://api.datadoghq.com/api/v1/downtimehttps://api.us3.datadoghq.com/api/v1/downtimehttps://api.us5.datadoghq.com/api/v1/downtime

Présentation

Planifiez un downtime. This endpoint requires the monitors_downtime authorization scope.

Requête

Body Data (required)

Corps de requête pour la planification d’un downtime.

Expand All

Champ

Type

Description

active

boolean

If a scheduled downtime currently exists.

active_child

object

The downtime object definition of the active child for the original parent recurring downtime. This field will only exist on recurring downtimes.

active

boolean

If a scheduled downtime currently exists.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

{
  "message": "Example-Downtime",
  "recurrence": {
    "period": 1,
    "type": "years"
  },
  "scope": [
    "*"
  ],
  "start": 1636629071,
  "end": 1636632671,
  "timezone": "Etc/UTC",
  "mute_first_recovery_notification": true,
  "monitor_tags": [
    "tag0"
  ],
  "notify_end_states": [
    "alert",
    "warn"
  ],
  "notify_end_types": [
    "expired"
  ]
}
{
  "message": "Example-Downtime",
  "start": 1636629071,
  "end": 1636632671,
  "timezone": "Etc/UTC",
  "scope": [
    "test:exampledowntime"
  ],
  "recurrence": {
    "type": "weeks",
    "period": 1,
    "week_days": [
      "Mon",
      "Tue",
      "Wed",
      "Thu",
      "Fri"
    ],
    "until_date": 1638443471
  },
  "notify_end_states": [
    "alert",
    "no data",
    "warn"
  ],
  "notify_end_types": [
    "canceled",
    "expired"
  ]
}
{
  "message": "Example-Downtime",
  "recurrence": {
    "period": 1,
    "type": "weeks",
    "until_date": 1638443471,
    "week_days": [
      "Mon",
      "Tue",
      "Wed",
      "Thu",
      "Fri"
    ]
  },
  "scope": [
    "*"
  ],
  "start": 1636629071,
  "end": 1636632671,
  "timezone": "Etc/UTC",
  "mute_first_recovery_notification": true,
  "monitor_tags": [
    "tag0"
  ],
  "notify_end_states": [
    "alert"
  ],
  "notify_end_types": [
    "canceled"
  ]
}

Réponse

OK

Downtiming gives you greater control over monitor notifications by allowing you to globally exclude scopes from alerting. Downtime settings, which can be scheduled with start and end times, prevent all alerting related to specified Datadog tags.

Expand All

Champ

Type

Description

active

boolean

If a scheduled downtime currently exists.

active_child

object

The downtime object definition of the active child for the original parent recurring downtime. This field will only exist on recurring downtimes.

active

boolean

If a scheduled downtime currently exists.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

{
  "active": true,
  "active_child": {
    "active": true,
    "canceled": 1412799983,
    "creator_id": 123456,
    "disabled": false,
    "downtime_type": 2,
    "end": 1412793983,
    "id": 1626,
    "message": "Message on the downtime",
    "monitor_id": 123456,
    "monitor_tags": [
      "*"
    ],
    "mute_first_recovery_notification": false,
    "notify_end_states": [
      "alert",
      "no data",
      "warn"
    ],
    "notify_end_types": [
      "canceled",
      "expired"
    ],
    "parent_id": 123,
    "recurrence": {
      "period": 1,
      "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
      "type": "weeks",
      "until_date": 1447786293,
      "until_occurrences": 2,
      "week_days": [
        "Mon",
        "Tue"
      ]
    },
    "scope": [
      "env:staging"
    ],
    "start": 1412792983,
    "timezone": "America/New_York",
    "updater_id": 123456
  },
  "canceled": 1412799983,
  "creator_id": 123456,
  "disabled": false,
  "downtime_type": 2,
  "end": 1412793983,
  "id": 1625,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "mute_first_recovery_notification": false,
  "notify_end_states": [
    "alert",
    "no data",
    "warn"
  ],
  "notify_end_types": [
    "canceled",
    "expired"
  ],
  "parent_id": 123,
  "recurrence": {
    "period": 1,
    "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
    "type": "weeks",
    "until_date": 1447786293,
    "until_occurrences": 2,
    "week_days": [
      "Mon",
      "Tue"
    ]
  },
  "scope": [
    "env:staging"
  ],
  "start": 1412792983,
  "timezone": "America/New_York",
  "updater_id": 123456
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code

  
  # Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/downtime" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "message": "Example-Downtime", "recurrence": { "period": 1, "type": "years" }, "scope": [ "*" ], "start": 1636629071, "end": 1636632671, "timezone": "Etc/UTC", "mute_first_recovery_notification": true, "monitor_tags": [ "tag0" ], "notify_end_states": [ "alert", "warn" ], "notify_end_types": [ "expired" ] } EOF
  
  # Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/downtime" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "message": "Example-Downtime", "start": 1636629071, "end": 1636632671, "timezone": "Etc/UTC", "scope": [ "test:exampledowntime" ], "recurrence": { "type": "weeks", "period": 1, "week_days": [ "Mon", "Tue", "Wed", "Thu", "Fri" ], "until_date": 1638443471 }, "notify_end_states": [ "alert", "no data", "warn" ], "notify_end_types": [ "canceled", "expired" ] } EOF
  
  # Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/downtime" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "message": "Example-Downtime", "recurrence": { "period": 1, "type": "weeks", "until_date": 1638443471, "week_days": [ "Mon", "Tue", "Wed", "Thu", "Fri" ] }, "scope": [ "*" ], "start": 1636629071, "end": 1636632671, "timezone": "Etc/UTC", "mute_first_recovery_notification": true, "monitor_tags": [ "tag0" ], "notify_end_states": [ "alert" ], "notify_end_types": [ "canceled" ] } EOF
// Schedule a downtime once a year

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	body := datadogV1.Downtime{
		Message: *datadog.NewNullableString(datadog.PtrString("Example-Downtime")),
		Recurrence: *datadogV1.NewNullableDowntimeRecurrence(&datadogV1.DowntimeRecurrence{
			Period: datadog.PtrInt32(1),
			Type:   datadog.PtrString("years"),
		}),
		Scope: []string{
			"*",
		},
		Start:                         datadog.PtrInt64(time.Now().Unix()),
		End:                           *datadog.NewNullableInt64(datadog.PtrInt64(time.Now().Add(time.Hour * 1).Unix())),
		Timezone:                      datadog.PtrString("Etc/UTC"),
		MuteFirstRecoveryNotification: datadog.PtrBool(true),
		MonitorTags: []string{
			"tag0",
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDowntimesApi(apiClient)
	resp, r, err := api.CreateDowntime(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DowntimesApi.CreateDowntime`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.CreateDowntime`:\n%s\n", responseContent)
}
// Schedule a downtime returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	body := datadogV1.Downtime{
		Message:  *datadog.NewNullableString(datadog.PtrString("Example-Downtime")),
		Start:    datadog.PtrInt64(time.Now().Unix()),
		Timezone: datadog.PtrString("Etc/UTC"),
		Scope: []string{
			"test:exampledowntime",
		},
		Recurrence: *datadogV1.NewNullableDowntimeRecurrence(&datadogV1.DowntimeRecurrence{
			Type:   datadog.PtrString("weeks"),
			Period: datadog.PtrInt32(1),
			WeekDays: []string{
				"Mon",
				"Tue",
				"Wed",
				"Thu",
				"Fri",
			},
			UntilDate: *datadog.NewNullableInt64(datadog.PtrInt64(time.Now().AddDate(0, 0, 21).Unix())),
		}),
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDowntimesApi(apiClient)
	resp, r, err := api.CreateDowntime(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DowntimesApi.CreateDowntime`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.CreateDowntime`:\n%s\n", responseContent)
}
// Schedule a downtime until date

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	body := datadogV1.Downtime{
		Message: *datadog.NewNullableString(datadog.PtrString("Example-Downtime")),
		Recurrence: *datadogV1.NewNullableDowntimeRecurrence(&datadogV1.DowntimeRecurrence{
			Period:    datadog.PtrInt32(1),
			Type:      datadog.PtrString("weeks"),
			UntilDate: *datadog.NewNullableInt64(datadog.PtrInt64(time.Now().AddDate(0, 0, 21).Unix())),
			WeekDays: []string{
				"Mon",
				"Tue",
				"Wed",
				"Thu",
				"Fri",
			},
		}),
		Scope: []string{
			"*",
		},
		Start:                         datadog.PtrInt64(time.Now().Unix()),
		End:                           *datadog.NewNullableInt64(datadog.PtrInt64(time.Now().Add(time.Hour * 1).Unix())),
		Timezone:                      datadog.PtrString("Etc/UTC"),
		MuteFirstRecoveryNotification: datadog.PtrBool(true),
		MonitorTags: []string{
			"tag0",
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDowntimesApi(apiClient)
	resp, r, err := api.CreateDowntime(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DowntimesApi.CreateDowntime`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.CreateDowntime`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Schedule a downtime once a year
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DowntimesApi;
import com.datadog.api.client.v1.model.Downtime;
import com.datadog.api.client.v1.model.DowntimeRecurrence;
import java.time.OffsetDateTime;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DowntimesApi apiInstance = new DowntimesApi(defaultClient);

    Downtime body =
        new Downtime()
            .message("Example-Downtime")
            .recurrence(new DowntimeRecurrence().period(1).type("years"))
            .scope(Collections.singletonList("*"))
            .start(OffsetDateTime.now().toInstant().getEpochSecond())
            .end(OffsetDateTime.now().plusHours(1).toInstant().getEpochSecond())
            .timezone("Etc/UTC")
            .muteFirstRecoveryNotification(true)
            .monitorTags(Collections.singletonList("tag0"));

    try {
      Downtime result = apiInstance.createDowntime(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#createDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
// Schedule a downtime returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DowntimesApi;
import com.datadog.api.client.v1.model.Downtime;
import com.datadog.api.client.v1.model.DowntimeRecurrence;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DowntimesApi apiInstance = new DowntimesApi(defaultClient);

    Downtime body =
        new Downtime()
            .message("Example-Downtime")
            .start(OffsetDateTime.now().toInstant().getEpochSecond())
            .timezone("Etc/UTC")
            .scope(Collections.singletonList("test:exampledowntime"))
            .recurrence(
                new DowntimeRecurrence()
                    .type("weeks")
                    .period(1)
                    .weekDays(Arrays.asList("Mon", "Tue", "Wed", "Thu", "Fri"))
                    .untilDate(OffsetDateTime.now().plusDays(21).toInstant().getEpochSecond()));

    try {
      Downtime result = apiInstance.createDowntime(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#createDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
// Schedule a downtime until date
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DowntimesApi;
import com.datadog.api.client.v1.model.Downtime;
import com.datadog.api.client.v1.model.DowntimeRecurrence;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DowntimesApi apiInstance = new DowntimesApi(defaultClient);

    Downtime body =
        new Downtime()
            .message("Example-Downtime")
            .recurrence(
                new DowntimeRecurrence()
                    .period(1)
                    .type("weeks")
                    .untilDate(OffsetDateTime.now().plusDays(21).toInstant().getEpochSecond())
                    .weekDays(Arrays.asList("Mon", "Tue", "Wed", "Thu", "Fri")))
            .scope(Collections.singletonList("*"))
            .start(OffsetDateTime.now().toInstant().getEpochSecond())
            .end(OffsetDateTime.now().plusHours(1).toInstant().getEpochSecond())
            .timezone("Etc/UTC")
            .muteFirstRecoveryNotification(true)
            .monitorTags(Collections.singletonList("tag0"));

    try {
      Downtime result = apiInstance.createDowntime(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#createDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api
import time

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Repeat for 3 hours (starting now) on every week day for 4 weeks.
start_ts = int(time.time())
end_ts = start_ts + (3 * 60 * 60)
end_reccurrence_ts = start_ts + (4 * 7 * 24 * 60 * 60)  # 4 weeks from now

recurrence = {
    'type': 'weeks',
    'period': 1,
    'week_days': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
    'until_date': end_reccurrence_ts
}

# Schedule downtime
api.Downtime.create(
    scope='env:staging',
    start=start_ts,
    end=end_ts,
    recurrence=recurrence
)

# OR use RRULE reccurence
rrule_recurrence = {
    'type': 'rrule',
    'rrule': 'FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1',
}

# Schedule downtime
api.Downtime.create(
    scope='env:staging',
    start=start_ts,
    end=end_ts,
    recurrence=rrule_recurrence
)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
"""
Schedule a downtime once a year
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.downtimes_api import DowntimesApi
from datadog_api_client.v1.model.downtime import Downtime
from datadog_api_client.v1.model.downtime_recurrence import DowntimeRecurrence

body = Downtime(
    message="Example-Downtime",
    recurrence=DowntimeRecurrence(
        period=1,
        type="years",
    ),
    scope=[
        "*",
    ],
    start=int(datetime.now().timestamp()),
    end=int((datetime.now() + relativedelta(hours=1)).timestamp()),
    timezone="Etc/UTC",
    mute_first_recovery_notification=True,
    monitor_tags=[
        "tag0",
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DowntimesApi(api_client)
    response = api_instance.create_downtime(body=body)

    print(response)
"""
Schedule a downtime returns "OK" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.downtimes_api import DowntimesApi
from datadog_api_client.v1.model.downtime import Downtime
from datadog_api_client.v1.model.downtime_recurrence import DowntimeRecurrence

body = Downtime(
    message="Example-Downtime",
    start=int(datetime.now().timestamp()),
    timezone="Etc/UTC",
    scope=[
        "test:exampledowntime",
    ],
    recurrence=DowntimeRecurrence(
        type="weeks",
        period=1,
        week_days=[
            "Mon",
            "Tue",
            "Wed",
            "Thu",
            "Fri",
        ],
        until_date=int((datetime.now() + relativedelta(days=21)).timestamp()),
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DowntimesApi(api_client)
    response = api_instance.create_downtime(body=body)

    print(response)
"""
Schedule a downtime until date
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.downtimes_api import DowntimesApi
from datadog_api_client.v1.model.downtime import Downtime
from datadog_api_client.v1.model.downtime_recurrence import DowntimeRecurrence

body = Downtime(
    message="Example-Downtime",
    recurrence=DowntimeRecurrence(
        period=1,
        type="weeks",
        until_date=int((datetime.now() + relativedelta(days=21)).timestamp()),
        week_days=[
            "Mon",
            "Tue",
            "Wed",
            "Thu",
            "Fri",
        ],
    ),
    scope=[
        "*",
    ],
    start=int(datetime.now().timestamp()),
    end=int((datetime.now() + relativedelta(hours=1)).timestamp()),
    timezone="Etc/UTC",
    mute_first_recovery_notification=True,
    monitor_tags=[
        "tag0",
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DowntimesApi(api_client)
    response = api_instance.create_downtime(body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Repeat for 3 hours (starting now) on every week day for 4 weeks.
start_ts = Time.now.to_i
end_ts = start_ts + (3 * 60 * 60)
end_reccurrence_ts = start_ts + (4 * 7 * 24 * 60 * 60) # 4 weeks from now

recurrence = {
    'type' => 'weeks',
    'period' => 1,
    'week_days' => %w[Mon Tue Wed Thu Fri],
    'until_date' => end_reccurrence_ts
}

# Schedule downtime
dog.Downtime.create(
    'env:staging',
    start: start_ts,
    end: end_ts,
    recurrence: recurrence
)

# OR use RRULE reccurence
rrule_recurrence = {
    'type' => 'rrule',
    'rrule' => 'FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1',
}

# Schedule downtime
dog.Downtime.create(
    'env:staging',
    start: start_ts,
    end: end_ts,
    recurrence: rrule_recurrence
)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
# Schedule a downtime once a year

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DowntimesAPI.new

body = DatadogAPIClient::V1::Downtime.new({
  message: "Example-Downtime",
  recurrence: DatadogAPIClient::V1::DowntimeRecurrence.new({
    period: 1,
    type: "years",
  }),
  scope: [
    "*",
  ],
  start: Time.now.to_i,
  _end: (Time.now + 1 * 3600).to_i,
  timezone: "Etc/UTC",
  mute_first_recovery_notification: true,
  monitor_tags: [
    "tag0",
  ],
})
p api_instance.create_downtime(body)
# Schedule a downtime returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DowntimesAPI.new

body = DatadogAPIClient::V1::Downtime.new({
  message: "Example-Downtime",
  start: Time.now.to_i,
  timezone: "Etc/UTC",
  scope: [
    "test:exampledowntime",
  ],
  recurrence: DatadogAPIClient::V1::DowntimeRecurrence.new({
    type: "weeks",
    period: 1,
    week_days: [
      "Mon",
      "Tue",
      "Wed",
      "Thu",
      "Fri",
    ],
    until_date: (Time.now + 21 * 86400).to_i,
  }),
})
p api_instance.create_downtime(body)
# Schedule a downtime until date

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DowntimesAPI.new

body = DatadogAPIClient::V1::Downtime.new({
  message: "Example-Downtime",
  recurrence: DatadogAPIClient::V1::DowntimeRecurrence.new({
    period: 1,
    type: "weeks",
    until_date: (Time.now + 21 * 86400).to_i,
    week_days: [
      "Mon",
      "Tue",
      "Wed",
      "Thu",
      "Fri",
    ],
  }),
  scope: [
    "*",
  ],
  start: Time.now.to_i,
  _end: (Time.now + 1 * 3600).to_i,
  timezone: "Etc/UTC",
  mute_first_recovery_notification: true,
  monitor_tags: [
    "tag0",
  ],
})
p api_instance.create_downtime(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Schedule a downtime once a year
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DowntimesApi(configuration);

const params: v1.DowntimesApiCreateDowntimeRequest = {
  body: {
    message: "Example-Downtime",
    recurrence: {
      period: 1,
      type: "years",
    },
    scope: ["*"],
    start: Math.round(new Date().getTime() / 1000),
    end: Math.round(
      new Date(new Date().getTime() + 1 * 3600 * 1000).getTime() / 1000
    ),
    timezone: "Etc/UTC",
    muteFirstRecoveryNotification: true,
    monitorTags: ["tag0"],
  },
};

apiInstance
  .createDowntime(params)
  .then((data: v1.Downtime) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
/**
 * Schedule a downtime returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DowntimesApi(configuration);

const params: v1.DowntimesApiCreateDowntimeRequest = {
  body: {
    message: "Example-Downtime",
    start: Math.round(new Date().getTime() / 1000),
    timezone: "Etc/UTC",
    scope: ["test:exampledowntime"],
    recurrence: {
      type: "weeks",
      period: 1,
      weekDays: ["Mon", "Tue", "Wed", "Thu", "Fri"],
      untilDate: Math.round(
        new Date(new Date().getTime() + 21 * 86400 * 1000).getTime() / 1000
      ),
    },
  },
};

apiInstance
  .createDowntime(params)
  .then((data: v1.Downtime) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
/**
 * Schedule a downtime until date
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DowntimesApi(configuration);

const params: v1.DowntimesApiCreateDowntimeRequest = {
  body: {
    message: "Example-Downtime",
    recurrence: {
      period: 1,
      type: "weeks",
      untilDate: Math.round(
        new Date(new Date().getTime() + 21 * 86400 * 1000).getTime() / 1000
      ),
      weekDays: ["Mon", "Tue", "Wed", "Thu", "Fri"],
    },
    scope: ["*"],
    start: Math.round(new Date().getTime() / 1000),
    end: Math.round(
      new Date(new Date().getTime() + 1 * 3600 * 1000).getTime() / 1000
    ),
    timezone: "Etc/UTC",
    muteFirstRecoveryNotification: true,
    monitorTags: ["tag0"],
  },
};

apiInstance
  .createDowntime(params)
  .then((data: v1.Downtime) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"

POST https://api.ap1.datadoghq.com/api/v1/downtime/cancel/by_scopehttps://api.datadoghq.eu/api/v1/downtime/cancel/by_scopehttps://api.ddog-gov.com/api/v1/downtime/cancel/by_scopehttps://api.datadoghq.com/api/v1/downtime/cancel/by_scopehttps://api.us3.datadoghq.com/api/v1/downtime/cancel/by_scopehttps://api.us5.datadoghq.com/api/v1/downtime/cancel/by_scope

Présentation

Supprimez tous les downtimes correspondant au contexte X. This endpoint requires the monitors_downtime authorization scope.

Requête

Body Data (required)

Contexte pour l’annulation des downtimes.

Expand All

Champ

Type

Description

scope [required]

string

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

{
  "scope": "string"
}

Réponse

OK

Object containing array of IDs of canceled downtimes.

Expand All

Champ

Type

Description

cancelled_ids

[integer]

ID of downtimes that were canceled.

{
  "cancelled_ids": [
    123456789,
    123456790
  ]
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Downtimes not found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code

  
  # Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/downtime/cancel/by_scope" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "scope": "string" } EOF
// Cancel downtimes by scope returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	// there is a valid "downtime" in the system
	DowntimeScope0 := os.Getenv("DOWNTIME_SCOPE_0")

	body := datadogV1.CancelDowntimesByScopeRequest{
		Scope: DowntimeScope0,
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDowntimesApi(apiClient)
	resp, r, err := api.CancelDowntimesByScope(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DowntimesApi.CancelDowntimesByScope`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.CancelDowntimesByScope`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Cancel downtimes by scope returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DowntimesApi;
import com.datadog.api.client.v1.model.CancelDowntimesByScopeRequest;
import com.datadog.api.client.v1.model.CanceledDowntimesIds;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DowntimesApi apiInstance = new DowntimesApi(defaultClient);

    // there is a valid "downtime" in the system
    String DOWNTIME_SCOPE_0 = System.getenv("DOWNTIME_SCOPE_0");

    CancelDowntimesByScopeRequest body =
        new CancelDowntimesByScopeRequest().scope(DOWNTIME_SCOPE_0);

    try {
      CanceledDowntimesIds result = apiInstance.cancelDowntimesByScope(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#cancelDowntimesByScope");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Cancel all downtimes with scope
api.Downtime.cancel_downtime_by_scope('env:testing')

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
"""
Cancel downtimes by scope returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.downtimes_api import DowntimesApi
from datadog_api_client.v1.model.cancel_downtimes_by_scope_request import CancelDowntimesByScopeRequest

# there is a valid "downtime" in the system
DOWNTIME_SCOPE_0 = environ["DOWNTIME_SCOPE_0"]

body = CancelDowntimesByScopeRequest(
    scope=DOWNTIME_SCOPE_0,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DowntimesApi(api_client)
    response = api_instance.cancel_downtimes_by_scope(body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Cancel all downtimes with the given scope
dog.cancel_downtime_by_scope('env:testing')

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
# Cancel downtimes by scope returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DowntimesAPI.new

# there is a valid "downtime" in the system
DOWNTIME_SCOPE_0 = ENV["DOWNTIME_SCOPE_0"]

body = DatadogAPIClient::V1::CancelDowntimesByScopeRequest.new({
  scope: DOWNTIME_SCOPE_0,
})
p api_instance.cancel_downtimes_by_scope(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Cancel downtimes by scope returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DowntimesApi(configuration);

// there is a valid "downtime" in the system
const DOWNTIME_SCOPE_0 = process.env.DOWNTIME_SCOPE_0 as string;

const params: v1.DowntimesApiCancelDowntimesByScopeRequest = {
  body: {
    scope: DOWNTIME_SCOPE_0,
  },
};

apiInstance
  .cancelDowntimesByScope(params)
  .then((data: v1.CanceledDowntimesIds) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"

DELETE https://api.ap1.datadoghq.com/api/v1/downtime/{downtime_id}https://api.datadoghq.eu/api/v1/downtime/{downtime_id}https://api.ddog-gov.com/api/v1/downtime/{downtime_id}https://api.datadoghq.com/api/v1/downtime/{downtime_id}https://api.us3.datadoghq.com/api/v1/downtime/{downtime_id}https://api.us5.datadoghq.com/api/v1/downtime/{downtime_id}

Présentation

Annulez un downtime. This endpoint requires the monitors_downtime authorization scope.

Arguments

Paramètres du chemin

Nom

Type

Description

downtime_id [required]

integer

ID of the downtime to cancel.

Réponse

OK

Forbidden

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Downtime not found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Path parameters
export downtime_id="123456"
# Curl command
curl -X DELETE "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/downtime/${downtime_id}" \ -H "Accept: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Cancel a downtime returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.downtimes_api import DowntimesApi

# there is a valid "downtime" in the system
DOWNTIME_ID = environ["DOWNTIME_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DowntimesApi(api_client)
    api_instance.cancel_downtime(
        downtime_id=int(DOWNTIME_ID),
    )

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Cancel a downtime returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DowntimesAPI.new

# there is a valid "downtime" in the system
DOWNTIME_ID = ENV["DOWNTIME_ID"]
api_instance.cancel_downtime(DOWNTIME_ID.to_i)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Cancel a downtime returns "OK" response

package main

import (
	"context"
	"fmt"
	"os"
	"strconv"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	// there is a valid "downtime" in the system
	DowntimeID, _ := strconv.ParseInt(os.Getenv("DOWNTIME_ID"), 10, 64)

	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDowntimesApi(apiClient)
	r, err := api.CancelDowntime(ctx, DowntimeID)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DowntimesApi.CancelDowntime`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Cancel a downtime returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DowntimesApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DowntimesApi apiInstance = new DowntimesApi(defaultClient);

    // there is a valid "downtime" in the system
    Long DOWNTIME_ID = Long.parseLong(System.getenv("DOWNTIME_ID"));

    try {
      apiInstance.cancelDowntime(DOWNTIME_ID);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#cancelDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
/**
 * Cancel a downtime returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DowntimesApi(configuration);

// there is a valid "downtime" in the system
const DOWNTIME_ID = parseInt(process.env.DOWNTIME_ID as string);

const params: v1.DowntimesApiCancelDowntimeRequest = {
  downtimeId: DOWNTIME_ID,
};

apiInstance
  .cancelDowntime(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"

GET https://api.ap1.datadoghq.com/api/v1/downtime/{downtime_id}https://api.datadoghq.eu/api/v1/downtime/{downtime_id}https://api.ddog-gov.com/api/v1/downtime/{downtime_id}https://api.datadoghq.com/api/v1/downtime/{downtime_id}https://api.us3.datadoghq.com/api/v1/downtime/{downtime_id}https://api.us5.datadoghq.com/api/v1/downtime/{downtime_id}

Présentation

Récupérez les détails d’un downtime par downtime_id. This endpoint requires the monitors_read authorization scope.

Arguments

Paramètres du chemin

Nom

Type

Description

downtime_id [required]

integer

ID of the downtime to fetch.

Réponse

OK

Downtiming gives you greater control over monitor notifications by allowing you to globally exclude scopes from alerting. Downtime settings, which can be scheduled with start and end times, prevent all alerting related to specified Datadog tags.

Expand All

Champ

Type

Description

active

boolean

If a scheduled downtime currently exists.

active_child

object

The downtime object definition of the active child for the original parent recurring downtime. This field will only exist on recurring downtimes.

active

boolean

If a scheduled downtime currently exists.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

{
  "active": true,
  "active_child": {
    "active": true,
    "canceled": 1412799983,
    "creator_id": 123456,
    "disabled": false,
    "downtime_type": 2,
    "end": 1412793983,
    "id": 1626,
    "message": "Message on the downtime",
    "monitor_id": 123456,
    "monitor_tags": [
      "*"
    ],
    "mute_first_recovery_notification": false,
    "notify_end_states": [
      "alert",
      "no data",
      "warn"
    ],
    "notify_end_types": [
      "canceled",
      "expired"
    ],
    "parent_id": 123,
    "recurrence": {
      "period": 1,
      "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
      "type": "weeks",
      "until_date": 1447786293,
      "until_occurrences": 2,
      "week_days": [
        "Mon",
        "Tue"
      ]
    },
    "scope": [
      "env:staging"
    ],
    "start": 1412792983,
    "timezone": "America/New_York",
    "updater_id": 123456
  },
  "canceled": 1412799983,
  "creator_id": 123456,
  "disabled": false,
  "downtime_type": 2,
  "end": 1412793983,
  "id": 1625,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "mute_first_recovery_notification": false,
  "notify_end_states": [
    "alert",
    "no data",
    "warn"
  ],
  "notify_end_types": [
    "canceled",
    "expired"
  ],
  "parent_id": 123,
  "recurrence": {
    "period": 1,
    "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
    "type": "weeks",
    "until_date": 1447786293,
    "until_occurrences": 2,
    "week_days": [
      "Mon",
      "Tue"
    ]
  },
  "scope": [
    "env:staging"
  ],
  "start": 1412792983,
  "timezone": "America/New_York",
  "updater_id": 123456
}

Forbidden

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Downtime not found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Path parameters
export downtime_id="123456"
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/downtime/${downtime_id}" \ -H "Accept: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get a downtime returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.downtimes_api import DowntimesApi

# there is a valid "downtime" in the system
DOWNTIME_ID = environ["DOWNTIME_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DowntimesApi(api_client)
    response = api_instance.get_downtime(
        downtime_id=int(DOWNTIME_ID),
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get a downtime returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DowntimesAPI.new

# there is a valid "downtime" in the system
DOWNTIME_ID = ENV["DOWNTIME_ID"]
p api_instance.get_downtime(DOWNTIME_ID.to_i)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

# Get a downtime object
downtime_id = 1625
dog.get_downtime(downtime_id)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Get a downtime returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"strconv"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	// there is a valid "downtime" in the system
	DowntimeID, _ := strconv.ParseInt(os.Getenv("DOWNTIME_ID"), 10, 64)

	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDowntimesApi(apiClient)
	resp, r, err := api.GetDowntime(ctx, DowntimeID)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DowntimesApi.GetDowntime`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.GetDowntime`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get a downtime returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DowntimesApi;
import com.datadog.api.client.v1.model.Downtime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DowntimesApi apiInstance = new DowntimesApi(defaultClient);

    // there is a valid "downtime" in the system
    Long DOWNTIME_ID = Long.parseLong(System.getenv("DOWNTIME_ID"));

    try {
      Downtime result = apiInstance.getDowntime(DOWNTIME_ID);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#getDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

# Get a downtime
api.Downtime.get(2910)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python "example.py"
/**
 * Get a downtime returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DowntimesApi(configuration);

// there is a valid "downtime" in the system
const DOWNTIME_ID = parseInt(process.env.DOWNTIME_ID as string);

const params: v1.DowntimesApiGetDowntimeRequest = {
  downtimeId: DOWNTIME_ID,
};

apiInstance
  .getDowntime(params)
  .then((data: v1.Downtime) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"

PUT https://api.ap1.datadoghq.com/api/v1/downtime/{downtime_id}https://api.datadoghq.eu/api/v1/downtime/{downtime_id}https://api.ddog-gov.com/api/v1/downtime/{downtime_id}https://api.datadoghq.com/api/v1/downtime/{downtime_id}https://api.us3.datadoghq.com/api/v1/downtime/{downtime_id}https://api.us5.datadoghq.com/api/v1/downtime/{downtime_id}

Présentation

Mettez à jour un downtime unique par downtime_id. This endpoint requires the monitors_downtime authorization scope.

Arguments

Paramètres du chemin

Nom

Type

Description

downtime_id [required]

integer

ID of the downtime to update.

Requête

Body Data (required)

Corps de requête pour la mise à jour d’un downtime.

Expand All

Champ

Type

Description

active

boolean

If a scheduled downtime currently exists.

active_child

object

The downtime object definition of the active child for the original parent recurring downtime. This field will only exist on recurring downtimes.

active

boolean

If a scheduled downtime currently exists.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

{
  "message": "Example-Downtime-updated",
  "mute_first_recovery_notification": true,
  "notify_end_states": [
    "alert",
    "no data",
    "warn"
  ],
  "notify_end_types": [
    "canceled",
    "expired"
  ]
}

Réponse

OK

Downtiming gives you greater control over monitor notifications by allowing you to globally exclude scopes from alerting. Downtime settings, which can be scheduled with start and end times, prevent all alerting related to specified Datadog tags.

Expand All

Champ

Type

Description

active

boolean

If a scheduled downtime currently exists.

active_child

object

The downtime object definition of the active child for the original parent recurring downtime. This field will only exist on recurring downtimes.

active

boolean

If a scheduled downtime currently exists.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

{
  "active": true,
  "active_child": {
    "active": true,
    "canceled": 1412799983,
    "creator_id": 123456,
    "disabled": false,
    "downtime_type": 2,
    "end": 1412793983,
    "id": 1626,
    "message": "Message on the downtime",
    "monitor_id": 123456,
    "monitor_tags": [
      "*"
    ],
    "mute_first_recovery_notification": false,
    "notify_end_states": [
      "alert",
      "no data",
      "warn"
    ],
    "notify_end_types": [
      "canceled",
      "expired"
    ],
    "parent_id": 123,
    "recurrence": {
      "period": 1,
      "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
      "type": "weeks",
      "until_date": 1447786293,
      "until_occurrences": 2,
      "week_days": [
        "Mon",
        "Tue"
      ]
    },
    "scope": [
      "env:staging"
    ],
    "start": 1412792983,
    "timezone": "America/New_York",
    "updater_id": 123456
  },
  "canceled": 1412799983,
  "creator_id": 123456,
  "disabled": false,
  "downtime_type": 2,
  "end": 1412793983,
  "id": 1625,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "mute_first_recovery_notification": false,
  "notify_end_states": [
    "alert",
    "no data",
    "warn"
  ],
  "notify_end_types": [
    "canceled",
    "expired"
  ],
  "parent_id": 123,
  "recurrence": {
    "period": 1,
    "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
    "type": "weeks",
    "until_date": 1447786293,
    "until_occurrences": 2,
    "week_days": [
      "Mon",
      "Tue"
    ]
  },
  "scope": [
    "env:staging"
  ],
  "start": 1412792983,
  "timezone": "America/New_York",
  "updater_id": 123456
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Downtime not found

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code

  
  # Path parameters
export downtime_id="123456"
# Curl command
curl -X PUT "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/downtime/${downtime_id}" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "message": "Example-Downtime-updated", "mute_first_recovery_notification": true, "notify_end_states": [ "alert", "no data", "warn" ], "notify_end_types": [ "canceled", "expired" ] } EOF
// Update a downtime returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"strconv"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	// there is a valid "downtime" in the system
	DowntimeID, _ := strconv.ParseInt(os.Getenv("DOWNTIME_ID"), 10, 64)

	body := datadogV1.Downtime{
		Message:                       *datadog.NewNullableString(datadog.PtrString("Example-Downtime-updated")),
		MuteFirstRecoveryNotification: datadog.PtrBool(true),
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDowntimesApi(apiClient)
	resp, r, err := api.UpdateDowntime(ctx, DowntimeID, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DowntimesApi.UpdateDowntime`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.UpdateDowntime`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Update a downtime returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DowntimesApi;
import com.datadog.api.client.v1.model.Downtime;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DowntimesApi apiInstance = new DowntimesApi(defaultClient);

    // there is a valid "downtime" in the system
    Long DOWNTIME_ID = Long.parseLong(System.getenv("DOWNTIME_ID"));

    Downtime body =
        new Downtime().message("Example-Downtime-updated").muteFirstRecoveryNotification(true);

    try {
      Downtime result = apiInstance.updateDowntime(DOWNTIME_ID, body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#updateDowntime");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
"""
Update a downtime returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.downtimes_api import DowntimesApi
from datadog_api_client.v1.model.downtime import Downtime

# there is a valid "downtime" in the system
DOWNTIME_ID = environ["DOWNTIME_ID"]

body = Downtime(
    message="Example-Downtime-updated",
    mute_first_recovery_notification=True,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DowntimesApi(api_client)
    response = api_instance.update_downtime(downtime_id=int(DOWNTIME_ID), body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Update a downtime returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DowntimesAPI.new

# there is a valid "downtime" in the system
DOWNTIME_ID = ENV["DOWNTIME_ID"]

body = DatadogAPIClient::V1::Downtime.new({
  message: "Example-Downtime-updated",
  mute_first_recovery_notification: true,
})
p api_instance.update_downtime(DOWNTIME_ID.to_i, body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
/**
 * Update a downtime returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DowntimesApi(configuration);

// there is a valid "downtime" in the system
const DOWNTIME_ID = parseInt(process.env.DOWNTIME_ID as string);

const params: v1.DowntimesApiUpdateDowntimeRequest = {
  body: {
    message: "Example-Downtime-updated",
    muteFirstRecoveryNotification: true,
  },
  downtimeId: DOWNTIME_ID,
};

apiInstance
  .updateDowntime(params)
  .then((data: v1.Downtime) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"

GET https://api.ap1.datadoghq.com/api/v1/monitor/{monitor_id}/downtimeshttps://api.datadoghq.eu/api/v1/monitor/{monitor_id}/downtimeshttps://api.ddog-gov.com/api/v1/monitor/{monitor_id}/downtimeshttps://api.datadoghq.com/api/v1/monitor/{monitor_id}/downtimeshttps://api.us3.datadoghq.com/api/v1/monitor/{monitor_id}/downtimeshttps://api.us5.datadoghq.com/api/v1/monitor/{monitor_id}/downtimes

Présentation

Récupérez tous les downtimes du monitor spécifié. This endpoint requires the monitors_read authorization scope.

Arguments

Paramètres du chemin

Nom

Type

Description

monitor_id [required]

integer

The id of the monitor

Réponse

OK

Expand All

Champ

Type

Description

active

boolean

If a scheduled downtime currently exists.

active_child

object

The downtime object definition of the active child for the original parent recurring downtime. This field will only exist on recurring downtimes.

active

boolean

If a scheduled downtime currently exists.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

canceled

int64

If a scheduled downtime is canceled.

creator_id

int32

User ID of the downtime creator.

disabled

boolean

If a downtime has been disabled.

downtime_type

int32

0 for a downtime applied on * or all, 1 when the downtime is only scoped to hosts, or 2 when the downtime is scoped to anything but hosts.

end

int64

POSIX timestamp to end the downtime. If not provided, the downtime is in effect indefinitely until you cancel it.

id

int64

The downtime ID.

message

string

A message to include with notifications for this downtime. Email notifications can be sent to specific users by using the same @username notation as events.

monitor_id

int64

A single monitor to which the downtime applies. If not provided, the downtime applies to all monitors.

monitor_tags

[string]

A comma-separated list of monitor tags. For example, tags that are applied directly to monitors, not tags that are used in monitor queries (which are filtered by the scope parameter), to which the downtime applies. The resulting downtime applies to monitors that match ALL provided monitor tags. For example, service:postgres AND team:frontend.

mute_first_recovery_notification

boolean

If the first recovery notification during a downtime should be muted.

notify_end_states

[string]

States for which notify_end_types sends out notifications for.

notify_end_types

[string]

If set, notifies if a monitor is in an alert-worthy state (ALERT, WARNING, or NO DATA) when this downtime expires or is canceled. Applied to monitors that change states during the downtime (such as from OK to ALERT, WARNING, or NO DATA), and to monitors that already have an alert-worthy state when downtime begins.

parent_id

int64

ID of the parent Downtime.

recurrence

object

An object defining the recurrence of the downtime.

period

int32

How often to repeat as an integer. For example, to repeat every 3 days, select a type of days and a period of 3.

rrule

string

The RRULE standard for defining recurring events (requires to set "type" to rrule) For example, to have a recurring event on the first day of each month, set the type to rrule and set the FREQ to MONTHLY and BYMONTHDAY to 1. Most common rrule options from the iCalendar Spec are supported.

Note: Attributes specifying the duration in RRULE are not supported (for example, DTSTART, DTEND, DURATION). More examples available in this downtime guide

type

string

The type of recurrence. Choose from days, weeks, months, years, rrule.

until_date

int64

The date at which the recurrence should end as a POSIX timestamp. until_occurences and until_date are mutually exclusive.

until_occurrences

int32

How many times the downtime is rescheduled. until_occurences and until_date are mutually exclusive.

week_days

[string]

A list of week days to repeat on. Choose from Mon, Tue, Wed, Thu, Fri, Sat or Sun. Only applicable when type is weeks. First letter must be capitalized.

scope

[string]

The scope(s) to which the downtime applies and must be in key:value format. For example, host:app2. Provide multiple scopes as a comma-separated list like env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided scopes (env:dev AND env:prod).

start

int64

POSIX timestamp to start the downtime. If not provided, the downtime starts the moment it is created.

timezone

string

The timezone in which to display the downtime's start and end times in Datadog applications.

updater_id

int32

ID of the last user that updated the downtime.

{
  "active": true,
  "active_child": {
    "active": true,
    "canceled": 1412799983,
    "creator_id": 123456,
    "disabled": false,
    "downtime_type": 2,
    "end": 1412793983,
    "id": 1626,
    "message": "Message on the downtime",
    "monitor_id": 123456,
    "monitor_tags": [
      "*"
    ],
    "mute_first_recovery_notification": false,
    "notify_end_states": [
      "alert",
      "no data",
      "warn"
    ],
    "notify_end_types": [
      "canceled",
      "expired"
    ],
    "parent_id": 123,
    "recurrence": {
      "period": 1,
      "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
      "type": "weeks",
      "until_date": 1447786293,
      "until_occurrences": 2,
      "week_days": [
        "Mon",
        "Tue"
      ]
    },
    "scope": [
      "env:staging"
    ],
    "start": 1412792983,
    "timezone": "America/New_York",
    "updater_id": 123456
  },
  "canceled": 1412799983,
  "creator_id": 123456,
  "disabled": false,
  "downtime_type": 2,
  "end": 1412793983,
  "id": 1625,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "mute_first_recovery_notification": false,
  "notify_end_states": [
    "alert",
    "no data",
    "warn"
  ],
  "notify_end_types": [
    "canceled",
    "expired"
  ],
  "parent_id": 123,
  "recurrence": {
    "period": 1,
    "rrule": "FREQ=MONTHLY;BYSETPOS=3;BYDAY=WE;INTERVAL=1",
    "type": "weeks",
    "until_date": 1447786293,
    "until_occurrences": 2,
    "week_days": [
      "Mon",
      "Tue"
    ]
  },
  "scope": [
    "env:staging"
  ],
  "start": 1412792983,
  "timezone": "America/New_York",
  "updater_id": 123456
}

Bad Request

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Monitor Not Found error

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

Error response object.

Expand All

Champ

Type

Description

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


# Path parameters
export monitor_id="CHANGE_ME"
# Curl command
curl -X GET "https://api.ap1.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v1/monitor/${monitor_id}/downtimes" \ -H "Accept: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get all downtimes for a monitor returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.downtimes_api import DowntimesApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DowntimesApi(api_client)
    response = api_instance.list_monitor_downtimes(
        monitor_id=9223372036854775807,
    )

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get all downtimes for a monitor returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DowntimesAPI.new
p api_instance.list_monitor_downtimes(9223372036854775807)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Get all downtimes for a monitor returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV1.NewDowntimesApi(apiClient)
	resp, r, err := api.ListMonitorDowntimes(ctx, 9223372036854775807)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DowntimesApi.ListMonitorDowntimes`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.ListMonitorDowntimes`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get all downtimes for a monitor returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DowntimesApi;
import com.datadog.api.client.v1.model.Downtime;
import java.util.List;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DowntimesApi apiInstance = new DowntimesApi(defaultClient);

    try {
      List<Downtime> result = apiInstance.listMonitorDowntimes(9223372036854775807L);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DowntimesApi#listMonitorDowntimes");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
/**
 * Get all downtimes for a monitor returns "OK" response
 */

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DowntimesApi(configuration);

const params: v1.DowntimesApiListMonitorDowntimesRequest = {
  monitorId: 9223372036854775807,
};

apiInstance
  .listMonitorDowntimes(params)
  .then((data: v1.Downtime[]) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"