Skip to content

Commit 4131ee5

Browse files
authored
Fix monitor validation on default tags (#3296)
Fix monitor validation on default tags Co-authored-by: shane.yuan <[email protected]>
1 parent ae0d457 commit 4131ee5

6 files changed

+562
-149
lines changed

datadog/resource_datadog_monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func resourceDatadogMonitor() *schema.Resource {
3333
ReadContext: resourceDatadogMonitorRead,
3434
UpdateContext: resourceDatadogMonitorUpdate,
3535
DeleteContext: resourceDatadogMonitorDelete,
36-
CustomizeDiff: customdiff.All(resourceDatadogMonitorCustomizeDiff, tagDiff),
36+
CustomizeDiff: customdiff.All(tagDiff, resourceDatadogMonitorCustomizeDiff),
3737
Importer: &schema.ResourceImporter{
3838
StateContext: schema.ImportStatePassthroughContext,
3939
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-06-06T17:01:15.824693+02:00
1+
2025-10-22T15:39:35.751951-04:00

datadog/tests/cassettes/TestAccDatadogMonitor_DefaultTags.yaml

Lines changed: 147 additions & 147 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-10-22T15:16:31.787289-04:00
Lines changed: 365 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,365 @@
1+
---
2+
version: 2
3+
interactions:
4+
- id: 0
5+
request:
6+
proto: HTTP/1.1
7+
proto_major: 1
8+
proto_minor: 1
9+
content_length: 465
10+
transfer_encoding: []
11+
trailer: {}
12+
host: api.datadoghq.com
13+
remote_addr: ""
14+
request_uri: ""
15+
body: |
16+
{"draft_status":"published","message":"updated message Notify: @hipchat-channel","name":"tf-TestAccDatadogMonitor_WithTagConfig-local-1761160591","options":{"include_tags":true,"new_host_delay":300,"no_data_timeframe":10,"notify_no_data":false,"require_full_window":true,"thresholds":{"critical":2}},"priority":null,"query":"avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} \u003e 2","restricted_roles":null,"tags":["foo:bar"],"type":"query alert"}
17+
form: {}
18+
headers:
19+
Accept:
20+
- application/json
21+
Content-Type:
22+
- application/json
23+
url: https://api.datadoghq.com/api/v1/monitor/validate
24+
method: POST
25+
response:
26+
proto: HTTP/1.1
27+
proto_major: 1
28+
proto_minor: 1
29+
transfer_encoding: []
30+
trailer: {}
31+
content_length: 3
32+
uncompressed: false
33+
body: |
34+
{}
35+
headers:
36+
Content-Type:
37+
- application/json
38+
status: 200 OK
39+
code: 200
40+
duration: 114.548375ms
41+
- id: 1
42+
request:
43+
proto: HTTP/1.1
44+
proto_major: 1
45+
proto_minor: 1
46+
content_length: 155
47+
transfer_encoding: []
48+
trailer: {}
49+
host: api.datadoghq.com
50+
remote_addr: ""
51+
request_uri: ""
52+
body: |
53+
{"data":{"attributes":{"policy":{"tag_key":"foo","tag_key_required":true,"valid_tag_values":["bar"]},"policy_type":"tag"},"type":"monitor-config-policy"}}
54+
form: {}
55+
headers:
56+
Accept:
57+
- application/json
58+
Content-Type:
59+
- application/json
60+
url: https://api.datadoghq.com/api/v2/monitor/policy
61+
method: POST
62+
response:
63+
proto: HTTP/1.1
64+
proto_major: 1
65+
proto_minor: 1
66+
transfer_encoding:
67+
- chunked
68+
trailer: {}
69+
content_length: -1
70+
uncompressed: true
71+
body: |
72+
{"data":{"type":"monitor-config-policy","id":"6d4ccf64-8d28-40f4-8a3b-7b9b7f2cbc5a","attributes":{"policy":{"tag_key_required":true,"valid_tag_values":["bar"],"tag_key":"foo"},"policy_type":"tag"}}}
73+
headers:
74+
Content-Type:
75+
- application/json
76+
status: 200 OK
77+
code: 200
78+
duration: 100.749417ms
79+
- id: 2
80+
request:
81+
proto: HTTP/1.1
82+
proto_major: 1
83+
proto_minor: 1
84+
content_length: 465
85+
transfer_encoding: []
86+
trailer: {}
87+
host: api.datadoghq.com
88+
remote_addr: ""
89+
request_uri: ""
90+
body: |
91+
{"draft_status":"published","message":"updated message Notify: @hipchat-channel","name":"tf-TestAccDatadogMonitor_WithTagConfig-local-1761160591","options":{"include_tags":true,"new_host_delay":300,"no_data_timeframe":10,"notify_no_data":false,"require_full_window":true,"thresholds":{"critical":2}},"priority":null,"query":"avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} \u003e 2","restricted_roles":null,"tags":["foo:bar"],"type":"query alert"}
92+
form: {}
93+
headers:
94+
Accept:
95+
- application/json
96+
Content-Type:
97+
- application/json
98+
url: https://api.datadoghq.com/api/v1/monitor/validate
99+
method: POST
100+
response:
101+
proto: HTTP/1.1
102+
proto_major: 1
103+
proto_minor: 1
104+
transfer_encoding: []
105+
trailer: {}
106+
content_length: 3
107+
uncompressed: false
108+
body: |
109+
{}
110+
headers:
111+
Content-Type:
112+
- application/json
113+
status: 200 OK
114+
code: 200
115+
duration: 114.822125ms
116+
- id: 3
117+
request:
118+
proto: HTTP/1.1
119+
proto_major: 1
120+
proto_minor: 1
121+
content_length: 442
122+
transfer_encoding: []
123+
trailer: {}
124+
host: api.datadoghq.com
125+
remote_addr: ""
126+
request_uri: ""
127+
body: |
128+
{"draft_status":"published","message":"updated message Notify: @hipchat-channel","name":"tf-TestAccDatadogMonitor_WithTagConfig-local-1761160591","options":{"include_tags":true,"new_host_delay":300,"notify_no_data":false,"require_full_window":true,"thresholds":{"critical":2}},"priority":null,"query":"avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} \u003e 2","restricted_roles":null,"tags":["foo:bar"],"type":"query alert"}
129+
form: {}
130+
headers:
131+
Accept:
132+
- application/json
133+
Content-Type:
134+
- application/json
135+
url: https://api.datadoghq.com/api/v1/monitor
136+
method: POST
137+
response:
138+
proto: HTTP/1.1
139+
proto_major: 1
140+
proto_minor: 1
141+
transfer_encoding:
142+
- chunked
143+
trailer: {}
144+
content_length: -1
145+
uncompressed: true
146+
body: |
147+
{"id":229387457,"org_id":321813,"type":"query alert","name":"tf-TestAccDatadogMonitor_WithTagConfig-local-1761160591","message":"updated message Notify: @hipchat-channel","tags":["foo:bar"],"query":"avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2","options":{"include_tags":true,"new_host_delay":300,"notify_no_data":false,"require_full_window":true,"thresholds":{"critical":2.0},"notify_audit":false,"silenced":{}},"multi":true,"created_at":1761160593000,"created":"2025-10-22T19:16:33.840083+00:00","modified":"2025-10-22T19:16:33.840083+00:00","deleted":null,"priority":null,"restricted_roles":null,"restriction_policy":null,"overall_state_modified":null,"overall_state":"No Data","creator":{"name":"frog","handle":"[email protected]","email":"[email protected]","id":1445416}}
148+
headers:
149+
Content-Type:
150+
- application/json
151+
status: 200 OK
152+
code: 200
153+
duration: 2.626365875s
154+
- id: 4
155+
request:
156+
proto: HTTP/1.1
157+
proto_major: 1
158+
proto_minor: 1
159+
content_length: 465
160+
transfer_encoding: []
161+
trailer: {}
162+
host: api.datadoghq.com
163+
remote_addr: ""
164+
request_uri: ""
165+
body: |
166+
{"draft_status":"published","message":"updated message Notify: @hipchat-channel","name":"tf-TestAccDatadogMonitor_WithTagConfig-local-1761160591","options":{"include_tags":true,"new_host_delay":300,"no_data_timeframe":10,"notify_no_data":false,"require_full_window":true,"thresholds":{"critical":2}},"priority":null,"query":"avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} \u003e 2","restricted_roles":null,"tags":["foo:bar"],"type":"query alert"}
167+
form: {}
168+
headers:
169+
Accept:
170+
- application/json
171+
Content-Type:
172+
- application/json
173+
url: https://api.datadoghq.com/api/v1/monitor/229387457/validate
174+
method: POST
175+
response:
176+
proto: HTTP/1.1
177+
proto_major: 1
178+
proto_minor: 1
179+
transfer_encoding: []
180+
trailer: {}
181+
content_length: 3
182+
uncompressed: false
183+
body: |
184+
{}
185+
headers:
186+
Content-Type:
187+
- application/json
188+
status: 200 OK
189+
code: 200
190+
duration: 97.938667ms
191+
- id: 5
192+
request:
193+
proto: HTTP/1.1
194+
proto_major: 1
195+
proto_minor: 1
196+
content_length: 0
197+
transfer_encoding: []
198+
trailer: {}
199+
host: api.datadoghq.com
200+
remote_addr: ""
201+
request_uri: ""
202+
body: ""
203+
form: {}
204+
headers:
205+
Accept:
206+
- application/json
207+
url: https://api.datadoghq.com/api/v2/monitor/policy/6d4ccf64-8d28-40f4-8a3b-7b9b7f2cbc5a
208+
method: GET
209+
response:
210+
proto: HTTP/1.1
211+
proto_major: 1
212+
proto_minor: 1
213+
transfer_encoding:
214+
- chunked
215+
trailer: {}
216+
content_length: -1
217+
uncompressed: true
218+
body: |
219+
{"data":{"type":"monitor-config-policy","attributes":{"policy":{"tag_key_required":true,"valid_tag_values":["bar"],"tag_key":"foo"},"policy_type":"tag"},"id":"6d4ccf64-8d28-40f4-8a3b-7b9b7f2cbc5a"}}
220+
headers:
221+
Content-Type:
222+
- application/json
223+
status: 200 OK
224+
code: 200
225+
duration: 74.235583ms
226+
- id: 6
227+
request:
228+
proto: HTTP/1.1
229+
proto_major: 1
230+
proto_minor: 1
231+
content_length: 0
232+
transfer_encoding: []
233+
trailer: {}
234+
host: api.datadoghq.com
235+
remote_addr: ""
236+
request_uri: ""
237+
body: ""
238+
form: {}
239+
headers:
240+
Accept:
241+
- application/json
242+
url: https://api.datadoghq.com/api/v1/monitor/229387457
243+
method: GET
244+
response:
245+
proto: HTTP/1.1
246+
proto_major: 1
247+
proto_minor: 1
248+
transfer_encoding:
249+
- chunked
250+
trailer: {}
251+
content_length: -1
252+
uncompressed: true
253+
body: |
254+
{"id":229387457,"org_id":321813,"type":"query alert","name":"tf-TestAccDatadogMonitor_WithTagConfig-local-1761160591","message":"updated message Notify: @hipchat-channel","tags":["foo:bar"],"query":"avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} > 2","options":{"include_tags":true,"new_host_delay":300,"notify_no_data":false,"require_full_window":true,"thresholds":{"critical":2.0},"notify_audit":false,"silenced":{}},"multi":true,"created_at":1761160593000,"created":"2025-10-22T19:16:33.840083+00:00","modified":"2025-10-22T19:16:33.840083+00:00","deleted":null,"priority":null,"restricted_roles":null,"overall_state_modified":null,"overall_state":"No Data","creator":{"name":"frog","email":"[email protected]","handle":"[email protected]","id":1445416}}
255+
headers:
256+
Content-Type:
257+
- application/json
258+
status: 200 OK
259+
code: 200
260+
duration: 122.4685ms
261+
- id: 7
262+
request:
263+
proto: HTTP/1.1
264+
proto_major: 1
265+
proto_minor: 1
266+
content_length: 465
267+
transfer_encoding: []
268+
trailer: {}
269+
host: api.datadoghq.com
270+
remote_addr: ""
271+
request_uri: ""
272+
body: |
273+
{"draft_status":"published","message":"updated message Notify: @hipchat-channel","name":"tf-TestAccDatadogMonitor_WithTagConfig-local-1761160591","options":{"include_tags":true,"new_host_delay":300,"no_data_timeframe":10,"notify_no_data":false,"require_full_window":true,"thresholds":{"critical":2}},"priority":null,"query":"avg(last_1h):avg:aws.ec2.cpu{environment:foo,host:foo} by {host} \u003e 2","restricted_roles":null,"tags":["foo:bar"],"type":"query alert"}
274+
form: {}
275+
headers:
276+
Accept:
277+
- application/json
278+
Content-Type:
279+
- application/json
280+
url: https://api.datadoghq.com/api/v1/monitor/229387457/validate
281+
method: POST
282+
response:
283+
proto: HTTP/1.1
284+
proto_major: 1
285+
proto_minor: 1
286+
transfer_encoding: []
287+
trailer: {}
288+
content_length: 3
289+
uncompressed: false
290+
body: |
291+
{}
292+
headers:
293+
Content-Type:
294+
- application/json
295+
status: 200 OK
296+
code: 200
297+
duration: 86.904083ms
298+
- id: 8
299+
request:
300+
proto: HTTP/1.1
301+
proto_major: 1
302+
proto_minor: 1
303+
content_length: 0
304+
transfer_encoding: []
305+
trailer: {}
306+
host: api.datadoghq.com
307+
remote_addr: ""
308+
request_uri: ""
309+
body: ""
310+
form: {}
311+
headers:
312+
Accept:
313+
- '*/*'
314+
url: https://api.datadoghq.com/api/v2/monitor/policy/6d4ccf64-8d28-40f4-8a3b-7b9b7f2cbc5a
315+
method: DELETE
316+
response:
317+
proto: HTTP/1.1
318+
proto_major: 1
319+
proto_minor: 1
320+
transfer_encoding: []
321+
trailer: {}
322+
content_length: 0
323+
uncompressed: false
324+
body: ""
325+
headers:
326+
Content-Type:
327+
- text/html; charset=utf-8
328+
status: 204 No Content
329+
code: 204
330+
duration: 73.510291ms
331+
- id: 9
332+
request:
333+
proto: HTTP/1.1
334+
proto_major: 1
335+
proto_minor: 1
336+
content_length: 0
337+
transfer_encoding: []
338+
trailer: {}
339+
host: api.datadoghq.com
340+
remote_addr: ""
341+
request_uri: ""
342+
body: ""
343+
form: {}
344+
headers:
345+
Accept:
346+
- application/json
347+
url: https://api.datadoghq.com/api/v1/monitor/229387457
348+
method: DELETE
349+
response:
350+
proto: HTTP/1.1
351+
proto_major: 1
352+
proto_minor: 1
353+
transfer_encoding:
354+
- chunked
355+
trailer: {}
356+
content_length: -1
357+
uncompressed: true
358+
body: |
359+
{"deleted_monitor_id":229387457}
360+
headers:
361+
Content-Type:
362+
- application/json
363+
status: 200 OK
364+
code: 200
365+
duration: 2.889818375s

0 commit comments

Comments
 (0)