diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index 0fb572f8..bd387707 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -30,6 +30,11 @@ # alerts only if the check fails x times within the last y attempts # where x is the threshold and y is the window. # +# reverse_content_match +# When (optional) true, reverses the behavior of the content_match option, +# i.e. the HTTP check will report as DOWN if the string or expression +# in content_match IS found. (default is false) +# # content_match # The (optional) content_match parameter will allow the check # to look for a particular string within the response. The check @@ -166,6 +171,7 @@ $threshold = undef, $window = undef, $content_match = undef, + $reverse_content_match = false, $include_content = false, $http_response_status_code = undef, $collect_response_time = true, @@ -196,6 +202,7 @@ 'threshold' => $threshold, 'window' => $window, 'content_match' => $content_match, + 'reverse_content_match' => $reverse_content_match, 'include_content' => $include_content, 'http_response_status_code' => $http_response_status_code, 'collect_response_time' => $collect_response_time, diff --git a/spec/classes/datadog_agent_integrations_http_check_spec.rb b/spec/classes/datadog_agent_integrations_http_check_spec.rb index 9eee9af4..cf40f447 100644 --- a/spec/classes/datadog_agent_integrations_http_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_http_check_spec.rb @@ -42,6 +42,7 @@ it { should contain_file(conf_file).without_content(%{threshold: }) } it { should contain_file(conf_file).without_content(%r{window: }) } it { should contain_file(conf_file).without_content(%r{content_match: }) } + it { should contain_file(conf_file).without_content(%r{reverse_content_match: true}) } it { should contain_file(conf_file).without_content(%r{include_content: true}) } it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) } it { should contain_file(conf_file).without_content(%r{http_response_status_code: }) } @@ -67,6 +68,7 @@ threshold: 456, window: 789, content_match: 'foomatch', + reverse_content_match: true, include_content: true, collect_response_time: false, disable_ssl_validation: true, @@ -90,6 +92,7 @@ it { should contain_file(conf_file).with_content(%r{threshold: 456}) } it { should contain_file(conf_file).with_content(%r{window: 789}) } it { should contain_file(conf_file).with_content(%r{content_match: 'foomatch'}) } + it { should contain_file(conf_file).with_content(%r{reverse_content_match: true}) } it { should contain_file(conf_file).with_content(%r{include_content: true}) } it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) } it { should contain_file(conf_file).with_content(%r{disable_ssl_validation: true}) } diff --git a/templates/agent-conf.d/http_check.yaml.erb b/templates/agent-conf.d/http_check.yaml.erb index bbef4856..f08f43a1 100644 --- a/templates/agent-conf.d/http_check.yaml.erb +++ b/templates/agent-conf.d/http_check.yaml.erb @@ -32,6 +32,9 @@ instances: <% if instance['window'] -%> window: <%= instance['window'] %> <% end -%> +<% if instance['reverse_content_match'] -%> + reverse_content_match: <%= instance["reverse_content_match"] %> +<% end -%> <% if instance['content_match'] -%> content_match: '<%= instance["content_match"] %>' <% end -%>