Add statsd configuration options

This change adds the ability to configure the statsd configuration
options for the account, container, object and proxy services.

Change-Id: I9b06c86b44162cbd35b0aa3a5d237dcc5eea318b
Closes-Bug: #1616512
This commit is contained in:
Alex Schultz
2016-08-24 12:02:53 -06:00
parent e2ad11e48e
commit 658f6589de
8 changed files with 180 additions and 44 deletions

View File

@@ -71,24 +71,56 @@
# Optional. Defaults to 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r' # 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. # 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( class swift::storage::all(
$storage_local_net_ip, $storage_local_net_ip,
$devices = '/srv/node', $devices = '/srv/node',
$object_port = '6000', $object_port = '6000',
$container_port = '6001', $container_port = '6001',
$account_port = '6002', $account_port = '6002',
$object_pipeline = undef, $object_pipeline = undef,
$container_pipeline = undef, $container_pipeline = undef,
$allow_versions = false, $allow_versions = false,
$mount_check = true, $mount_check = true,
$account_pipeline = undef, $account_pipeline = undef,
$log_facility = 'LOG_LOCAL2', $log_facility = 'LOG_LOCAL2',
$log_level = 'INFO', $log_level = 'INFO',
$log_udp_host = undef, $log_udp_host = undef,
$log_udp_port = undef, $log_udp_port = undef,
$log_requests = true, $log_requests = true,
$incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', $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', $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 include ::swift::deps
@@ -98,12 +130,18 @@ class swift::storage::all(
} }
Swift::Storage::Server { Swift::Storage::Server {
devices => $devices, devices => $devices,
storage_local_net_ip => $storage_local_net_ip, storage_local_net_ip => $storage_local_net_ip,
mount_check => $mount_check, mount_check => $mount_check,
log_level => $log_level, log_level => $log_level,
log_udp_host => $log_udp_host, log_udp_host => $log_udp_host,
log_udp_port => $log_udp_port, 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: swift::storage::server { $account_port:

View File

@@ -109,32 +109,64 @@
# Starting at the path "/etc/swift/" # Starting at the path "/etc/swift/"
# Defaults to "${type}-server.conf" # 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( define swift::storage::server(
$type, $type,
$storage_local_net_ip, $storage_local_net_ip,
$devices = '/srv/node', $devices = '/srv/node',
$owner = 'swift', $owner = 'swift',
$group = 'swift', $group = 'swift',
$incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', $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', $outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
$max_connections = 25, $max_connections = 25,
$pipeline = ["${type}-server"], $pipeline = ["${type}-server"],
$mount_check = true, $mount_check = true,
$user = 'swift', $user = 'swift',
$workers = '1', $workers = '1',
$allow_versions = false, $allow_versions = false,
$replicator_concurrency = $::processorcount, $replicator_concurrency = $::processorcount,
$updater_concurrency = $::processorcount, $updater_concurrency = $::processorcount,
$reaper_concurrency = $::processorcount, $reaper_concurrency = $::processorcount,
$log_facility = 'LOG_LOCAL2', $log_facility = 'LOG_LOCAL2',
$log_level = 'INFO', $log_level = 'INFO',
$log_address = '/dev/log', $log_address = '/dev/log',
$log_name = "${type}-server", $log_name = "${type}-server",
$log_udp_host = undef, $log_udp_host = undef,
$log_udp_port = undef, $log_udp_port = undef,
$log_requests = true, $log_requests = true,
# this parameters needs to be specified after type and name # 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 include ::swift::deps

View File

@@ -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.

View File

@@ -123,6 +123,36 @@ describe 'swift::storage::all' do
end end
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 describe "when installed on Debian" do
let :facts do let :facts do
OSDefaults.get_facts({ OSDefaults.get_facts({

View File

@@ -16,6 +16,13 @@ log_udp_host = <%= @log_udp_host -%>
<% if @log_udp_host and @log_udp_port -%> <% if @log_udp_host and @log_udp_port -%>
log_udp_port = <%= @log_udp_port -%> log_udp_port = <%= @log_udp_port -%>
<% end %> <% 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:main]
pipeline = <%= @pipeline.to_a.join(' ') %> pipeline = <%= @pipeline.to_a.join(' ') %>

View File

@@ -17,6 +17,13 @@ log_udp_port = <%= @log_udp_port -%>
<% end %> <% end %>
workers = <%= @workers %> workers = <%= @workers %>
allowed_sync_hosts = <%= scope.lookupvar("swift::storage::container::allowed_sync_hosts").to_a.join(',') %> 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:main]
pipeline = <%= @pipeline.to_a.join(' ') %> pipeline = <%= @pipeline.to_a.join(' ') %>

View File

@@ -16,6 +16,13 @@ log_udp_host = <%= @log_udp_host -%>
log_udp_port = <%= @log_udp_port -%> log_udp_port = <%= @log_udp_port -%>
<% end %> <% end %>
workers = <%= @workers %> 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:main]
pipeline = <%= @pipeline.to_a.join(' ') %> pipeline = <%= @pipeline.to_a.join(' ') %>

View File

@@ -23,6 +23,13 @@ log_udp_port = <%= @log_udp_port -%>
cors_allow_origin = <%= @cors_allow_origin %> cors_allow_origin = <%= @cors_allow_origin %>
strict_cors_mode = <%= @strict_cors_mode %> strict_cors_mode = <%= @strict_cors_mode %>
<% end -%> <% 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:main]
pipeline = <%= @pipeline.to_a.join(' ') %> pipeline = <%= @pipeline.to_a.join(' ') %>