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.
DELETE https://api.datadoghq.eu/api/v1/downtime/{downtime_id}https://api.datadoghq.com/api/v1/downtime/{downtime_id}
Cancel a downtime.
Name
Type
Description
downtime_id [required]
integer
ID of the downtime to cancel.
OK
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Downtime not found
Error response object.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export downtime_id="123456"
# Curl command
curl -X DELETE "https://api.datadoghq.eu"https://api.datadoghq.com/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 := int64(123456) // int64 | ID of the downtime to cancel.
configuration := datadog.NewConfiguration()
api_client := datadog.NewAPIClient(configuration)
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 java.util.*;
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 = 123456L; // Long | ID of the downtime to cancel.
try {
apiInstance.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();
}
}
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import downtimes_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
host = "https://api.datadoghq.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = downtimes_api.DowntimesApi(api_client)
downtime_id = 123456 # int | ID of the downtime to cancel.
# example passing only required values which don't have defaults set
try:
# Cancel a downtime
api_instance.cancel_downtime(downtime_id)
except datadog_api_client.v1.ApiException as e:
print("Exception when calling DowntimesApi->cancel_downtime: %s\n" % e)
require 'time'
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['appKeyAuth'] = 'Bearer'
end
api_instance = DatadogAPIClient::V1::DowntimesApi.new
downtime_id = 123456 # Integer | ID of the downtime to cancel.
begin
# Cancel a downtime
api_instance.cancel_downtime(downtime_id)
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling DowntimesApi->cancel_downtime: #{e}"
end
POST https://api.datadoghq.eu/api/v1/downtime/cancel/by_scopehttps://api.datadoghq.com/api/v1/downtime/cancel/by_scope
Delete all downtimes that match the scope of X
.
Scope to cancel downtimes for.
{
"scope": "host:myserver"
}
OK
Object containing array of IDs of canceled downtimes.
{
"cancelled_ids": [
123456789,
123456790
]
}
Bad Request
Error response object.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Downtimes not found
Error response object.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/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"
"encoding/json"
"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.NewCancelDowntimesByScopeRequest("host:myserver") // CancelDowntimesByScopeRequest | Scope to cancel downtimes for.
configuration := datadog.NewConfiguration()
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.DowntimesApi.CancelDowntimesByScope(ctx).Body(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
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from DowntimesApi.CancelDowntimesByScope:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
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 = apiInstance.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')
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import downtimes_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
host = "https://api.datadoghq.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = downtimes_api.DowntimesApi(api_client)
body = CancelDowntimesByScopeRequest(
scope="host:myserver",
) # CancelDowntimesByScopeRequest | Scope to cancel downtimes for.
# example passing only required values which don't have defaults set
try:
# Cancel downtimes by scope
api_response = api_instance.cancel_downtimes_by_scope(body)
pprint(api_response)
except datadog_api_client.v1.ApiException as e:
print("Exception when calling DowntimesApi->cancel_downtimes_by_scope: %s\n" % e)
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')
require 'time'
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['appKeyAuth'] = 'Bearer'
end
api_instance = DatadogAPIClient::V1::DowntimesApi.new
body = DatadogAPIClient::V1::CancelDowntimesByScopeRequest.new({scope: 'host:myserver'}) # CancelDowntimesByScopeRequest | Scope to cancel downtimes for.
begin
# Cancel downtimes by scope
result = api_instance.cancel_downtimes_by_scope(body)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling DowntimesApi->cancel_downtimes_by_scope: #{e}"
end
GET https://api.datadoghq.eu/api/v1/downtime/{downtime_id}https://api.datadoghq.com/api/v1/downtime/{downtime_id}
Get downtime detail by downtime_id
.
Name
Type
Description
downtime_id [required]
integer
ID of the downtime to fetch.
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.
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 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,
"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.
{
"errors": [
"Bad Request"
]
}
Downtime not found
Error response object.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export downtime_id="123456"
# Curl command
curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/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"
"encoding/json"
"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 := int64(123456) // 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
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from DowntimesApi.GetDowntime:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
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 = 123456L; // Long | ID of the downtime to fetch.
try {
Downtime result = apiInstance.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)
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import downtimes_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
host = "https://api.datadoghq.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = downtimes_api.DowntimesApi(api_client)
downtime_id = 123456 # int | ID of the downtime to fetch.
# example passing only required values which don't have defaults set
try:
# Get a downtime
api_response = api_instance.get_downtime(downtime_id)
pprint(api_response)
except datadog_api_client.v1.ApiException as e:
print("Exception when calling DowntimesApi->get_downtime: %s\n" % e)
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)
require 'time'
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['appKeyAuth'] = 'Bearer'
end
api_instance = DatadogAPIClient::V1::DowntimesApi.new
downtime_id = 123456 # Integer | ID of the downtime to fetch.
begin
# Get a downtime
result = api_instance.get_downtime(downtime_id)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling DowntimesApi->get_downtime: #{e}"
end
GET https://api.datadoghq.eu/api/v1/downtimehttps://api.datadoghq.com/api/v1/downtime
Get all scheduled downtimes.
Name
Type
Description
current_only
boolean
Only return downtimes that are active when the request is made.
OK
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 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,
"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.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/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"
"encoding/json"
"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
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from DowntimesApi.ListDowntimes:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
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 = apiInstance.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())
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import downtimes_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
host = "https://api.datadoghq.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = downtimes_api.DowntimesApi(api_client)
current_only = True # bool | Only return downtimes that are active when the request is made. (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# Get all downtimes
api_response = api_instance.list_downtimes(current_only=current_only)
pprint(api_response)
except datadog_api_client.v1.ApiException as e:
print("Exception when calling DowntimesApi->list_downtimes: %s\n" % e)
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
require 'time'
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['appKeyAuth'] = 'Bearer'
end
api_instance = DatadogAPIClient::V1::DowntimesApi.new
opts = {
current_only: true # Boolean | Only return downtimes that are active when the request is made.
}
begin
# Get all downtimes
result = api_instance.list_downtimes(opts)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling DowntimesApi->list_downtimes: #{e}"
end
POST https://api.datadoghq.eu/api/v1/downtimehttps://api.datadoghq.com/api/v1/downtime
Schedule a downtime.
Schedule a downtime request body.
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 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.
{
"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"
}
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.
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 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,
"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.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
# Curl command
curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/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"
"encoding/json"
"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.NewDowntime() // Downtime | Schedule a downtime request body.
configuration := datadog.NewConfiguration()
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.DowntimesApi.CreateDowntime(ctx).Body(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
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from DowntimesApi.CreateDowntime:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
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 = apiInstance.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
)
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import downtimes_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
host = "https://api.datadoghq.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = downtimes_api.DowntimesApi(api_client)
body = 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=DowntimeRecurrence(
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,
) # Downtime | Schedule a downtime request body.
# example passing only required values which don't have defaults set
try:
# Schedule a downtime
api_response = api_instance.create_downtime(body)
pprint(api_response)
except datadog_api_client.v1.ApiException as e:
print("Exception when calling DowntimesApi->create_downtime: %s\n" % e)
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
)
require 'time'
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['appKeyAuth'] = 'Bearer'
end
api_instance = DatadogAPIClient::V1::DowntimesApi.new
body = DatadogAPIClient::V1::Downtime.new # Downtime | Schedule a downtime request body.
begin
# Schedule a downtime
result = api_instance.create_downtime(body)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling DowntimesApi->create_downtime: #{e}"
end
PUT https://api.datadoghq.eu/api/v1/downtime/{downtime_id}https://api.datadoghq.com/api/v1/downtime/{downtime_id}
Update a single downtime by downtime_id
.
Name
Type
Description
downtime_id [required]
integer
ID of the downtime to update.
Update a downtime request body.
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 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.
{
"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"
}
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.
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 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,
"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.
{
"errors": [
"Bad Request"
]
}
Forbidden
Error response object.
{
"errors": [
"Bad Request"
]
}
Downtime not found
Error response object.
{
"errors": [
"Bad Request"
]
}
# Path parameters
export downtime_id="123456"
# Curl command
curl -X PUT "https://api.datadoghq.eu"https://api.datadoghq.com/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"
"encoding/json"
"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 := int64(123456) // int64 | ID of the downtime to update.
body := *datadog.NewDowntime() // Downtime | Update a downtime request body.
configuration := datadog.NewConfiguration()
api_client := datadog.NewAPIClient(configuration)
resp, r, err := api_client.DowntimesApi.UpdateDowntime(ctx, downtimeId).Body(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
response_content, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from DowntimesApi.UpdateDowntime:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
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 = 123456L; // Long | ID of the downtime to update.
Downtime body = new Downtime(); // Downtime | Update a downtime request body.
try {
Downtime result = apiInstance.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();
}
}
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import downtimes_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
host = "https://api.datadoghq.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with datadog_api_client.v1.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = downtimes_api.DowntimesApi(api_client)
downtime_id = 123456 # int | ID of the downtime to update.
body = 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=DowntimeRecurrence(
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,
) # Downtime | Update a downtime request body.
# example passing only required values which don't have defaults set
try:
# Update a downtime
api_response = api_instance.update_downtime(downtime_id, body)
pprint(api_response)
except datadog_api_client.v1.ApiException as e:
print("Exception when calling DowntimesApi->update_downtime: %s\n" % e)
require 'time'
require 'datadog_api_client/v1'
# setup authorization
DatadogAPIClient::V1.configure do |config|
# Configure API key authorization: apiKeyAuth
config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['apiKeyAuth'] = 'Bearer'
# Configure API key authorization: appKeyAuth
config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['appKeyAuth'] = 'Bearer'
end
api_instance = DatadogAPIClient::V1::DowntimesApi.new
downtime_id = 123456 # Integer | ID of the downtime to update.
body = DatadogAPIClient::V1::Downtime.new # Downtime | Update a downtime request body.
begin
# Update a downtime
result = api_instance.update_downtime(downtime_id, body)
p result
rescue DatadogAPIClient::V1::ApiError => e
puts "Error when calling DowntimesApi->update_downtime: #{e}"
end