Skip to content

Commit 97128c6

Browse files
dzinektruthbk
authored andcommitted
Added http_responce_status_code to http_check module integration (#290)
* Added http_responce_status_code to http_check module integration * [spec] adding tests for http_response_status_code.
1 parent b7cc8c4 commit 97128c6

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

manifests/integrations/http_check.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
# check to create a metric 'network.http.response_time', tagged with
3838
# the url, reporting the response time in seconds.
3939
#
40+
# http_response_status_code
41+
# The (optional) http_response_status_code parameter will instruct the check
42+
# to look for a particular HTTP response status code or a Regex identifying
43+
# a set of possible status codes.
44+
# The check will report as DOWN if status code returned differs.
45+
# This defaults to 1xx, 2xx and 3xx HTTP status code: (1|2|3)\d\d.
46+
#
4047
# collect_response_time
4148
# The (optional) collect_response_time parameter will instruct the
4249
# check to create a metric 'network.http.response_time', tagged with
@@ -144,6 +151,7 @@
144151
$window = undef,
145152
$content_match = undef,
146153
$include_content = false,
154+
$http_response_status_code = undef,
147155
$collect_response_time = true,
148156
$disable_ssl_validation = false,
149157
$skip_event = true,
@@ -169,6 +177,7 @@
169177
'window' => $window,
170178
'content_match' => $content_match,
171179
'include_content' => $include_content,
180+
'http_response_status_code' => $http_response_status_code,
172181
'collect_response_time' => $collect_response_time,
173182
'disable_ssl_validation' => $disable_ssl_validation,
174183
'skip_event' => $skip_event,

spec/classes/datadog_agent_integrations_http_check_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
it { should contain_file(conf_file).without_content(%r{content_match: }) }
3232
it { should contain_file(conf_file).without_content(%r{include_content: true}) }
3333
it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) }
34+
it { should contain_file(conf_file).without_content(%r{http_response_status_code: }) }
3435
it { should contain_file(conf_file).without_content(%r{disable_ssl_validation: false}) }
3536
it { should contain_file(conf_file).without_content(%r{skip_event: }) }
3637
it { should contain_file(conf_file).without_content(%r{no_proxy: }) }
@@ -55,6 +56,7 @@
5556
collect_response_time: false,
5657
disable_ssl_validation: true,
5758
skip_event: true,
59+
http_response_status_code: '503',
5860
no_proxy: true,
5961
check_certificate_expiration: true,
6062
days_warning: 14,
@@ -73,6 +75,7 @@
7375
it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) }
7476
it { should contain_file(conf_file).with_content(%r{disable_ssl_validation: true}) }
7577
it { should contain_file(conf_file).with_content(%r{skip_event: true}) }
78+
it { should contain_file(conf_file).with_content(%r{http_response_status_code: 503}) }
7679
it { should contain_file(conf_file).with_content(%r{no_proxy: true}) }
7780
it { should contain_file(conf_file).with_content(%r{check_certificate_expiration: true}) }
7881
it { should contain_file(conf_file).with_content(%r{days_warning: 14}) }

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ instances:
2525
<% if instance['include_content'] -%>
2626
include_content: <%= instance['include_content'] %>
2727
<% end -%>
28+
<% if instance['http_response_status_code'] -%>
29+
http_response_status_code: <%= instance['http_response_status_code'] %>
30+
<% end -%>
2831
<% if instance['collect_response_time'] -%>
2932
collect_response_time: <%= instance['collect_response_time'] %>
3033
<% end -%>

0 commit comments

Comments
 (0)