From 94a91fc22a0d27842de03c2a4a0486d460cf8702 Mon Sep 17 00:00:00 2001 From: Pierre GINDRAUD Date: Tue, 4 Jun 2019 23:40:37 +0200 Subject: [PATCH 1/3] Add variable to customize apache log format --- manifests/init.pp | 3 +++ spec/classes/graphite_config_apache_spec.rb | 2 ++ templates/etc/apache2/sites-available/graphite.conf.erb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 08aba63b..b548311b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -377,6 +377,8 @@ # variable (mainly for nginx use) to tell Graphite a user is authenticated. # Useful when using an external auth handler with X-Accel-Redirect etc. # Example value - HTTP_X_REMOTE_USER +# [*gr_apache_logformat*] +# Specify the log format to use for apache access logs # [*gunicorn_arg_timeout*] # value to pass to gunicorn's --timeout arg. # Default is 30 @@ -726,6 +728,7 @@ $gr_graphiteweb_storage_dir = '/var/lib/graphite-web', $gr_graphiteweb_install_lib_dir = undef, $gr_apache_logdir = $::graphite::params::apache_logdir_graphite, + $gr_apache_logformat = 'common', $gunicorn_arg_timeout = 30, $gunicorn_bind = 'unix:/var/run/graphite.sock', $gunicorn_workers = 2, diff --git a/spec/classes/graphite_config_apache_spec.rb b/spec/classes/graphite_config_apache_spec.rb index e2a2d498..df3b24e8 100644 --- a/spec/classes/graphite_config_apache_spec.rb +++ b/spec/classes/graphite_config_apache_spec.rb @@ -60,6 +60,8 @@ :onlyif => 'test -f /etc/apache2/sites-enabled/000-default -o -f /etc/apache2/sites-enabled/000-default.conf', :require => 'Package[libapache2-mod-wsgi]',}) } + + it { is_expected.to contain_file('/etc/apache2/sites-available/graphite.conf.erb').with_content(/graphite-web-access.log custom/) } end context 'Unsupported OS' do diff --git a/templates/etc/apache2/sites-available/graphite.conf.erb b/templates/etc/apache2/sites-available/graphite.conf.erb index f6cf8a14..ae33f17e 100644 --- a/templates/etc/apache2/sites-available/graphite.conf.erb +++ b/templates/etc/apache2/sites-available/graphite.conf.erb @@ -23,7 +23,7 @@ WSGISocketPrefix <%= scope.lookupvar('graphite::params::apache_wsgi_socket_prefi <% if ![nil, '', :undef].include?(scope.lookupvar('graphite::gr_apache_noproxy')) %> NoProxy <%= scope.lookupvar('graphite::gr_apache_noproxy') %><% end %> ErrorLog <%= scope.lookupvar('graphite::gr_apache_logdir') %>/graphite-web-error.log - CustomLog <%= scope.lookupvar('graphite::gr_apache_logdir') %>/graphite-web-access.log common + CustomLog <%= scope.lookupvar('graphite::gr_apache_logdir') %>/graphite-web-access.log <%= scope.lookupvar('graphite::gr_apache_logformat') %> # I've found that an equal number of processes & threads tends # to show the best performance for Graphite (ymmv). From 0b8d88172b413a64c126fdedc27128e8be6a2cdf Mon Sep 17 00:00:00 2001 From: Pierre GINDRAUD Date: Tue, 4 Jun 2019 23:51:21 +0200 Subject: [PATCH 2/3] Fix path fpr graphite site specs --- spec/classes/graphite_config_apache_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/graphite_config_apache_spec.rb b/spec/classes/graphite_config_apache_spec.rb index df3b24e8..ec9db7ed 100644 --- a/spec/classes/graphite_config_apache_spec.rb +++ b/spec/classes/graphite_config_apache_spec.rb @@ -61,7 +61,7 @@ :require => 'Package[libapache2-mod-wsgi]',}) } - it { is_expected.to contain_file('/etc/apache2/sites-available/graphite.conf.erb').with_content(/graphite-web-access.log custom/) } + it { is_expected.to contain_file('/etc/apache2/sites-available/graphite.conf').with_content(/graphite-web-access.log custom/) } end context 'Unsupported OS' do From ea7290e7b2f6fba8b3f50d59ab9405628915d1ad Mon Sep 17 00:00:00 2001 From: Pierre GINDRAUD Date: Wed, 5 Jun 2019 19:25:51 +0200 Subject: [PATCH 3/3] Fix typo in graphite vhost path + add Redhat spec --- spec/classes/graphite_config_apache_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/classes/graphite_config_apache_spec.rb b/spec/classes/graphite_config_apache_spec.rb index ec9db7ed..ee4da54a 100644 --- a/spec/classes/graphite_config_apache_spec.rb +++ b/spec/classes/graphite_config_apache_spec.rb @@ -32,6 +32,7 @@ :require => 'Package[mod_wsgi]', :notify => 'Service[httpd]'}) } + it { is_expected.to contain_file('/etc/httpd/conf.d/graphite.conf').with_content(/CustomLog \/var\/log\/httpd\/graphite-web\/graphite-web-access.log common/) } end shared_context 'Debian supported platforms' do @@ -61,7 +62,7 @@ :require => 'Package[libapache2-mod-wsgi]',}) } - it { is_expected.to contain_file('/etc/apache2/sites-available/graphite.conf').with_content(/graphite-web-access.log custom/) } + it { is_expected.to contain_file('/etc/apache2/sites-available/graphite.conf').with_content(/CustomLog \/var\/log\/apache2\/graphite-web\/graphite-web-access.log common/) } end context 'Unsupported OS' do