Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Implement logic to send service logs to syslog #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jobs/carbon/spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ templates:
config/whitelist.conf.erb: conf/whitelist.conf

properties:
carbon.cache.log_to_syslog:
description: Set this to True to enable logging to syslog.
default: False
carbon.cache.enable_log_rotation:
description: Set this to True to enable daily log rotation.
default: True
Expand Down
9 changes: 9 additions & 0 deletions jobs/carbon/templates/bin/carbon_ctl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,19 @@ case $1 in
rm -f /etc/cron.daily/prune_metrics
<% end %>

<% if p('carbon.cache.log_to_syslog') %>
exec chpst -u vcap:vcap python /var/vcap/packages/carbon/bin/carbon-cache.py \
--config=/var/vcap/packages/carbon/conf/carbon.conf \
--debug \
start \
1> >(tee -a /var/vcap/sys/log/carbon/carbon.stdout.log | logger -t vcap.carbon.stdout ) \
2> >(tee -a /var/vcap/sys/log/carbon/carbon.stderr.log | logger -t vcap.carbon.stderr ) &
<% else %>
exec chpst -u vcap:vcap python /var/vcap/packages/carbon/bin/carbon-cache.py \
--config=/var/vcap/packages/carbon/conf/carbon.conf start \
1>> /var/vcap/sys/log/carbon/carbon_ctl.stdout.log \
2>> /var/vcap/sys/log/carbon/carbon_ctl.stderr.log
<% end %>
;;

stop)
Expand Down
3 changes: 3 additions & 0 deletions jobs/graphite-web/spec
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ templates:
config/graphite-vhost.conf.erb: conf/graphite-vhost.conf

properties:
graphite-web.log_to_syslog:
description: Set this to True to enable error logging to syslog.
default: False

graphite-web.secret_key:
description: Set this to a long, random unique string to use as a secret key for this install.
Expand Down
4 changes: 4 additions & 0 deletions jobs/graphite-web/templates/config/httpd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ WSGISocketPrefix run/wsgi
</Files>

LogLevel warn
<% if p('graphite-web.log_to_syslog') %>
ErrorLog "|$ tee -a /var/vcap/sys/log/graphite-web/default_httpd_error.log | logger -t vcap.graphite-web"
<% else %>
ErrorLog "/var/vcap/sys/log/graphite-web/default_httpd_error.log"
<% end %>

<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
Expand Down
3 changes: 3 additions & 0 deletions jobs/statsd/spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ properties:
statsd.carbon_cache_line_receiver_port:
description: Port the carbon cache line receiver listens on.
default: 2003
statsd.log_to_syslog:
description: Set this to True to enable logging to syslog.
default: False
13 changes: 13 additions & 0 deletions jobs/statsd/templates/bin/statsd_ctl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ case $1 in
chown -H vcap:vcap /var/vcap/sys/log/statsd
chown -H vcap:vcap /var/vcap/sys/run/statsd

<% if p('statsd.log_to_syslog') %>
start-stop-daemon --start --quiet -m \
--pidfile /var/vcap/sys/run/statsd/statsd.pid \
--startas /var/vcap/packages/node/bin/node \
--chuid vcap:vcap \
--background \
--no-close \
--chdir /var/vcap/packages/statsd \
-- /var/vcap/packages/statsd/stats.js /var/vcap/packages/statsd/localConfig.js \
1> >(tee -a /var/vcap/sys/log/statsd/statsd.stdout.log | logger -t vcap.statsd.stdout ) \
2> >(tee -a /var/vcap/sys/log/statsd/statsd.stderr.log | logger -t vcap.statsd.stderr )
<% else %>
start-stop-daemon --start --quiet -m \
--pidfile /var/vcap/sys/run/statsd/statsd.pid \
--startas /var/vcap/packages/node/bin/node \
Expand All @@ -27,6 +39,7 @@ case $1 in
-- /var/vcap/packages/statsd/stats.js /var/vcap/packages/statsd/localConfig.js \
1>> /var/vcap/sys/log/statsd/statsd_ctl.stdout.log \
2>> /var/vcap/sys/log/statsd/statsd_ctl.stderr.log
<% end %>
;;

stop)
Expand Down