diff --git a/manifests/storage/all.pp b/manifests/storage/all.pp index 886a152c..1b081367 100644 --- a/manifests/storage/all.pp +++ b/manifests/storage/all.pp @@ -71,24 +71,56 @@ # Optional. Defaults to 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r' # This mask translates to 0755 for directories and 0644 for files. # +# [*statsd_enabled*] +# (optional) Should statsd configuration items be writen out to config files +# Defaults to false. +# +# [*log_statsd_host*] +# (optional) statsd host to send data to. +# Defaults to 'localhost' +# +# [*log_statsd_port*] +# (optional) statsd port to send data to. +# Defaults to 8125 +# +# [*log_statsd_default_sample_rate*] +# (optional) Default sample rate for data. This should be a number between 0 +# and 1. According to the documentation this should be set to 1 and the +# sample rate factor should be adjusted. +# Defaults to '1.0' +# +# [*log_statsd_sample_rate_factor*] +# (optional) sample rate factor for data. +# Defaults to '1.0' +# +# [*log_statsd_metric_prefix*] +# (optional) Prefix for data being sent to statsd. +# Defaults to '' +# class swift::storage::all( $storage_local_net_ip, - $devices = '/srv/node', - $object_port = '6000', - $container_port = '6001', - $account_port = '6002', - $object_pipeline = undef, - $container_pipeline = undef, - $allow_versions = false, - $mount_check = true, - $account_pipeline = undef, - $log_facility = 'LOG_LOCAL2', - $log_level = 'INFO', - $log_udp_host = undef, - $log_udp_port = undef, - $log_requests = true, - $incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', - $outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', + $devices = '/srv/node', + $object_port = '6000', + $container_port = '6001', + $account_port = '6002', + $object_pipeline = undef, + $container_pipeline = undef, + $allow_versions = false, + $mount_check = true, + $account_pipeline = undef, + $log_facility = 'LOG_LOCAL2', + $log_level = 'INFO', + $log_udp_host = undef, + $log_udp_port = undef, + $log_requests = true, + $incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', + $outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', + $statsd_enabled = false, + $log_statsd_host = 'localhost', + $log_statsd_port = 8125, + $log_statsd_default_sample_rate = '1.0', + $log_statsd_sample_rate_factor = '1.0', + $log_statsd_metric_prefix = '', ) { include ::swift::deps @@ -98,12 +130,18 @@ class swift::storage::all( } Swift::Storage::Server { - devices => $devices, - storage_local_net_ip => $storage_local_net_ip, - mount_check => $mount_check, - log_level => $log_level, - log_udp_host => $log_udp_host, - log_udp_port => $log_udp_port, + devices => $devices, + storage_local_net_ip => $storage_local_net_ip, + mount_check => $mount_check, + log_level => $log_level, + log_udp_host => $log_udp_host, + log_udp_port => $log_udp_port, + statsd_enabled => $statsd_enabled, + log_statsd_host => $log_statsd_host, + log_statsd_port => $log_statsd_port, + log_statsd_default_sample_rate => $log_statsd_default_sample_rate, + log_statsd_sample_rate_factor => $log_statsd_sample_rate_factor, + log_statsd_metric_prefix => $log_statsd_metric_prefix, } swift::storage::server { $account_port: diff --git a/manifests/storage/server.pp b/manifests/storage/server.pp index 9eb9693c..d7da9631 100644 --- a/manifests/storage/server.pp +++ b/manifests/storage/server.pp @@ -109,32 +109,64 @@ # Starting at the path "/etc/swift/" # Defaults to "${type}-server.conf" # +# [*statsd_enabled*] +# (optional) Should statsd configuration items be writen out to config files +# Defaults to false. +# +# [*log_statsd_host*] +# (optional) statsd host to send data to. +# Defaults to 'localhost' +# +# [*log_statsd_port*] +# (optional) statsd port to send data to. +# Defaults to 8125 +# +# [*log_statsd_default_sample_rate*] +# (optional) Default sample rate for data. This should be a number between 0 +# and 1. According to the documentation this should be set to 1 and the +# sample rate factor should be adjusted. +# Defaults to '1.0' +# +# [*log_statsd_sample_rate_factor*] +# (optional) sample rate factor for data. +# Defaults to '1.0' +# +# [*log_statsd_metric_prefix*] +# (optional) Prefix for data being sent to statsd. +# Defaults to '' +# define swift::storage::server( $type, $storage_local_net_ip, - $devices = '/srv/node', - $owner = 'swift', - $group = 'swift', - $incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', - $outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', - $max_connections = 25, - $pipeline = ["${type}-server"], - $mount_check = true, - $user = 'swift', - $workers = '1', - $allow_versions = false, - $replicator_concurrency = $::processorcount, - $updater_concurrency = $::processorcount, - $reaper_concurrency = $::processorcount, - $log_facility = 'LOG_LOCAL2', - $log_level = 'INFO', - $log_address = '/dev/log', - $log_name = "${type}-server", - $log_udp_host = undef, - $log_udp_port = undef, - $log_requests = true, + $devices = '/srv/node', + $owner = 'swift', + $group = 'swift', + $incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', + $outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', + $max_connections = 25, + $pipeline = ["${type}-server"], + $mount_check = true, + $user = 'swift', + $workers = '1', + $allow_versions = false, + $replicator_concurrency = $::processorcount, + $updater_concurrency = $::processorcount, + $reaper_concurrency = $::processorcount, + $log_facility = 'LOG_LOCAL2', + $log_level = 'INFO', + $log_address = '/dev/log', + $log_name = "${type}-server", + $log_udp_host = undef, + $log_udp_port = undef, + $log_requests = true, # this parameters needs to be specified after type and name - $config_file_path = "${type}-server.conf", + $config_file_path = "${type}-server.conf", + $statsd_enabled = false, + $log_statsd_host = 'localhost', + $log_statsd_port = 8125, + $log_statsd_default_sample_rate = '1.0', + $log_statsd_sample_rate_factor = '1.0', + $log_statsd_metric_prefix = '', ) { include ::swift::deps diff --git a/releasenotes/notes/statsd-configuration-c839c5485f761109.yaml b/releasenotes/notes/statsd-configuration-c839c5485f761109.yaml new file mode 100644 index 00000000..106cbaaa --- /dev/null +++ b/releasenotes/notes/statsd-configuration-c839c5485f761109.yaml @@ -0,0 +1,8 @@ +--- +features: + - Added parameters to configure the statsd integration + for the account, container, object and proxy services. + log_statsd_host, log_statsd_port, log_statsd_default_sample_rate, + log_statsd_sample_rate_factor and log_statsd_metric_prefix can + be configured if statsd_enabled is set to true for the + swift::storage::services resource. diff --git a/spec/classes/swift_storage_all_spec.rb b/spec/classes/swift_storage_all_spec.rb index 3e63e5a6..5d8e1eeb 100644 --- a/spec/classes/swift_storage_all_spec.rb +++ b/spec/classes/swift_storage_all_spec.rb @@ -123,6 +123,36 @@ describe 'swift::storage::all' do end end + describe "when specifying statsd enabled" do + let :params do + { + :storage_local_net_ip => '127.0.0.1', + :statsd_enabled => true, + :log_statsd_host => 'statsd.example.com', + :log_statsd_port => '9999', + :log_statsd_default_sample_rate => '2.0', + :log_statsd_sample_rate_factor => '1.5', + :log_statsd_metric_prefix => 'foo', + } + end + + {'object' => '6000', 'container' => '6001', 'account' => '6002'}.each do |type,name| + it "should configure statsd in the #{type} config file" do + is_expected.to contain_concat_fragment("swift-#{type}-#{name}").with_content( + /log_statsd_host = statsd.example.com/ + ).with_content( + /log_statsd_port = 9999/ + ).with_content( + /log_statsd_default_sample_rate = 2.0/ + ).with_content( + /log_statsd_sample_rate_factor = 1.5/ + ).with_content( + /log_statsd_metric_prefix = foo/ + ) + end + end + end + describe "when installed on Debian" do let :facts do OSDefaults.get_facts({ diff --git a/templates/account-server.conf.erb b/templates/account-server.conf.erb index 6c4ba277..d551d14f 100644 --- a/templates/account-server.conf.erb +++ b/templates/account-server.conf.erb @@ -16,6 +16,13 @@ log_udp_host = <%= @log_udp_host -%> <% if @log_udp_host and @log_udp_port -%> log_udp_port = <%= @log_udp_port -%> <% end %> +<%- if @statsd_enabled -%> +log_statsd_host = <%=@log_statsd_host%> +log_statsd_port = <%=@log_statsd_port%> +log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%> +log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%> +log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%> +<%- end -%> [pipeline:main] pipeline = <%= @pipeline.to_a.join(' ') %> diff --git a/templates/container-server.conf.erb b/templates/container-server.conf.erb index fa05fd0d..a3916ae3 100644 --- a/templates/container-server.conf.erb +++ b/templates/container-server.conf.erb @@ -17,6 +17,13 @@ log_udp_port = <%= @log_udp_port -%> <% end %> workers = <%= @workers %> allowed_sync_hosts = <%= scope.lookupvar("swift::storage::container::allowed_sync_hosts").to_a.join(',') %> +<%- if @statsd_enabled -%> +log_statsd_host = <%=@log_statsd_host%> +log_statsd_port = <%=@log_statsd_port%> +log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%> +log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%> +log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%> +<%- end -%> [pipeline:main] pipeline = <%= @pipeline.to_a.join(' ') %> diff --git a/templates/object-server.conf.erb b/templates/object-server.conf.erb index e5d79227..5013aa5a 100644 --- a/templates/object-server.conf.erb +++ b/templates/object-server.conf.erb @@ -16,6 +16,13 @@ log_udp_host = <%= @log_udp_host -%> log_udp_port = <%= @log_udp_port -%> <% end %> workers = <%= @workers %> +<%- if @statsd_enabled -%> +log_statsd_host = <%=@log_statsd_host%> +log_statsd_port = <%=@log_statsd_port%> +log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%> +log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%> +log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%> +<%- end -%> [pipeline:main] pipeline = <%= @pipeline.to_a.join(' ') %> diff --git a/templates/proxy-server.conf.erb b/templates/proxy-server.conf.erb index e7741372..3cf1e541 100644 --- a/templates/proxy-server.conf.erb +++ b/templates/proxy-server.conf.erb @@ -23,6 +23,13 @@ log_udp_port = <%= @log_udp_port -%> cors_allow_origin = <%= @cors_allow_origin %> strict_cors_mode = <%= @strict_cors_mode %> <% end -%> +<%- if @statsd_enabled -%> +log_statsd_host = <%=@log_statsd_host%> +log_statsd_port = <%=@log_statsd_port%> +log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%> +log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%> +log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%> +<%- end -%> [pipeline:main] pipeline = <%= @pipeline.to_a.join(' ') %>