Skip to content

Commit 6608801

Browse files
Jenkinsopenstack-gerrit
Jenkins
authored andcommitted
Merge "Add statsd configuration options"
2 parents f991b40 + 658f658 commit 6608801

File tree

8 files changed

+180
-44
lines changed

8 files changed

+180
-44
lines changed

manifests/storage/all.pp

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,56 @@
7171
# Optional. Defaults to 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r'
7272
# This mask translates to 0755 for directories and 0644 for files.
7373
#
74+
# [*statsd_enabled*]
75+
# (optional) Should statsd configuration items be writen out to config files
76+
# Defaults to false.
77+
#
78+
# [*log_statsd_host*]
79+
# (optional) statsd host to send data to.
80+
# Defaults to 'localhost'
81+
#
82+
# [*log_statsd_port*]
83+
# (optional) statsd port to send data to.
84+
# Defaults to 8125
85+
#
86+
# [*log_statsd_default_sample_rate*]
87+
# (optional) Default sample rate for data. This should be a number between 0
88+
# and 1. According to the documentation this should be set to 1 and the
89+
# sample rate factor should be adjusted.
90+
# Defaults to '1.0'
91+
#
92+
# [*log_statsd_sample_rate_factor*]
93+
# (optional) sample rate factor for data.
94+
# Defaults to '1.0'
95+
#
96+
# [*log_statsd_metric_prefix*]
97+
# (optional) Prefix for data being sent to statsd.
98+
# Defaults to ''
99+
#
74100
class swift::storage::all(
75101
$storage_local_net_ip,
76-
$devices = '/srv/node',
77-
$object_port = '6000',
78-
$container_port = '6001',
79-
$account_port = '6002',
80-
$object_pipeline = undef,
81-
$container_pipeline = undef,
82-
$allow_versions = false,
83-
$mount_check = true,
84-
$account_pipeline = undef,
85-
$log_facility = 'LOG_LOCAL2',
86-
$log_level = 'INFO',
87-
$log_udp_host = undef,
88-
$log_udp_port = undef,
89-
$log_requests = true,
90-
$incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
91-
$outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
102+
$devices = '/srv/node',
103+
$object_port = '6000',
104+
$container_port = '6001',
105+
$account_port = '6002',
106+
$object_pipeline = undef,
107+
$container_pipeline = undef,
108+
$allow_versions = false,
109+
$mount_check = true,
110+
$account_pipeline = undef,
111+
$log_facility = 'LOG_LOCAL2',
112+
$log_level = 'INFO',
113+
$log_udp_host = undef,
114+
$log_udp_port = undef,
115+
$log_requests = true,
116+
$incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
117+
$outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
118+
$statsd_enabled = false,
119+
$log_statsd_host = 'localhost',
120+
$log_statsd_port = 8125,
121+
$log_statsd_default_sample_rate = '1.0',
122+
$log_statsd_sample_rate_factor = '1.0',
123+
$log_statsd_metric_prefix = '',
92124
) {
93125

94126
include ::swift::deps
@@ -98,12 +130,18 @@
98130
}
99131

100132
Swift::Storage::Server {
101-
devices => $devices,
102-
storage_local_net_ip => $storage_local_net_ip,
103-
mount_check => $mount_check,
104-
log_level => $log_level,
105-
log_udp_host => $log_udp_host,
106-
log_udp_port => $log_udp_port,
133+
devices => $devices,
134+
storage_local_net_ip => $storage_local_net_ip,
135+
mount_check => $mount_check,
136+
log_level => $log_level,
137+
log_udp_host => $log_udp_host,
138+
log_udp_port => $log_udp_port,
139+
statsd_enabled => $statsd_enabled,
140+
log_statsd_host => $log_statsd_host,
141+
log_statsd_port => $log_statsd_port,
142+
log_statsd_default_sample_rate => $log_statsd_default_sample_rate,
143+
log_statsd_sample_rate_factor => $log_statsd_sample_rate_factor,
144+
log_statsd_metric_prefix => $log_statsd_metric_prefix,
107145
}
108146

