Downtimes
Rapport de recherche Datadog : Bilan sur l'adoption de l'informatique sans serveur Rapport : Bilan sur l'adoption de l'informatique sans serveur

Downtimes

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.

Cancel a downtime

DELETE https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime/{downtime_id}

Overview

Cancel a downtime.

Arguments

Path Parameters

Name

Type

Description

downtime_id [required]

integer

ID of the downtime to cancel.

Response

OK

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Downtime not found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Path parameters
export downtime_id="123456"
# Curl command curl -X DELETE https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime/${downtime_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    downtimeId := 987 // int64 | ID of the downtime to cancel.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.DowntimesApi.CancelDowntime(ctx, downtimeId).Execute()
    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)
    }
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.DowntimesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        DowntimesApi apiInstance = new DowntimesApi(defaultClient);
        Long downtimeId = 123456; // Long | ID of the downtime to cancel.
        try {
            api.cancelDowntime(downtimeId)
                .execute();
        } 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();
        }
    }
}

Cancel downtimes by scope

POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime/cancel/by_scope

Overview

Delete all downtimes that match the scope of X.

Request

Body Data (required)

Scope to cancel downtimes for.

Expand All

Field

Type

Description

scope [required]

string

The scope(s) to which the downtime applies. 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": "host:myserver"
}

Response

OK

Object containing array of IDs of canceled downtimes.

Expand All

Field

Type

Description

cancelled_ids

[integer]

ID of downtimes that were canceled.

{
  "cancelled_ids": [
    123456789,
    123456790
  ]
}

Bad Request

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Downtimes not found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Curl command
curl -X POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime/cancel/by_scope \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "scope": "host:myserver"
}
EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := datadog.CancelDowntimesByScopeRequest{Scope: "Scope_example"} // CancelDowntimesByScopeRequest | Scope to cancel downtimes for.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.DowntimesApi.CancelDowntimesByScope(ctx, body).Execute()
    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)
    }
    // response from `CancelDowntimesByScope`: CanceledDowntimesIds
    fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.CancelDowntimesByScope`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.DowntimesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        DowntimesApi apiInstance = new DowntimesApi(defaultClient);
        CancelDowntimesByScopeRequest body = new CancelDowntimesByScopeRequest(); // CancelDowntimesByScopeRequest | Scope to cancel downtimes for.
        try {
            CanceledDowntimesIds result = api.cancelDowntimesByScope()
                .body(body)
                .execute();
            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();
        }
    }
}
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')
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')

Get a downtime

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime/{downtime_id}

Overview

Get downtime detail by downtime_id.

Arguments

Path Parameters

Name

Type

Description

downtime_id [required]

integer

ID of the downtime to fetch.

Response

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

Field

Type

Description

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.

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. For example, to have a recurring event on the first day of each month, select a type of 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).

type

string

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

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. 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 for the downtime.

updater_id

int32

ID of the last user that updated the downtime.

{
  "active": true,
  "canceled": 1412799983,
  "creator_id": 123456,
  "disabled": false,
  "downtime_type": 2,
  "end": 1412793983,
  "id": 1625,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "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

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Downtime not found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Path parameters
export downtime_id="123456"
# Curl command curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime/${downtime_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    downtimeId := 987 // int64 | ID of the downtime to fetch.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.DowntimesApi.GetDowntime(ctx, downtimeId).Execute()
    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)
    }
    // response from `GetDowntime`: Downtime
    fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.GetDowntime`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.DowntimesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        DowntimesApi apiInstance = new DowntimesApi(defaultClient);
        Long downtimeId = 123456; // Long | ID of the downtime to fetch.
        try {
            Downtime result = api.getDowntime(downtimeId)
                .execute();
            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();
        }
    }
}
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)
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)

Get all downtimes

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime

Overview

Get all scheduled downtimes.

Arguments

Query Strings

Name

Type

Description

current_only

boolean

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

Response

OK

Expand All

Field

Type

Description

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.

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. For example, to have a recurring event on the first day of each month, select a type of 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).

type

string

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

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. 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 for the downtime.

updater_id

int32

ID of the last user that updated the downtime.

