blob: 394d950976760a09588ae77f88100728ca89154f [file] [log] [blame]
# Class: datadog_agent::integrations::http_check
#
# This class will install the necessary config to hook the http_check in the agent
#
# Parameters:
# url
# timeout
#
# username
# password
# If your service uses basic authentication, you can optionally
# specify a username and password that will be used in the check.
#
# threshold
# window
# The (optional) window and threshold parameters allow you to trigger
# alerts only if the check fails x times within the last y attempts
# where x is the threshold and y is the window.
#
# content_match
# The (optional) content_match parameter will allow the check
# to look for a particular string within the response. The check
# will report as DOWN if the string is not found.
# content_match uses Python regular expressions which means that
# you will have to escape the following "special" characters with
# a backslash (\) if you're trying to match them in your content:
# . ^ $ * + ? { } [ ] \ | ( )
#
# include_content
# The (optional) collect_response_time parameter will instruct the
# check to create a metric 'network.http.response_time', tagged with
# the url, reporting the response time in seconds.
#
# collect_response_time
# The (optional) collect_response_time parameter will instruct the
# check to create a metric 'network.http.response_time', tagged with
# the url, reporting the response time in seconds.
#
# disable_ssl_validation
# The setting disable_ssl_validation parameter to true will instruct
# the http client to accept self signed, expired and otherwise
# problematic SSL server certificates. To maintain backwards
# compatibility this defaults to false.
#
# headers
# The (optional) headers parameter allows you to send extra headers
# with the request. This is useful for explicitly specifying the host
# header or perhaps adding headers for authorisation purposes. Note
# that the http client library converts all headers to lowercase.
# This is legal according to RFC2616
# (See: http://tools.ietf.org/html/rfc2616#section-4.2)
# but may be problematic with some HTTP servers
# (See: https://code.google.com/p/httplib2/issues/detail?id=169)
#
# contact
# For service-specific notifications, you can optionally specify
# a list of users to notify within the service configuration.
#
# tags
#
# Sample Usage:
#
# class { 'datadog_agent::integrations::http_check':
# sitename => 'google',
# url => 'http://www.google.com/',
# }
#
# class { 'datadog_agent::integrations::http_check':
# sitename => 'local',
# url => 'http://localhost/',
# headers => ['Host: stan.borbat.com', 'DNT: true'],
# tags => ['production', 'wordpress'],
# }
#
# class { 'datadog_agent::integrations::http_check':
# sitename => 'localhost-9001',
# url => 'http://localhost:9001/',
# timeout => 5,
# threshold => 1,
# window => 1,
# content_match => '^(Bread|Apples) float(s)? in water'
# include_content => true,
# collect_response_time => true,
# contact => 'pagerduty',
# tags => 'production',
# }
#
#
class datadog_agent::integrations::http_check (
$sitename = undef,
$url = undef,
$username = undef,
$password = undef,
$timeout = 1,
$threshold = undef,
$window = undef,
$content_match = undef,
$include_content = false,
$collect_response_time = true,
$disable_ssl_validation = false,
$headers = [],
$tags = [],
$contact = [],
$instances = undef,
) inherits datadog_agent::params {
include datadog_agent
if !$instances and $url {
$_instances = [{
'sitename' => $sitename,
'url' => $url,
'username' => $username,
'password' => $password,
'timeout' => $timeout,
'threshold' => $threshold,
'window' => $window,
'content_match' => $content_match,
'include_content' => $include_content,
'collect_response_time' => $collect_response_time,
'disable_ssl_validation' => $disable_ssl_validation,
'headers' => $headers,
'tags' => $tags,
'contact' => $contact,
}]
} elsif !$instances{
$_instances = []
} else {
$_instances = $instances
}
file { "${datadog_agent::params::conf_dir}/http_check.yaml":
ensure => file,
owner => $datadog_agent::params::dd_user,
group => $datadog_agent::params::dd_group,
mode => '0600',
content => template('datadog_agent/agent-conf.d/http_check.yaml.erb'),
require => Package[$datadog_agent::params::package_name],
notify => Service[$datadog_agent::params::service_name]
}
}