109147
swift::storage::server { $account_port:

manifests/storage/server.pp

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -109,32 +109,64 @@
109109
# Starting at the path "/etc/swift/"
110110
# Defaults to "${type}-server.conf"
111111
#
112+
# [*statsd_enabled*]
113+
# (optional) Should statsd configuration items be writen out to config files
114+
# Defaults to false.
115+
#
116+
# [*log_statsd_host*]
117+
# (optional) statsd host to send data to.
118+
# Defaults to 'localhost'
119+
#
120+
# [*log_statsd_port*]
121+
# (optional) statsd port to send data to.
122+
# Defaults to 8125
123+
#
124+
# [*log_statsd_default_sample_rate*]
125+
# (optional) Default sample rate for data. This should be a number between 0
126+
# and 1. According to the documentation this should be set to 1 and the
127+
# sample rate factor should be adjusted.
128+
# Defaults to '1.0'
129+
#
130+
# [*log_statsd_sample_rate_factor*]
131+
# (optional) sample rate factor for data.
132+
# Defaults to '1.0'
133+
#
134+
# [*log_statsd_metric_prefix*]
135+
# (optional) Prefix for data being sent to statsd.
136+
# Defaults to ''
137+
#
112138
define swift::storage::server(
113139
$type,
114140
$storage_local_net_ip,
115-
$devices = '/srv/node',
116-
$owner = 'swift',
117-
$group = 'swift',
118-
$incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
119-
$outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
120-
$max_connections = 25,
121-
$pipeline = ["${type}-server"],
122-
$mount_check = true,
123-
$user = 'swift',
124-
$workers = '1',
125-
$allow_versions = false,
126-
$replicator_concurrency = $::processorcount,
127-
$updater_concurrency = $::processorcount,
128-
$reaper_concurrency = $::processorcount,
129-
$log_facility = 'LOG_LOCAL2',
130-
$log_level = 'INFO',
131-
$log_address = '/dev/log',
132-
$log_name = "${type}-server",
133-
$log_udp_host = undef,
134-
$log_udp_port = undef,
135-
$log_requests = true,
141+
$devices = '/srv/node',
142+
$owner = 'swift',
143+
$group = 'swift',
144+
$incoming_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
145+
$outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
146+
$max_connections = 25,
147+
$pipeline = ["${type}-server"],
148+
$mount_check = true,
149+
$user = 'swift',
150+
$workers = '1',
151+
$allow_versions = false,
152+
$replicator_concurrency = $::processorcount,
153+
$updater_concurrency = $::processorcount,
154+
$reaper_concurrency = $::processorcount,
155+
$log_facility = 'LOG_LOCAL2',
156+
$log_level = 'INFO',
157+
$log_address = '/dev/log',
158+
$log_name = "${type}-server",
159+
$log_udp_host = undef,
160+
$log_udp_port = undef,
161+
$log_requests = true,
136162
# this parameters needs to be specified after type and name
137-
$config_file_path = "${type}-server.conf",
163+
$config_file_path = "${type}-server.conf",
164+
$statsd_enabled = false,
165+
$log_statsd_host = 'localhost',
166+
$log_statsd_port = 8125,
167+
$log_statsd_default_sample_rate = '1.0',
168+
$log_statsd_sample_rate_factor = '1.0',
169+
$log_statsd_metric_prefix = '',
138170
) {
139171
140172
include ::swift::deps
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
features:
3+
- Added parameters to configure the statsd integration
4+
for the account, container, object and proxy services.
5+
log_statsd_host, log_statsd_port, log_statsd_default_sample_rate,
6+
log_statsd_sample_rate_factor and log_statsd_metric_prefix can
7+
be configured if statsd_enabled is set to true for the
8+
swift::storage::services resource.

spec/classes/swift_storage_all_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,36 @@
123123
end
124124
end
125125

126+
describe "when specifying statsd enabled" do
127+
let :params do
128+
{
129+
:storage_local_net_ip => '127.0.0.1',
130+
:statsd_enabled => true,
131+
:log_statsd_host => 'statsd.example.com',
132+
:log_statsd_port => '9999',
133+
:log_statsd_default_sample_rate => '2.0',
134+
:log_statsd_sample_rate_factor => '1.5',
135+
:log_statsd_metric_prefix => 'foo',
136+
}
137+
end
138+
139+
{'object' => '6000', 'container' => '6001', 'account' => '6002'}.each do |type,name|
140+
it "should configure statsd in the #{type} config file" do
141+
is_expected.to contain_concat_fragment("swift-#{type}-#{name}").with_content(
142+
/log_statsd_host = statsd.example.com/
143+
).with_content(
144+
/log_statsd_port = 9999/
145+
).with_content(
146+
/log_statsd_default_sample_rate = 2.0/
147+
).with_content(
148+
/log_statsd_sample_rate_factor = 1.5/
149+
).with_content(
150+
/log_statsd_metric_prefix = foo/
151+
)
152+
end
153+
end
154+
end
155+
126156
describe "when installed on Debian" do
127157
let :facts do
128158
OSDefaults.get_facts({

templates/account-server.conf.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ log_udp_host = <%= @log_udp_host -%>
1616
<% if @log_udp_host and @log_udp_port -%>
1717
log_udp_port = <%= @log_udp_port -%>
1818
<% end %>
19+
<%- if @statsd_enabled -%>
20+
log_statsd_host = <%=@log_statsd_host%>
21+
log_statsd_port = <%=@log_statsd_port%>
22+
log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%>
23+
log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%>
24+
log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%>
25+
<%- end -%>
1926

2027
[pipeline:main]
2128
pipeline = <%= @pipeline.to_a.join(' ') %>

templates/container-server.conf.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ log_udp_port = <%= @log_udp_port -%>
1717
<% end %>
1818
workers = <%= @workers %>
1919
allowed_sync_hosts = <%= scope.lookupvar("swift::storage::container::allowed_sync_hosts").to_a.join(',') %>
20+
<%- if @statsd_enabled -%>
21+
log_statsd_host = <%=@log_statsd_host%>
22+
log_statsd_port = <%=@log_statsd_port%>
23+
log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%>
24+
log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%>
25+
log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%>
26+
<%- end -%>
2027

2128
[pipeline:main]
2229
pipeline = <%= @pipeline.to_a.join(' ') %>

templates/object-server.conf.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ log_udp_host = <%= @log_udp_host -%>
1616
log_udp_port = <%= @log_udp_port -%>
1717
<% end %>
1818
workers = <%= @workers %>
19+
<%- if @statsd_enabled -%>
20+
log_statsd_host = <%=@log_statsd_host%>
21+
log_statsd_port = <%=@log_statsd_port%>
22+
log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%>
23+
log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%>
24+
log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%>
25+
<%- end -%>
1926

2027
[pipeline:main]
2128
pipeline = <%= @pipeline.to_a.join(' ') %>

templates/proxy-server.conf.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ log_udp_port = <%= @log_udp_port -%>
2323
cors_allow_origin = <%= @cors_allow_origin %>
2424
strict_cors_mode = <%= @strict_cors_mode %>
2525
<% end -%>
26+
<%- if @statsd_enabled -%>
27+
log_statsd_host = <%=@log_statsd_host%>
28+
log_statsd_port = <%=@log_statsd_port%>
29+
log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%>
30+
log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%>
31+
log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%>
32+
<%- end -%>
2633

2734
[pipeline:main]
2835
pipeline = <%= @pipeline.to_a.join(' ') %>

0 commit comments

Comments
 (0)