{"id":777,"date":"2014-07-29T19:07:02","date_gmt":"2014-07-29T10:07:02","guid":{"rendered":"http:\/\/tech.akat.info\/?p=777"},"modified":"2014-09-25T23:00:17","modified_gmt":"2014-09-25T14:00:17","slug":"nginx-%e3%81%a7%e3%81%ae%e3%83%ad%e3%82%b0%e6%93%8d%e4%bd%9clocal_time-%e3%83%bb-fluentd","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=777","title":{"rendered":"nginx \u3067\u306e\u30ed\u30b0\u64cd\u4f5c($time_iso8601 \u30fb Fluentd)"},"content":{"rendered":"<h1>\u6982\u8981<\/h1>\n<p>nginx\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u6708\u65e5\u304c\u5206\u5272\u3055\u308c\u308b\u3088\u3046\u306b\u3059\u308b<\/p>\n<h1>\u7d50\u8ad6-2014\/09\/25\u8ffd\u8a18<\/h1>\n<p>http:\/\/wiki.nginx.org\/LogRotation<br \/>\n\u516c\u5f0f\u306blogrotate\u306e\u65b9\u6cd5\u304c\u3042\u308a\u3001\u3053\u308c\u3092\u771f\u4f3c\u3066bash\u3067\u6708\u65e5\u3092\u5206\u5272\u3059\u308b\u3088\u3046\u306b\u3057\u305f<br \/>\n\u3044\u308d\u3044\u308d\u8a66\u3057\u305f\u304c\u3001&#8221;time_iso8601&#8243; variable \u304c\u5229\u7528\u3067\u304d\u306a\u3044\u5834\u5408\u306f\u81ea\u4f5c\u304c\u4e00\u756a\u826f\u3055\u305d\u3046<\/p>\n<h1>\u305d\u306e\u524d\u306b<\/h1>\n<pre class=\"brush: plain; title: \u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u304c\u4f5c\u6210\u3055\u308c\u308b\u30bf\u30a4\u30df\u30f3\u30b0; notranslate\" title=\"\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u304c\u4f5c\u6210\u3055\u308c\u308b\u30bf\u30a4\u30df\u30f3\u30b0\">\r\nroot@hostname:\/home\/shimizu# vi \/etc\/nginx\/sites-enabled\/default\r\n=====\r\naccess_log \/var\/log\/nginx\/default\/access.log;\r\n=====\r\nroot@hostname:\/home\/shimizu# rm \/var\/log\/nginx\/default\/access.log\r\nroot@hostname:\/home\/shimizu# \/etc\/init.d\/nginx start # \u3082\u3057\u304f\u306f reload \u3067access.log \u304c\u4f5c\u6210\u3055\u308c\u308b\r\nroot@hostname:\/home\/shimizu# ls -al \/var\/log\/nginx\/default\/access.log\r\n-rw-r--r-- 1 root root 385  7\u6708 29 20:42 \/var\/log\/nginx\/default\/access.log\r\n<\/pre>\n<h1>nginx\u6a5f\u80fd\u3067\u5b9f\u73fe<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/home\/shimizu# nginx -v\r\nnginx version: nginx\/1.6.0\r\n\r\nroot@hostname:\/home\/shimizu# vi \/etc\/nginx\/sites-enabled\/default\r\n=====\r\nif ($time_iso8601 ~ &quot;^(\\d{4})-(\\d{2})-(\\d{2})&quot;) {\r\n    set $year $1;\r\n    set $month $2;\r\n    set $day $3;\r\n}\r\n=====\r\nroot@hostname:\/home\/shimizu# ls -al \/var\/log\/nginx\/default\/\r\n\u5408\u8a08 20\r\ndrwxr-xr-x 2 www-data adm      4096  7\u6708 29 20:46 .\r\ndrwxr-x--- 4 www-data adm      4096  7\u6708 29 20:45 ..\r\n-rw-r--r-- 1 www-data www-data  385  7\u6708 29 20:46 2014-07-29-access.log # www-data\u6a29\u9650\u3067\u4f5c\u6210\u3055\u308c\u308b\r\n-rw-r--r-- 1 www-data www-data  385  7\u6708 29 20:46 2014-07-29T20:46:32+09:00-access.log\r\n-rw-r--r-- 1 root     root      385  7\u6708 29 20:42 access.log \r\n\r\nroot@hostname:\/home\/shimizu# ps aufx | grep &#x5B;n]ginx\r\nroot      2988  0.0  0.3 132300  2264 ?        Ss   20:46   0:00 nginx: master process \/usr\/sbin\/nginx\r\nwww-data  2992  0.0  0.5 132660  3628 ?        S    20:46   0:00  \\_ nginx: worker process\r\n\r\n<\/pre>\n<h2>nginx: [emerg] unknown &#8220;time_iso8601&#8221; variable<\/h2>\n<p>\u4e0a\u306e\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u5834\u5408\u306f\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u9055\u3046\u53ef\u80fd\u6027\u304c\u3042\u308a<br \/>\nIn the modern nginx versions variables $status (1.3.2, 1.2.2), $bytes_sent (1.3.8, 1.2.5), $connection (1.3.8, 1.2.5), $connection_requests (1.3.8, 1.2.5), $msec (1.3.9, 1.2.6), $request_time (1.3.9, 1.2.6), $pipe (1.3.12, 1.2.7), $request_length (1.3.12, 1.2.7), $time_iso8601 (1.3.12, 1.2.7), and $time_local (1.3.12, 1.2.7) are also available as common variables.<\/p>\n<h1>nginx() + Fluentd<\/h1>\n<h2>Fluentd\u3068\u306f<\/h2>\n<p>\u67d4\u8edf\u306a\u30ed\u30b0\u53ce\u96c6\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd<br \/>\n<a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/07\/2014-07-29_215403.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/07\/2014-07-29_215403.png\" alt=\"2014-07-29_215403\" width=\"1202\" height=\"337\" class=\"alignnone size-full wp-image-783\" \/><\/a><\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>td-agent \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002td-agent \u3068\u306f Treasure Data \u793e\u304c\u4f5c\u6210\u3057\u3066\u3044\u308b Fluentd\u5b89\u5b9a\u7248\u306e\u914d\u5e03\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u3053\u3068<br \/>\nruby\u74b0\u5883\u3092\u5185\u5305\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u30b7\u30b9\u30c6\u30e0\u306eruby\u74b0\u5883\u306b\u4f9d\u5b58\u305b\u305a\u975e\u7834\u58ca\u7684\u306b\u5c0e\u5165\u53ef\u80fd<br \/>\n\u516c\u5f0f\u30b5\u30a4\u30c8\u306b debian\/Ubuntu \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u624b\u9806\u304c\u3042\u308b\u304c\u3001\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u304a\u3089\u305a\u3001\u591a\u304f\u306e\u4eba\u304c\u306f\u307e\u3063\u3066\u3044\u308b\u6a21\u69d8\u3002\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/home\/shimizu# vi \/etc\/apt\/sources.list # \u4ee5\u4e0b\u3092\u8ffd\u8a18\u3059\u308b\r\n=====\r\n# fluentd(td-agent)\r\ndeb http:\/\/packages.treasure-data.com\/debian\/ lucid contrib\r\n=====\r\nroot@hostname:\/home\/shimizu# aptitude update\r\n(\u4e2d\u7565)\r\nW: GPG \u30a8\u30e9\u30fc: http:\/\/packages.treasure-data.com lucid Release: \u516c\u958b\u9375\u3092\u5229\u7528\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u4ee5\u4e0b\u306e\u7f72\u540d\u306f\u691c\u8a3c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f: NO_PUBKEY 1093DB45A12E206F\r\n\r\nroot@hostname:\/home\/shimizu# wget http:\/\/packages.treasure-data.com\/debian\/RPM-GPG-KEY-td-agent\r\n--2014-07-29 22:31:28--  http:\/\/packages.treasure-data.com\/debian\/RPM-GPG-KEY-td-agent\r\npackages.treasure-data.com (packages.treasure-data.com) \u3092DNS\u306b\u554f\u3044\u3042\u308f\u305b\u3066\u3044\u307e\u3059... 54.230.233.15, 54.230.234.52, 54.230.233.27, ...\r\npackages.treasure-data.com (packages.treasure-data.com)|54.230.233.15|:80 \u306b\u63a5\u7d9a\u3057\u3066\u3044\u307e\u3059... \u63a5\u7d9a\u3057\u307e\u3057\u305f\u3002\r\nHTTP \u306b\u3088\u308b\u63a5\u7d9a\u8981\u6c42\u3092\u9001\u4fe1\u3057\u307e\u3057\u305f\u3001\u5fdc\u7b54\u3092\u5f85\u3063\u3066\u3044\u307e\u3059... 200 OK\r\n\u9577\u3055: 934 &#x5B;binary\/octet-stream]\r\n`RPM-GPG-KEY-td-agent' \u306b\u4fdd\u5b58\u4e2d\r\n\r\n100%&#x5B;===========================================================&gt;] 934         --.-K\/s \u6642\u9593 0s\r\n\r\n2014-07-29 22:31:29 (1740 GB\/s) - `RPM-GPG-KEY-td-agent' \u3078\u4fdd\u5b58\u5b8c\u4e86 &#x5B;934\/934]\r\n\r\nroot@hostname:\/home\/shimizu# apt-key add RPM-GPG-KEY-td-agent\r\nOK\r\nroot@hostname:\/home\/shimizu# rm RPM-GPG-KEY-td-agent\r\nroot@hostname:\/home\/shimizu# aptitude install td-agent\r\n\u4ee5\u4e0b\u306e\u65b0\u898f\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059:\r\n  td-agent{b}\r\n\u4ee5\u4e0b\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u63a8\u5968\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u305b\u3093:\r\n  ntp\r\n\u66f4\u65b0: 0 \u500b\u3001\u65b0\u898f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb: 1 \u500b\u3001\u524a\u9664: 0 \u500b\u3001\u4fdd\u7559: 0 \u500b\u3002\r\n60.9 M \u30d0\u30a4\u30c8\u306e\u30a2\u30fc\u30ab\u30a4\u30d6\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u5c55\u958b\u5f8c\u306b 107 M \u30d0\u30a4\u30c8\u306e\u30c7\u30a3\u30b9\u30af\u9818\u57df\u304c\u65b0\u305f\u306b\u6d88\u8cbb\u3055\u308c\u307e\u3059\u3002\r\n\u4ee5\u4e0b\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u306f\u6e80\u305f\u3055\u308c\u3066\u3044\u306a\u3044\u4f9d\u5b58\u95a2\u4fc2\u304c\u3042\u308a\u307e\u3059:\r\n td-agent : \u4f9d\u5b58: libssl0.9.8 (&gt;= 0.9.8k-1)&#x5B;\u4eee\u60f3\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059]\r\n            \u4f9d\u5b58: libyaml-0-2 &#x5B;\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u305b\u3093]\r\n\u4ee5\u4e0b\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u3053\u308c\u3089\u306e\u4f9d\u5b58\u95a2\u4fc2\u306e\u554f\u984c\u306f\u89e3\u6c7a\u3055\u308c\u307e\u3059:\r\n\r\n     \u4ee5\u4e0b\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u73fe\u5728\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u4e00\u6642\u56fa\u5b9a\u3059\u308b:\r\n1)     td-agent &#x5B;\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u307e\u305b\u3093]\r\n\r\n\r\n\r\n\u3053\u306e\u89e3\u6c7a\u65b9\u6cd5\u3092\u53d7\u3051\u5165\u308c\u307e\u3059\u304b? &#x5B;Y\/n\/q\/?]n\r\n\r\n*** \u5229\u7528\u53ef\u80fd\u306a\u89e3\u6c7a\u65b9\u6cd5\u304c\u3053\u308c\u4ee5\u4e0a\u3042\u308a\u307e\u305b\u3093\u3002 ***\r\n\r\n\u4ee5\u4e0b\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u3053\u308c\u3089\u306e\u4f9d\u5b58\u95a2\u4fc2\u306e\u554f\u984c\u306f\u89e3\u6c7a\u3055\u308c\u307e\u3059:\r\n\r\n     \u4ee5\u4e0b\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u73fe\u5728\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u4e00\u6642\u56fa\u5b9a\u3059\u308b:\r\n1)     td-agent &#x5B;\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u307e\u305b\u3093]\r\n\r\n\r\n\r\n\u3053\u306e\u89e3\u6c7a\u65b9\u6cd5\u3092\u53d7\u3051\u5165\u308c\u307e\u3059\u304b? &#x5B;Y\/n\/q\/?]n\r\n\r\nt\r\nroot@hostname:\/home\/shimizu# wget -d http:\/\/ftp.jp.debian.org\/debian\/pool\/main\/o\/openssl\/libssl0.9.8_0.9.8o-4squeeze14_amd64.deb\r\nDEBUG output created by Wget 1.13.4 on linux-gnu.\r\n\r\nURI encoding = `UTF-8'\r\n--2014-07-29 23:07:36--  http:\/\/ftp.jp.debian.org\/debian\/pool\/main\/o\/openssl\/libssl0.9.8_0.9.8o-4squeeze14_amd64.deb\r\nftp.jp.debian.org (ftp.jp.debian.org) \u3092DNS\u306b\u554f\u3044\u3042\u308f\u305b\u3066\u3044\u307e\u3059... 133.242.8.20\r\nCaching ftp.jp.debian.org =&gt; 133.242.8.20\r\nftp.jp.debian.org (ftp.jp.debian.org)|133.242.8.20|:80 \u306b\u63a5\u7d9a\u3057\u3066\u3044\u307e\u3059... \u63a5\u7d9a\u3057\u307e\u3057\u305f\u3002\r\nCreated socket 3.\r\nReleasing 0x0000000000abc8c0 (new refcount 1).\r\n\r\n---request begin---\r\nGET \/debian\/pool\/main\/o\/openssl\/libssl0.9.8_0.9.8o-4squeeze14_amd64.deb HTTP\/1.1\r\nUser-Agent: Wget\/1.13.4 (linux-gnu)\r\nAccept: *\/*\r\nHost: ftp.jp.debian.org\r\nConnection: Keep-Alive\r\n\r\n---request end---\r\nHTTP \u306b\u3088\u308b\u63a5\u7d9a\u8981\u6c42\u3092\u9001\u4fe1\u3057\u307e\u3057\u305f\u3001\u5fdc\u7b54\u3092\u5f85\u3063\u3066\u3044\u307e\u3059...\r\n---response begin---\r\nHTTP\/1.1 200 OK\r\nDate: Tue, 29 Jul 2014 14:07:36 GMT\r\nServer: Apache\/2.2.22 (Debian)\r\nLast-Modified: Wed, 13 Feb 2013 20:15:13 GMT\r\nETag: &quot;20856c5-f49ce-4d5a0ccb8f640&quot;\r\nAccept-Ranges: bytes\r\nContent-Length: 1001934\r\nKeep-Alive: timeout=5, max=100\r\nConnection: Keep-Alive\r\nContent-Type: application\/x-debian-package\r\n\r\n---response end---\r\n200 OK\r\nRegistered socket 3 for persistent reuse.\r\n\u9577\u3055: 1001934 (978K) &#x5B;application\/x-debian-package]\r\n`libssl0.9.8_0.9.8o-4squeeze14_amd64.deb' \u306b\u4fdd\u5b58\u4e2d\r\n\r\n100%&#x5B;===========================================================&gt;] 1,001,934   2.59M\/s \u6642\u9593 0.4s\r\n\r\n2014-07-29 23:07:36 (2.59 MB\/s) - `libssl0.9.8_0.9.8o-4squeeze14_amd64.deb' \u3078\u4fdd\u5b58\u5b8c\u4e86 &#x5B;1001934\/1001934]\r\n\r\nroot@hostname:\/home\/shimizu# dpkg -i libssl0.9.8_0.9.8o-4squeeze14_amd64.deb\r\n\u4ee5\u524d\u306b\u672a\u9078\u629e\u306e\u30d1\u30c3\u30b1\u30fc\u30b8 libssl0.9.8 \u3092\u9078\u629e\u3057\u3066\u3044\u307e\u3059\u3002\r\n(\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u307e\u3059 ... \u73fe\u5728 68478 \u500b\u306e\u30d5\u30a1\u30a4\u30eb\u3068\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u307e\u3059\u3002)\r\n(libssl0.9.8_0.9.8o-4squeeze14_amd64.deb \u304b\u3089) libssl0.9.8 \u3092\u5c55\u958b\u3057\u3066\u3044\u307e\u3059...\r\nlibssl0.9.8 (0.9.8o-4squeeze14) \u3092\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059 ...\r\n\r\nroot@hostname:\/home\/shimizu# aptitude search libssl\r\np   libssl-dev                                 - \u958b\u767a\u7528 SSL \u30e9\u30a4\u30d6\u30e9\u30ea\u3001\u30d8\u30c3\u30c0\u304a\u3088\u3073\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\r\np   libssl-doc                                 - SSL development documentation documentation\r\np   libssl-ocaml                               - OCaml bindings for OpenSSL (runtime)\r\np   libssl-ocaml-dev                           - OCaml bindings for OpenSSL\r\nv   libssl-ocaml-dev-l8h98                     -\r\nv   libssl-ocaml-l8h98                         -\r\ni   libssl0.9.8                                - SSL shared libraries\r\ni   libssl1.0.0                                - SSL \u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\r\np   libssl1.0.0-dbg                            - libssl \u304a\u3088\u3073 libcrypto \u7528\u30b7\u30f3\u30dc\u30eb\u30c6\u30fc\u30d6\u30eb\r\np   libsslcommon2                              - enterprise messaging system - common SSL libraries\r\np   libsslcommon2-dev                          - enterprise messaging system - common SSL development\r\n\r\nroot@hostname:\/home\/shimizu# aptitude install td-agent\r\n\u4ee5\u4e0b\u306e\u65b0\u898f\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059:\r\n  td-agent\r\n\u66f4\u65b0: 0 \u500b\u3001\u65b0\u898f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb: 1 \u500b\u3001\u524a\u9664: 0 \u500b\u3001\u4fdd\u7559: 0 \u500b\u3002\r\n60.9 M \u30d0\u30a4\u30c8\u306e\u30a2\u30fc\u30ab\u30a4\u30d6\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u5c55\u958b\u5f8c\u306b 107 M \u30d0\u30a4\u30c8\u306e\u30c7\u30a3\u30b9\u30af\u9818\u57df\u304c\u65b0\u305f\u306b\u6d88\u8cbb\u3055\u308c\u307e\u3059\u3002\r\n(\u4e2d\u7565)\r\n(...\/td-agent_1.1.20-1_amd64.deb \u304b\u3089) td-agent \u3092\u5c55\u958b\u3057\u3066\u3044\u307e\u3059...\r\ntd-agent (1.1.20-1) \u3092\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059 ...\r\n\u30b7\u30b9\u30c6\u30e0\u30e6\u30fc\u30b6 `td-agent' (UID 114) \u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059...\r\n\u65b0\u3057\u3044\u30b0\u30eb\u30fc\u30d7 `td-agent' (GID 121) \u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059...\r\n\u65b0\u3057\u3044\u30e6\u30fc\u30b6 `td-agent' (UID 114) \u3092\u30b0\u30eb\u30fc\u30d7 `td-agent' \u306b\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059...\r\n\u30db\u30fc\u30e0\u30c7\u30a3\u30ec\u30af\u30c8\u30ea `\/home\/td-agent' \u306f\u4f5c\u6210\u3057\u307e\u305b\u3093\u3002\r\nInstalling default conffile \/etc\/td-agent\/td-agent.conf ...\r\n&#x5B; ok ] Starting td-agent : td-agent.\r\n\r\n<\/pre>\n<h2>nginx\u3092LTSV\u5f62\u5f0f\u306b<\/h2>\n<p>Labeled Tab-serapated Values\u306e\u7565\u3067\u3001parse\u51e6\u7406\u304c\u3068\u3066\u3082\u3057\u3084\u3059\u3044<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/home\/shimizu# vi \/etc\/nginx\/nginx.conf # http\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u8ffd\u8a18\r\n=====\r\nlog_format ltsv 'time:$time_iso8601\\t'\r\n        'remote_addr:$remote_addr\\t'\r\n        'request_method:$request_method\\t'\r\n        'request_length:$request_length\\t'\r\n        'request_uri:$request_uri\\t'\r\n        'https:$https\\t'\r\n        'uri:$uri\\t'\r\n        'query_string:$query_string\\t'\r\n        'status:$status\\t'\r\n        'bytes_sent:$bytes_sent\\t'\r\n        'body_bytes_sent:$body_bytes_sent\\t'\r\n        'referer:$http_referer\\t'\r\n        'useragent:$http_user_agent\\t'\r\n        'forwardedfor:$http_x_forwarded_for\\t'\r\n        'request_time:$request_time\\t'\r\n        'upstream_response_time:$upstream_response_time\\t'\r\n        'host:$host';\r\n=====\r\n\r\nroot@hostname:\/home\/shimizu# vi \/etc\/nginx\/sites-enabled\/default\r\n=====\r\naccess_log  \/var\/log\/nginx\/default\/access.log ltsv;\r\n=====\r\nroot@hostname:\/home\/shimizu# nginx -t\r\nnginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful\r\nroot@hostname:\/home\/shimizu# \/etc\/init.d\/nginx reload\r\nReloading nginx configuration: nginx.\r\nroot@hostname:\/home\/shimizu# tail -f \/var\/log\/nginx\/default\/access.log\r\ntime:2014-07-30T22:08:53+09:00  remote_addr:11.11.11.111        request_method:GET      request_length:312    request_uri:\/favicon.ico https:  uri:\/favicon.ico        query_string:-  status:404      bytes_sent:383  body_bytes_sent:198    referer:-       useragent:Mozilla\/5.0 (Windows NT 6.1; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/36.0.1985.125 Safari\/537.36        forwardedfor:-  request_time:0.000      upstream_response_time:-       host:49.212.204.46\r\n<\/pre>\n<h2>td-agent\u306e\u8a2d\u5b9a<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/home\/shimizu# which td-agent\r\n\/usr\/sbin\/td-agent\r\nroot@hostname:\/home\/shimizu# lv \/usr\/sbin\/td-agent\r\nroot@hostname:\/home\/shimizu# cat \/usr\/sbin\/td-agent # \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u6240\u304c\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\r\n#!\/usr\/lib\/fluent\/ruby\/bin\/ruby\r\nENV&#x5B;&quot;GEM_HOME&quot;]=&quot;\/usr\/lib\/fluent\/ruby\/lib\/ruby\/gems\/1.9.1\/&quot;\r\nENV&#x5B;&quot;GEM_PATH&quot;]=&quot;\/usr\/lib\/fluent\/ruby\/lib\/ruby\/gems\/1.9.1\/&quot;\r\nENV&#x5B;&quot;FLUENT_CONF&quot;]=&quot;\/etc\/td-agent\/td-agent.conf&quot;\r\nENV&#x5B;&quot;FLUENT_PLUGIN&quot;]=&quot;\/etc\/td-agent\/plugin&quot;\r\nENV&#x5B;&quot;FLUENT_SOCKET&quot;]=&quot;\/var\/run\/td-agent\/td-agent.sock&quot;\r\nload &quot;\/usr\/lib\/fluent\/ruby\/bin\/fluentd&quot;\r\n\r\nroot@hostname:\/home\/shimizu# cp \/etc\/td-agent\/td-agent.conf \/etc\/td-agent\/td-agent.conf_\r\nroot@hostname:\/home\/shimizu# vi \/etc\/td-agent\/td-agent.conf\r\n=====\r\n# Input\r\n&lt;source&gt;\r\n  type tail\r\n  path \/var\/log\/nginx\/default\/access.log\r\n  tag nginx.access\r\n  pos_file \/var\/log\/td-agent\/buffer\/access.log.pos\r\n  format ltsv\r\n&lt;\/source&gt;\r\n\r\n# Output\r\n&lt;match nginx.access&gt;\r\n  type file\r\n  path \/var\/log\/td-agent\/access.log\r\n&lt;\/match&gt;\r\n\r\n#&lt;match nginx.access&gt;\r\n#  type forward\r\n#  buffer_type memory\r\n#  buffer_chunk_limit 256m\r\n#  buffer_queue_limit 128\r\n#  flush_interval 5s\r\n#  &lt;server&gt;\r\n#    # \u30ed\u30b0\u306e\u9001\u4fe1\u5148IP\u30a2\u30c9\u30ec\u30b9\r\n#    host 192.168.1.100\r\n#    port 24224 # default port : TCP\u3067\u9001\u4fe1\u3001UDP\u3067\u76e3\u8996\r\n#  &lt;\/server&gt;\r\n#&lt;\/match&gt;\r\n=====\r\nroot@hostname:\/var\/log\/td-agent# \/etc\/init.d\/td-agent restart\r\n&#x5B; ok ] Restarting td-agent: td-agent.\r\nroot@hostname:\/var\/log\/td-agent# ls -al \/var\/log\/td-agent\/\r\n\u5408\u8a08 48\r\ndrwxr-xr-x  4 td-agent td-agent  4096  7\u6708 31 00:10 .\r\ndrwxr-xr-x 20 root     root      4096  7\u6708 30 06:25 ..\r\n-rw-r--r--  1 td-agent td-agent  1356  7\u6708 31 00:01 access.log.20140731.b4ff6a69443049725\r\ndrwxrwxrwx  2 td-agent td-agent  4096  7\u6708 30 23:58 buffer\r\n-rw-r--r--  1 td-agent td-agent 17104  7\u6708 31 00:15 td-agent.log\r\n<\/pre>\n<h2>[error]: unexpected error error_class=Errno::EACCES error=#<Errno::EACCES: Permission\ndenied - \/var\/log\/nginx\/default\/nginx.pos><\/h2>\n<p>\/var\/log\/td-agent\/td-agent.log \u306b\u3066\u51fa\u305f\u30a8\u30e9\u30fc\u3001pos_file\u3092\u6a29\u9650\u306e\u306a\u3044\u5834\u6240\u306b\u304a\u304f\u3068\u8d77\u52d5\u3057\u306a\u3044\u305f\u3081\u6ce8\u610f<\/p>\n<h2>todo<\/h2>\n<p>http:\/\/blog.star-flare.com\/posts\/2013-10-11\/1160\/<br \/>\npath %Y\/%m\/%d\/%H\/blog.star-flare.com.access.log<\/p>\n<h1>\u53c2\u8003URL<\/h1>\n<p>http:\/\/www.cambus.net\/log-rotation-directly-within-nginx-configuration-file\/<br \/>\nhttp:\/\/nginx.org\/en\/docs\/http\/ngx_http_log_module.html<br \/>\nhttps:\/\/packages.debian.org\/squeeze\/amd64\/libssl0.9.8\/download<br \/>\nhttp:\/\/docs.fluentd.org\/ja\/articles\/install-by-deb<br \/>\nhttps:\/\/sites.google.com\/site\/itsikao\/it-memo\/fluentd<br \/>\nhttp:\/\/mtoyoshi.hateblo.jp\/entry\/2013\/06\/22\/235408<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 nginx\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u6708\u65e5\u304c\u5206\u5272\u3055\u308c\u308b\u3088\u3046\u306b\u3059\u308b \u7d50\u8ad6-2014\/09\/25\u8ffd\u8a18 http:\/\/wiki.nginx.org\/LogRotation \u516c\u5f0f\u306blogrotate\u306e\u65b9\u6cd5\u304c\u3042\u308a\u3001\u3053\u308c\u3092\u771f\u4f3c\u3066bash\u3067 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[29,18],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/777"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=777"}],"version-history":[{"count":17,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/777\/revisions"}],"predecessor-version":[{"id":1062,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/777\/revisions\/1062"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}