-
Notifications
You must be signed in to change notification settings - Fork 0
San 3496 json logs #432
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
San 3496 json logs #432
Changes from all commits
90a9325
a6ce7b7
82bce3d
1ae1336
c03d553
1812fbc
550ed44
7f9d804
ce65446
c05e0a7
56e87a7
d03aadb
899fed2
cbe3bdb
1e44812
4b44bef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| - name: copy bash aliases to ubuntu | ||
| tags: [ loggly, bash_aliases ] | ||
| template: | ||
| src=dot_bash_aliases.sh.j2 | ||
| dest=/home/ubuntu/.bash_aliases | ||
| owner=ubuntu | ||
| group=ubuntu | ||
| mode=0700 | ||
|
|
||
| - name: copy bash aliases to root | ||
| tags: [ loggly, bash_aliases ] | ||
| become: true | ||
| template: | ||
| src=dot_bash_aliases_root.sh.j2 | ||
| dest=/root/.bash_aliases | ||
| owner=root | ||
| group=root | ||
| mode=0700 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Follows the logfile for a given app_name interpolating the datetime string into the logpath (/var/log/runnable/YYYY/MM/DD/HH/<app_name>.log) | ||
| # Usage: logtail <app_name> | ||
| function logtail() { | ||
| local app_name="$1" | ||
| local datetime=`date +%Y/%m/%d/%H` | ||
| local app_log_dir="{{ app_log_dir }}" | ||
| local logfile="${app_log_dir}/${datetime}/${app_name}.log" | ||
| tail -f ${logfile} | bunyan | ||
| } | ||
|
|
||
| # Outputs contents of an npm start log for <app_name>, if it exists, into a pager for reading. | ||
| # Usage: npmlog <app_name> | ||
| function npmlog() { | ||
| local app_name="$1" | ||
| local app_log_dir="/var/log" | ||
| local logfile="${app_log_dir}/${app_name}.log" | ||
| less ${logfile} | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Follows the logfile for a given app_name interpolating the datetime string into the logpath (/var/log/runnable/YYYY/MM/DD/HH/<app_name>.log) | ||
| # Usage: logtail <app_name> | ||
| function logtail() { | ||
| local app_name="$1" | ||
| local datetime=`date +%Y/%m/%d/%H` | ||
| local app_log_dir="{{ app_log_dir }}" | ||
| local logfile="${app_log_dir}/${datetime}/${app_name}.log" | ||
| tail -f ${logfile} | bunyan | ||
| } | ||
|
|
||
| # Outputs contents of an npm start log for <app_name>, if it exists, into a pager for reading. | ||
| # Usage: npmlog <app_name> | ||
| function npmlog() { | ||
| local app_name="$1" | ||
| local app_log_dir="/var/log" | ||
| local logfile="${app_log_dir}/${app_name}.log" | ||
| less ${logfile} | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,11 @@ $KLogPermitNonKernelFacility on | |
| # | ||
| $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat | ||
|
|
||
| # Runnable JSON logging format | ||
| # Creates an "output formatter" template that accepts as input JSON and prints it out without any further processing ("raw JSON"). | ||
| # The formatting around the %msg% string is as such: start printing at the second character "2" until the end of the line "$" using the raw JSON format type. | ||
| $template RunnableJSON,"%msg:2:$:jsonr%\n" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Go ahead an add a comment that explains this line. |
||
|
|
||
| # Filter duplicated messages | ||
| $RepeatedMsgReduction on | ||
|
|
||
|
|
@@ -43,11 +48,11 @@ $RepeatedMsgReduction on | |
| # | ||
| $FileOwner syslog | ||
| $FileGroup adm | ||
| $FileCreateMode 0640 | ||
| $FileCreateMode 0644 | ||
| $DirCreateMode 0755 | ||
| $Umask 0022 | ||
| $PrivDropToUser syslog | ||
| $PrivDropToGroup syslog | ||
| $PrivDropToGroup adm | ||
|
|
||
| # | ||
| # Where to place spool and state files | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --- | ||
| dependencies: | ||
| - { role: bash_aliases } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,24 +46,6 @@ | |
| owner=syslog | ||
| group=syslog | ||
|
|
||
| - name: create runnable bin directory | ||
| tags: loggly | ||
| become: true | ||
| file: | ||
| path=/opt/runnable/bin | ||
| state=directory | ||
| mode=0755 | ||
| owner=ubuntu | ||
| group=ubuntu | ||
|
|
||
| - name: copy rotate util script | ||
| tags: loggly | ||
| become: true | ||
| template: | ||
| src=rotate-logs.sh.j2 | ||
| dest=/opt/runnable/bin/rotate-{{ name }}-logs.sh | ||
| mode=0755 | ||
|
|
||
| - name: copy app config | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we no longer need the rotate script at all? Is this somehow handled by rsyslog itself?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. Syslog will simply open a new log file every hour. Actually, let me add one more thing... |
||
| tags: loggly | ||
| become: true | ||
|
|
@@ -76,8 +58,8 @@ | |
| - name: copy rsyslog config | ||
| tags: loggly | ||
| become: true | ||
| template: | ||
| src=rsyslog.conf.j2 | ||
| copy: | ||
| src=rsyslog.conf | ||
| dest=/etc/rsyslog.conf | ||
| owner=syslog | ||
| group=syslog | ||
|
|
@@ -94,27 +76,16 @@ | |
| path=/var/spool/rsyslog/stat-{{ name }} | ||
| state=absent | ||
|
|
||
| - name: check for current log file | ||
| tags: [loggly, deploy] | ||
| stat: path="{{ app_log_dir }}/{{ name }}-daemon.log" | ||
| register: log_file | ||
|
|
||
| - name: remove old log file | ||
| when: log_file.stat.exists | ||
| tags: [loggly, deploy] | ||
| become: true | ||
| file: | ||
| path="{{ app_log_dir }}/{{ name }}-daemon.log" | ||
| state=absent | ||
|
|
||
| - name: touch the log file | ||
| tags: [loggly, deploy] | ||
| - name: ensure log path | ||
| tags: loggly | ||
| become: true | ||
| file: | ||
| path="{{ app_log_dir }}/{{ name }}-daemon.log" | ||
| state=touch | ||
| path="{{ app_log_dir }}" | ||
| state=directory | ||
| owner=syslog | ||
| group=adm | ||
| mode=0755 | ||
| recurse=yes | ||
|
|
||
| - name: restart rsyslog | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we still need to restart every deploy?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. out of scope ;) |
||
| tags: [loggly, deploy] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,10 @@ | ||
| $WorkDirectory /var/spool/rsyslog | ||
|
|
||
| # start log rotation via outchannel | ||
| # outchannel definition | ||
| $outchannel log_rotation_{{ name }},{{ app_log_dir }}/{{ name }}-daemon.log,524288000,/opt/runnable/bin/rotate-{{ name }}-logs.sh | ||
| # activate the channel and log everything to it | ||
| if $msg contains '{{ name }}' and $syslogfacility-text == 'local7' then :omfile:$log_rotation_{{ name }} | ||
| # end log rotation via outchannel | ||
| # Rotate per hour | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, are the log files actually removed from the system? How does this all work?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clean up handled in another PR |
||
| $template RotateHourly_{{ name }},"{{ app_log_dir }}/%$YEAR%/%$MONTH%/%$DAY%/%$HOUR%/{{ name }}.log" | ||
| if $msg contains '{{ name }}' and $syslogfacility-text == 'local7' then { action (type="omfile" DynaFile="RotateHourly_{{ name }}" template="RunnableJSON") } | ||
|
|
||
| # {{ name }} access file: | ||
| #Add a tag for {{ name }} events | ||
| # Loggly: Add a tag for {{ name }} events | ||
| $template LogglyFormat_{{ name }},"<%pri%>%protocol-version% %timestamp:::date-rfc3339% %HOSTNAME% %app-name% %procid% %msgid% [{{ loggly_token }}@41058 tag=\"runnable\" tag=\"{{ node_env }}\"] %msg%\n" | ||
| if $msg contains '{{ name }}' then @@logs-01.loggly.com:6514;LogglyFormat_{{ name }} | ||
| if $msg contains '{{ name }}' then stop | ||
| if $msg contains '{{ name }}' and $syslogfacility-text == 'local7' then @@logs-01.loggly.com:6514;LogglyFormat_{{ name }} | ||
| if $msg contains '{{ name }}' and $syslogfacility-text == 'local7' then stop | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's comment these functions similar to the way we comment them in dock-init, please and ty 👯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the methods look like they do in dock-init:
https://github.com/CodeNow/dock-init/blob/master/lib/consul.sh#L28