Skip to content

Commit 5aeca00

Browse files
authored
Merge pull request #217 from cristianjuve/add-argument-in-http-check-integration
Add content_match argument in http_checks integration
2 parents 320ef4c + dc3e43e commit 5aeca00

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

manifests/integrations/http_check.pp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
# alerts only if the check fails x times within the last y attempts
1818
# where x is the threshold and y is the window.
1919
#
20+
# content_match
21+
# The (optional) content_match parameter will allow the check
22+
# to look for a particular string within the response. The check
23+
# will report as DOWN if the string is not found.
24+
# content_match uses Python regular expressions which means that
25+
# you will have to escape the following "special" characters with
26+
# a backslash (\) if you're trying to match them in your content:
27+
# . ^ $ * + ? { } [ ] \ | ( )
28+
#
2029
# include_content
2130
# The (optional) collect_response_time parameter will instruct the
2231
# check to create a metric 'network.http.response_time', tagged with
@@ -69,6 +78,7 @@
6978
# timeout => 5,
7079
# threshold => 1,
7180
# window => 1,
81+
# content_match => '^(Bread|Apples) float(s)? in water'
7282
# include_content => true,
7383
# collect_response_time => true,
7484
# contact => 'pagerduty',
@@ -84,6 +94,7 @@
8494
$timeout = 1,
8595
$threshold = undef,
8696
$window = undef,
97+
$content_match = undef,
8798
$include_content = false,
8899
$collect_response_time = true,
89100
$disable_ssl_validation = false,
@@ -103,6 +114,7 @@
103114
'timeout' => $timeout,
104115
'threshold' => $threshold,
105116
'window' => $window,
117+
'content_match' => $content_match,
106118
'include_content' => $include_content,
107119
'collect_response_time' => $collect_response_time,
108120
'disable_ssl_validation' => $disable_ssl_validation,

spec/classes/datadog_agent_integrations_http_check_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
it { should contain_file(conf_file).without_content(%r{timeout: 1}) }
2929
it { should contain_file(conf_file).without_content(%{threshold: }) }
3030
it { should contain_file(conf_file).without_content(%r{window: }) }
31+
it { should contain_file(conf_file).without_content(%r{content_match: }) }
3132
it { should contain_file(conf_file).without_content(%r{include_content: true}) }
3233
it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) }
3334
it { should contain_file(conf_file).without_content(%r{disable_ssl_validation: false}) }
@@ -44,6 +45,7 @@
4445
timeout: 123,
4546
threshold: 456,
4647
window: 789,
48+
content_match: 'foomatch',
4749
include_content: true,
4850
collect_response_time: false,
4951
disable_ssl_validation: true,
@@ -56,6 +58,7 @@
5658
it { should contain_file(conf_file).with_content(%r{timeout: 123}) }
5759
it { should contain_file(conf_file).with_content(%r{threshold: 456}) }
5860
it { should contain_file(conf_file).with_content(%r{window: 789}) }
61+
it { should contain_file(conf_file).with_content(%r{content_match: foomatch}) }
5962
it { should contain_file(conf_file).with_content(%r{include_content: true}) }
6063
it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) }
6164
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
@@ -19,6 +19,9 @@ instances:
1919
<% if instance['window'] -%>
2020
window: <%= instance['window'] %>
2121
<% end -%>
22+
<% if instance['content_match'] -%>
23+
content_match: <%= instance['content_match'] %>
24+
<% end -%>
2225
<% if instance['include_content'] -%>
2326
include_content: <%= instance['include_content'] %>
2427
<% end -%>

0 commit comments

Comments
 (0)