Skip to content

Instantly share code, notes, and snippets.

@y-ken
Last active December 18, 2015 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y-ken/6b65e1a8b5205d30c007 to your computer and use it in GitHub Desktop.
Save y-ken/6b65e1a8b5205d30c007 to your computer and use it in GitHub Desktop.
FluentdでApacheのエラーログを収集する正規表現 ref: http://qiita.com/y-ken/items/b302b73d0721162ff401
<source>
type tail
path /var/log/httpd/error_log
format /^(\[(?<time>[^\]]*)\] \[(?<level>[^\]]+)\] (\[client (?<host>[^\]]*)\] )?(?<message>.*)|(?<message>.*))$/
time_format %a %b %d %H:%M:%S %Y
tag apache.error
pos_file /var/log/td-agent/apache_error.pos
</source>
# 送り先を Fluentd の標準ログへ出力します
<match apache.error>
type stdout
</match>
<source>
type tail
path /var/log/httpd/error_log
format apache_error
tag apache.error
pos_file /var/log/td-agent/apache_error.pos
</source>
# 送り先を Fluentd の標準ログへ出力します
<match apache.error>
type stdout
</match>
$ sudo tail -f /var/log/httpd/error_log
[Tue Aug 05 15:48:43 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Tue Aug 05 15:48:43 2014] [notice] Digest: generating secret for digest authentication ...
[Tue Aug 05 15:48:43 2014] [notice] Digest: done
[Tue Aug 05 15:48:43 2014] [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations
[Tue Aug 05 15:48:56 2014] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/
$ sudo tail -f /var/log/td-agent/td-agent.log
2014-08-05 15:48:43 +0900 apache.error: {"level":"notice","message":"suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)"}
2014-08-05 15:48:43 +0900 apache.error: {"level":"notice","message":"Digest: generating secret for digest authentication ..."}
2014-08-05 15:48:43 +0900 apache.error: {"level":"notice","message":"Digest: done"}
2014-08-05 15:48:43 +0900 apache.error: {"level":"notice","message":"Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations"}
2014-08-05 15:48:56 +0900 apache.error: {"level":"error","host":"::1","message":"Directory index forbidden by Options directive: /var/www/html/"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment