Get all monitor notification rules

GET https://api.ap1.datadoghq.com/api/v2/monitor/notification_rulehttps://api.ap2.datadoghq.com/api/v2/monitor/notification_rulehttps://api.datadoghq.eu/api/v2/monitor/notification_rulehttps://api.ddog-gov.com/api/v2/monitor/notification_rulehttps://api.us2.ddog-gov.com/api/v2/monitor/notification_rulehttps://api.datadoghq.com/api/v2/monitor/notification_rulehttps://api.us3.datadoghq.com/api/v2/monitor/notification_rulehttps://api.us5.datadoghq.com/api/v2/monitor/notification_rule

Overview

Returns a list of all monitor notification rules. This endpoint requires the monitors_read permission.

OAuth apps require the monitors_read authorization scope to access this endpoint.

Arguments

Query Strings

Name

Type

Description

page

integer

The page to start paginating from. If page is not specified, the argument defaults to the first page.

per_page

integer

The number of rules to return per page. If per_page is not specified, the argument defaults to 100.

sort

string

String for sort order, composed of field and sort order separated by a colon, for example name:asc. Supported sort directions: asc, desc. Supported fields: name, created_at.

filters

string

JSON-encoded filter object. Supported keys:

  • text: Free-text query matched against rule name, tags, and recipients.
  • tags: Array of strings. Return rules that have any of these tags.
  • recipients: Array of strings. Return rules that have any of these recipients.

include

string

Comma-separated list of resource paths for related resources to include in the response. Supported resource path is created_by.

Response

OK

Response for retrieving all monitor notification rules.

Expand All

Field

Type

Description

data

[object]

A list of monitor notification rules.

attributes

object

Attributes of the monitor notification rule.

conditional_recipients

object

Use conditional recipients to define different recipients for different situations. Cannot be used with recipients.

conditions [required]

[object]

Conditions of the notification rule.

recipients [required]

[string]

A list of recipients to notify. Uses the same format as the monitor message field. Must not start with an '@'.

scope [required]

string

Defines the condition under which the recipients are notified. Supported formats:

  • Monitor status condition using transition_type:<status>, for example transition_type:is_alert.
  • A single tag key:value pair, for example env:prod.

fallback_recipients

[string]

If none of the conditions applied, fallback_recipients will get notified.

created

date-time

Creation time of the monitor notification rule.

filter

 <oneOf>

Specifies the matching criteria for monitor notifications.

Option 1

object

Filters monitor notifications by a list of tag key:value pairs.

tags [required]

[string]

A list of tag key:value pairs (e.g. team:product). All tags must match (AND semantics).

Option 2

object

Filters monitor notifications using a scope expression over key:value pairs with boolean logic (AND, OR, NOT).

scope [required]

string

A scope expression composed by key:value pairs (e.g. service:foo) with boolean operators (AND, OR, NOT) and parentheses for grouping.

modified

date-time

Time the monitor notification rule was last modified.

name

string

The name of the monitor notification rule.

recipients

[string]

A list of recipients to notify. Uses the same format as the monitor message field. Must not start with an '@'. Cannot be used with conditional_recipients.

id

string

The ID of the monitor notification rule.

relationships

object

All relationships associated with monitor notification rule.

created_by

object

The user who created the monitor notification rule.

data

object

Data for the user who created the monitor notification rule.

id

string

User ID of the monitor notification rule creator.

type

enum

Users resource type. Allowed enum values: users

default: users

type

enum

Monitor notification rule resource type. Allowed enum values: monitor-notification-rule

default: monitor-notification-rule

included

[ <oneOf>]

Array of objects related to the monitor notification rules.

Option 1

object

User object returned by the API.

attributes

object

Attributes of user object returned by the API.

created_at

date-time

The ISO 8601 timestamp of when the user account was created.

disabled

boolean

Whether the user account is deactivated. Disabled users cannot log in.

email

string

The email address of the user, used for login and notifications.

handle

string

The unique handle (username) of the user, typically matching their email prefix.

icon

string

URL of the user's profile icon, typically a Gravatar URL derived from the email address.

last_login_time

date-time

The ISO 8601 timestamp of the user's most recent login, or null if the user has never logged in.

mfa_enabled

boolean

Whether multi-factor authentication (MFA) is enabled for the user's account.

modified_at

date-time

The ISO 8601 timestamp of when the user account was last modified.

name

string

The full display name of the user as shown in the Datadog UI.

service_account

boolean

Whether this is a service account rather than a human user. Service accounts are used for programmatic API access.

