Skip to content

Commit 9f9efc2

Browse files
dorg-kandersontruthbk
authored andcommitted
Fix reverse content match (#524)
* Update http_check.yaml.erb * Update http_check.pp * Update datadog_agent_integrations_http_check_spec.rb * Update datadog_agent_integrations_http_check_spec.rb * Update datadog_agent_integrations_http_check_spec.rb * Update datadog_agent_integrations_http_check_spec.rb * Update http_check.yaml.erb
1 parent 3411573 commit 9f9efc2

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

manifests/integrations/http_check.pp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
# alerts only if the check fails x times within the last y attempts
3131
# where x is the threshold and y is the window.
3232
#
33+
# reverse_content_match
34+
# When (optional) true, reverses the behavior of the content_match option,
35+
# i.e. the HTTP check will report as DOWN if the string or expression
36+
# in content_match IS found. (default is false)
37+
#
3338
# content_match
3439
# The (optional) content_match parameter will allow the check
3540
# to look for a particular string within the response. The check
@@ -166,6 +171,7 @@
166171
$threshold = undef,
167172
$window = undef,
168173
$content_match = undef,
174+
$reverse_content_match = false,
169175
$include_content = false,
170176
$http_response_status_code = undef,
171177
$collect_response_time = true,
@@ -196,6 +202,7 @@
196202
'threshold' => $threshold,
197203
'window' => $window,
198204
'content_match' => $content_match,
205+
'reverse_content_match' => $reverse_content_match,
199206
'include_content' => $include_content,
200207
'http_response_status_code' => $http_response_status_code,
201208
'collect_response_time' => $collect_response_time,

spec/classes/datadog_agent_integrations_http_check_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
it { should contain_file(conf_file).without_content(%{threshold: }) }
4343
it { should contain_file(conf_file).without_content(%r{window: }) }
4444
it { should contain_file(conf_file).without_content(%r{content_match: }) }
45+
it { should contain_file(conf_file).without_content(%r{reverse_content_match: true}) }
4546
it { should contain_file(conf_file).without_content(%r{include_content: true}) }
4647
it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) }
4748
it { should contain_file(conf_file).without_content(%r{http_response_status_code: }) }
@@ -67,6 +68,7 @@
6768
threshold: 456,
6869
window: 789,
6970
content_match: 'foomatch',
71+
reverse_content_match: true,
7072
include_content: true,
7173
collect_response_time: false,
7274
disable_ssl_validation: true,
@@ -90,6 +92,7 @@
9092
it { should contain_file(conf_file).with_content(%r{threshold: 456}) }
9193
it { should contain_file(conf_file).with_content(%r{window: 789}) }
9294
it { should contain_file(conf_file).with_content(%r{content_match: 'foomatch'}) }
95+
it { should contain_file(conf_file).with_content(%r{reverse_content_match: true}) }
9396
it { should contain_file(conf_file).with_content(%r{include_content: true}) }
9497
it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) }
9598
it { should contain_file(conf_file).with_content(%r{disable_ssl_validation: true}) }

templates/agent-conf.d/http_check.yaml.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ instances:
3232
<% if instance['window'] -%>
3333
window: <%= instance['window'] %>
3434
<% end -%>
35+
<% if instance['reverse_content_match'] -%>
36+
reverse_content_match: <%= instance["reverse_content_match"] %>
37+
<% end -%>
3538
<% if instance['content_match'] -%>
3639
content_match: '<%= instance["content_match"] %>'
3740
<% end -%>

0 commit comments

Comments
 (0)