{
  "active": true,
  "canceled": 1412799983,
  "creator_id": 123456,
  "disabled": false,
  "downtime_type": 2,
  "end": 1412793983,
  "id": 1625,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "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

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Curl command
curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    currentOnly := true // bool | Only return downtimes that are active when the request is made. (optional)

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.DowntimesApi.ListDowntimes(ctx).CurrentOnly(currentOnly).Execute()
    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)
    }
    // response from `ListDowntimes`: []Downtime
    fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.ListDowntimes`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.DowntimesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        DowntimesApi apiInstance = new DowntimesApi(defaultClient);
        Boolean currentOnly = true; // Boolean | Only return downtimes that are active when the request is made.
        try {
            List<Downtime> result = api.listDowntimes()
                .currentOnly(currentOnly)
                .execute();
            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();
        }
    }
}
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())
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

Schedule a downtime

POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime

Overview

Schedule a downtime.

Request

Body Data (required)

Schedule a downtime request body.

Expand All

Field

Type

Description

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.

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. For example, to have a recurring event on the first day of each month, select a type of 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).

type

string

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

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. 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 for the downtime.

updater_id

int32

ID of the last user that updated the downtime.

{
  "disabled": false,
  "end": 1412793983,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "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"
}

Response

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

Field

Type

Description

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.

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. For example, to have a recurring event on the first day of each month, select a type of 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).

type

string

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

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. 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 for the downtime.

updater_id

int32

ID of the last user that updated the downtime.

{
  "active": true,
  "canceled": 1412799983,
  "creator_id": 123456,
  "disabled": false,
  "downtime_type": 2,
  "end": 1412793983,
  "id": 1625,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "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

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Curl command
curl -X POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{}
EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := datadog.Downtime{Active: true, Canceled: int64(123), CreatorId: 123, Disabled: false, DowntimeType: 123, End: int64(123), Id: int64(123), Message: "Message_example", MonitorId: int64(123), MonitorTags: []string{"MonitorTags_example"), ParentId: int64(123), Recurrence: datadog.DowntimeRecurrence{Period: 123, Rrule: "Rrule_example", Type: "Type_example", UntilDate: int64(123), UntilOccurrences: 123, WeekDays: []string{"WeekDays_example")}, Scope: []string{"Scope_example"), Start: int64(123), Timezone: "Timezone_example", UpdaterId: 123} // Downtime | Schedule a downtime request body.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.DowntimesApi.CreateDowntime(ctx, body).Execute()
    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)
    }
    // response from `CreateDowntime`: Downtime
    fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.CreateDowntime`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.DowntimesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        DowntimesApi apiInstance = new DowntimesApi(defaultClient);
        Downtime body = new Downtime(); // Downtime | Schedule a downtime request body.
        try {
            Downtime result = api.createDowntime()
                .body(body)
                .execute();
            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();
        }
    }
}
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
)
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
)

Update a downtime

PUT https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime/{downtime_id}

Overview

Update a single downtime by downtime_id.

Arguments

Path Parameters

Name

Type

Description

downtime_id [required]

integer

ID of the downtime to update.

Request

Body Data (required)

Update a downtime request body.

Expand All

Field

Type

Description

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.

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. For example, to have a recurring event on the first day of each month, select a type of 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).

type

string

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

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. 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 for the downtime.

updater_id

int32

ID of the last user that updated the downtime.

{
  "disabled": false,
  "end": 1412793983,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "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"
}

Response

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

Field

Type

Description

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.

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. For example, to have a recurring event on the first day of each month, select a type of 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).

type

string

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

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. 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 for the downtime.

updater_id

int32

ID of the last user that updated the downtime.

{
  "active": true,
  "canceled": 1412799983,
  "creator_id": 123456,
  "disabled": false,
  "downtime_type": 2,
  "end": 1412793983,
  "id": 1625,
  "message": "Message on the downtime",
  "monitor_id": 123456,
  "monitor_tags": [
    "*"
  ],
  "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

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Forbidden

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Downtime not found

Error response object.

Expand All

Field

Type

Description

errors [required]

[string]

Array of errors returned by the API.

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

Code Example


                                        # Path parameters
export downtime_id="123456"
# Curl command curl -X PUT https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/downtime/${downtime_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF {} EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    downtimeId := 987 // int64 | ID of the downtime to update.
    body := datadog.Downtime{Active: true, Canceled: int64(123), CreatorId: 123, Disabled: false, DowntimeType: 123, End: int64(123), Id: int64(123), Message: "Message_example", MonitorId: int64(123), MonitorTags: []string{"MonitorTags_example"), ParentId: int64(123), Recurrence: datadog.DowntimeRecurrence{Period: 123, Rrule: "Rrule_example", Type: "Type_example", UntilDate: int64(123), UntilOccurrences: 123, WeekDays: []string{"WeekDays_example")}, Scope: []string{"Scope_example"), Start: int64(123), Timezone: "Timezone_example", UpdaterId: 123} // Downtime | Update a downtime request body.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.DowntimesApi.UpdateDowntime(ctx, downtimeId, body).Execute()
    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)
    }
    // response from `UpdateDowntime`: Downtime
    fmt.Fprintf(os.Stdout, "Response from `DowntimesApi.UpdateDowntime`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.DowntimesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        DowntimesApi apiInstance = new DowntimesApi(defaultClient);
        Long downtimeId = 123456; // Long | ID of the downtime to update.
        Downtime body = new Downtime(); // Downtime | Update a downtime request body.
        try {
            Downtime result = api.updateDowntime(downtimeId)
                .body(body)
                .execute();
            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();
        }
    }
}