status

string

The current status of the user account (for example, Active, Pending, or Disabled).

title

string

The job title of the user (for example, "Senior Engineer" or "Product Manager").

uuid

string

The globally unique identifier (UUID) of the user.

verified

boolean

Whether the user's email address has been verified.

id

string

ID of the user.

relationships

object

Relationships of the user object returned by the API.

org

object

Relationship to an organization.

data [required]

object

Relationship to organization object.

id [required]

string

ID of the organization.

type [required]

enum

Organizations resource type. Allowed enum values: orgs

default: orgs

other_orgs

object

Relationship to organizations.

data [required]

[object]

Relationships to organization objects.

id [required]

string

ID of the organization.

type [required]

enum

Organizations resource type. Allowed enum values: orgs

default: orgs

other_users

object

Relationship to users.

data [required]

[object]

Relationships to user objects.

id [required]

string

A unique identifier that represents the user.

type [required]

enum

Users resource type. Allowed enum values: users

default: users

roles

object

Relationship to roles.

data

[object]

An array containing type and the unique identifier of a role.

id

string

The unique identifier of the role.

type

enum

Roles type. Allowed enum values: roles

default: roles

type

enum

Users resource type. Allowed enum values: users

default: users

{
  "data": [
    {
      "attributes": {
        "conditional_recipients": {
          "conditions": [
            {
              "recipients": [
                "slack-test-channel",
                "jira-test"
              ],
              "scope": "transition_type:is_alert"
            }
          ],
          "fallback_recipients": [
            "slack-test-channel",
            "jira-test"
          ]
        },
        "created": "2020-01-02T03:04:00.000Z",
        "filter": {
          "tags": [
            "team:product",
            "host:abc"
          ]
        },
        "modified": "2020-01-02T03:04:00.000Z",
        "name": "A notification rule name",
        "recipients": [
          "slack-test-channel",
          "jira-test"
        ]
      },
      "id": "00000000-0000-1234-0000-000000000000",
      "relationships": {
        "created_by": {
          "data": {
            "id": "00000000-0000-1234-0000-000000000000",
            "type": "users"
          }
        }
      },
      "type": "monitor-notification-rule"
    }
  ],
  "included": [
    {
      "attributes": {
        "created_at": "2019-09-19T10:00:00.000Z",
        "disabled": false,
        "email": "string",
        "handle": "string",
        "icon": "string",
        "last_login_time": "2019-09-19T10:00:00.000Z",
        "mfa_enabled": false,
        "modified_at": "2019-09-19T10:00:00.000Z",
        "name": "string",
        "service_account": false,
        "status": "string",
        "title": "string",
        "uuid": "string",
        "verified": false
      },
      "id": "string",
      "relationships": {
        "org": {
          "data": {
            "id": "00000000-0000-beef-0000-000000000000",
            "type": "orgs"
          }
        },
        "other_orgs": {
          "data": [
            {
              "id": "00000000-0000-beef-0000-000000000000",
              "type": "orgs"
            }
          ]
        },
        "other_users": {
          "data": [
            {
              "id": "00000000-0000-0000-2345-000000000000",
              "type": "users"
            }
          ]
        },
        "roles": {
          "data": [
            {
              "id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
              "type": "roles"
            }
          ]
        }
      },
      "type": "users"
    }
  ]
}

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example

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

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.monitors_api import MonitorsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.get_monitor_notification_rules()

    print(response)

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Get all monitor notification rules returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::MonitorsAPI.new
p api_instance.get_monitor_notification_rules()

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// Get all monitor notification rules returns "OK" response

package main

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

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

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewMonitorsApi(apiClient)
	resp, r, err := api.GetMonitorNotificationRules(ctx, *datadogV2.NewGetMonitorNotificationRulesOptionalParameters())

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

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

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Get all monitor notification rules returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MonitorsApi;
import com.datadog.api.client.v2.model.MonitorNotificationRuleListResponse;

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

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

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Get all monitor notification rules returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_monitors::GetMonitorNotificationRulesOptionalParams;
use datadog_api_client::datadogV2::api_monitors::MonitorsAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = MonitorsAPI::with_config(configuration);
    let resp = api
        .get_monitor_notification_rules(GetMonitorNotificationRulesOptionalParams::default())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

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

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Get all monitor notification rules returns "OK" response
 */

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

const configuration = client.createConfiguration();
const apiInstance = new v2.MonitorsApi(configuration);

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

Instructions

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

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