Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32232,11 +32232,17 @@ components:
recipients:
$ref: '#/components/schemas/MonitorNotificationRuleRecipients'
scope:
$ref: '#/components/schemas/MonitorNotificationRuleScope'
$ref: '#/components/schemas/MonitorNotificationRuleConditionScope'
required:
- scope
- recipients
type: object
MonitorNotificationRuleConditionScope:
description: The scope to which the monitor applied.
example: transition_type:alert
maxLength: 3000
minLength: 1
type: string
MonitorNotificationRuleConditionalRecipients:
description: Use conditional recipients to define different recipients for different
situations.
Expand Down Expand Up @@ -32289,6 +32295,20 @@ components:
description: Filter used to associate the notification rule with monitors.
oneOf:
- $ref: '#/components/schemas/MonitorNotificationRuleFilterTags'
- $ref: '#/components/schemas/MonitorNotificationRuleFilterScope'
MonitorNotificationRuleFilterScope:
additionalProperties: false
description: Filter monitors by scope. Monitors must match the scope evaluation.
properties:
scope:
description: The scope to which the monitor notification rule applies.
example: env:prod AND datacenter:us-east-1
maxLength: 3000
minLength: 1
type: string
required:
- scope
type: object
MonitorNotificationRuleFilterTags:
additionalProperties: false
description: Filter monitors by tags. Monitors must match all tags.
Expand Down Expand Up @@ -32417,12 +32437,6 @@ components:
description: An object related to a monitor notification rule.
oneOf:
- $ref: '#/components/schemas/User'
MonitorNotificationRuleScope:
description: The scope to which the monitor applied.
example: transition_type:alert
maxLength: 3000
minLength: 1
type: string
MonitorNotificationRuleUpdateRequest:
description: Request for updating a monitor notification rule.
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2025-11-11T21:28:39.129Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"log": {
"_recordingName": "Monitors/Create a monitor notification rule with scope returns \"OK\" response",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.6"
},
"entries": [
{
"_id": "e4be868dca8d74340ab17b06ab95288e",
"_order": 0,
"cache": {},
"request": {
"bodySize": 235,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 589,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"data\":{\"attributes\":{\"filter\":{\"scope\":\"test:test-create_a_monitor_notification_rule_with_scope_returns_ok_response-1762896519\"},\"name\":\"test rule\",\"recipients\":[\"slack-test-channel\",\"jira-test\"]},\"type\":\"monitor-notification-rule\"}}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v2/monitor/notification_rule"
},
"response": {
"bodySize": 1002,
"content": {
"mimeType": "application/json",
"size": 1002,
"text": "{\"data\":{\"type\":\"monitor-notification-rule\",\"attributes\":{\"modified_at\":\"1970-01-01T00:00:00+00:00\",\"filter\":{\"scope\":\"test:test-create_a_monitor_notification_rule_with_scope_returns_ok_response-1762896519\"},\"name\":\"test rule\",\"recipients\":[\"slack-test-channel\",\"jira-test\"],\"created_at\":\"2025-11-11T21:28:40.032148+00:00\"},\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}},\"id\":\"bbea2907-c191-48d0-9e0f-1ec5881ee37c\"},\"included\":[{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"created_at\":\"2020-12-29T22:58:44.733921+00:00\",\"modified_at\":\"2021-04-27T13:54:01.547888+00:00\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":true,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\",\"last_login_time\":null}}]}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 704,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2025-11-11T21:28:39.744Z",
"time": 338
},
{
"_id": "00d5556e17c827a0dc4aa1c17361ac26",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "*/*"
}
],
"headersSize": 562,
"httpVersion": "HTTP/1.1",
"method": "DELETE",
"queryString": [],
"url": "https://api.datadoghq.com/api/v2/monitor/notification_rule/bbea2907-c191-48d0-9e0f-1ec5881ee37c"
},
"response": {
"bodySize": 0,
"content": {
"mimeType": "text/html; charset=utf-8",
"size": 0
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "text/html; charset=utf-8"
}
],
"headersSize": 690,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 204,
"statusText": "No Content"
},
"startedDateTime": "2025-11-11T21:28:40.100Z",
"time": 249
}
],
"pages": [],
"version": "1.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2025-11-11T21:28:40.357Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
{
"log": {
"_recordingName": "Monitors/Update a monitor notification rule with scope returns \"OK\" response",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.6"
},
"entries": [
{
"_id": "00cda7cffe4c75a8bc28baa5933cbfec",
"_order": 0,
"cache": {},
"request": {
"bodySize": 222,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 589,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"data\":{\"attributes\":{\"filter\":{\"tags\":[\"app:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"]},\"name\":\"test rule\",\"recipients\":[\"slack-monitor-app\"]},\"type\":\"monitor-notification-rule\"}}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v2/monitor/notification_rule"
},
"response": {
"bodySize": 989,
"content": {
"mimeType": "application/json",
"size": 989,
"text": "{\"data\":{\"type\":\"monitor-notification-rule\",\"attributes\":{\"recipients\":[\"slack-monitor-app\"],\"modified_at\":\"1970-01-01T00:00:00+00:00\",\"created_at\":\"2025-11-11T21:28:40.540848+00:00\",\"name\":\"test rule\",\"filter\":{\"tags\":[\"app:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"]}},\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}},\"id\":\"827442a0-5d3e-408c-a930-7ac44775fff1\"},\"included\":[{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"created_at\":\"2020-12-29T22:58:44.733921+00:00\",\"modified_at\":\"2021-04-27T13:54:01.547888+00:00\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":true,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\",\"last_login_time\":null}}]}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 703,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2025-11-11T21:28:40.361Z",
"time": 227
},
{
"_id": "91f1a6b8c117246dfceb72c3ec665801",
"_order": 0,
"cache": {},
"request": {
"bodySize": 270,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 627,
"httpVersion": "HTTP/1.1",
"method": "PATCH",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"data\":{\"attributes\":{\"filter\":{\"scope\":\"test:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"},\"name\":\"updated rule\",\"recipients\":[\"slack-test-channel\"]},\"id\":\"827442a0-5d3e-408c-a930-7ac44775fff1\",\"type\":\"monitor-notification-rule\"}}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1"
},
"response": {
"bodySize": 1000,
"content": {
"mimeType": "application/json",
"size": 1000,
"text": "{\"data\":{\"type\":\"monitor-notification-rule\",\"attributes\":{\"filter\":{\"scope\":\"test:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"},\"recipients\":[\"slack-test-channel\"],\"created_at\":\"2025-11-11T21:28:40.540848+00:00\",\"name\":\"updated rule\",\"modified_at\":\"2025-11-11T21:28:40.815544+00:00\"},\"id\":\"827442a0-5d3e-408c-a930-7ac44775fff1\",\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}},\"included\":[{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"created_at\":\"2020-12-29T22:58:44.733921+00:00\",\"modified_at\":\"2021-04-27T13:54:01.547888+00:00\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":true,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\",\"last_login_time\":null}}]}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 704,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2025-11-11T21:28:40.594Z",
"time": 277
},
{
"_id": "d37e3788b9fdb86941bed09511fde9b5",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "*/*"
}
],
"headersSize": 562,
"httpVersion": "HTTP/1.1",
"method": "DELETE",
"queryString": [],
"url": "https://api.datadoghq.com/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1"
},
"response": {
"bodySize": 0,
"content": {
"mimeType": "text/html; charset=utf-8",
"size": 0
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "text/html; charset=utf-8"
}
],
"headersSize": 690,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 204,
"statusText": "No Content"
},
"startedDateTime": "2025-11-11T21:28:40.876Z",
"time": 246
}
],
"pages": [],
"version": "1.2"
}
}
18 changes: 18 additions & 0 deletions features/v2/monitors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ Feature: Monitors
Then the response status is 200 OK
And the response "data.attributes.name" is equal to "test rule"

@team:DataDog/monitor-app
Scenario: Create a monitor notification rule with scope returns "OK" response
Given new "CreateMonitorNotificationRule" request
And body with value {"data": {"attributes": {"filter": {"scope": "test:{{ unique_lower }}"}, "name": "test rule", "recipients": ["slack-test-channel", "jira-test"]}, "type": "monitor-notification-rule"}}
When the request is sent
Then the response status is 200 OK
And the response "data.attributes.name" is equal to "test rule"

@skip-validation @team:DataDog/monitor-app
Scenario: Create a monitor user template returns "Bad Request" response
Given new "CreateMonitorUserTemplate" request
Expand Down Expand Up @@ -272,6 +280,16 @@ Feature: Monitors
Then the response status is 200 OK
And the response "data.attributes.name" is equal to "updated rule"

@team:DataDog/monitor-app
Scenario: Update a monitor notification rule with scope returns "OK" response
Given there is a valid "monitor_notification_rule" in the system
And new "UpdateMonitorNotificationRule" request
And request contains "rule_id" parameter from "monitor_notification_rule.data.id"
And body with value {"data": {"attributes": {"filter": {"scope": "test:{{ unique_lower }}"}, "name": "updated rule", "recipients": ["slack-test-channel"]}, "id": "{{ monitor_notification_rule.data.id }}", "type": "monitor-notification-rule"}}
When the request is sent
Then the response status is 200 OK
And the response "data.attributes.name" is equal to "updated rule"

@skip-validation @team:DataDog/monitor-app
Scenario: Update a monitor user template to a new version returns "Bad Request" response
Given there is a valid "monitor_user_template" in the system
Expand Down
1 change: 1 addition & 0 deletions services/monitors/src/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export { MonitorNotificationRuleCreateRequest } from "./models/MonitorNotificati
export { MonitorNotificationRuleCreateRequestData } from "./models/MonitorNotificationRuleCreateRequestData";
export { MonitorNotificationRuleData } from "./models/MonitorNotificationRuleData";
export { MonitorNotificationRuleFilter } from "./models/MonitorNotificationRuleFilter";
export { MonitorNotificationRuleFilterScope } from "./models/MonitorNotificationRuleFilterScope";
export { MonitorNotificationRuleFilterTags } from "./models/MonitorNotificationRuleFilterTags";
export { MonitorNotificationRuleListResponse } from "./models/MonitorNotificationRuleListResponse";
export { MonitorNotificationRuleRelationships } from "./models/MonitorNotificationRuleRelationships";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { UnparsedObject } from "@datadog/datadog-api-client";

import { MonitorNotificationRuleFilterScope } from "./MonitorNotificationRuleFilterScope";
import { MonitorNotificationRuleFilterTags } from "./MonitorNotificationRuleFilterTags";

/**
* Filter used to associate the notification rule with monitors.
*/
export type MonitorNotificationRuleFilter =
| MonitorNotificationRuleFilterTags
| MonitorNotificationRuleFilterScope
| UnparsedObject;
Loading