{"id":2317,"date":"2015-10-09T11:57:12","date_gmt":"2015-10-09T02:57:12","guid":{"rendered":"http:\/\/blog.rutake.com\/techmemo\/?p=2317"},"modified":"2015-10-09T12:09:03","modified_gmt":"2015-10-09T03:09:03","slug":"td-agentfluentd-%e8%a8%ad%e5%ae%9a%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92dsl%e5%8c%96%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/blog.rutake.com\/techmemo\/2015\/10\/09\/td-agentfluentd-%e8%a8%ad%e5%ae%9a%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92dsl%e5%8c%96%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f\/","title":{"rendered":"td-agent\/fluentd \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092DSL\u5316\u3057\u3066\u307f\u305f"},"content":{"rendered":"<p>td-agent\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306fXML\u5f62\u5f0f\u3067\u306f\u306a\u304f\u3001ruby\u306eDSL\u5f62\u5f0f\u3067\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3002<br \/>\n\uff08\u5171\u5b58\u306f\u3067\u304d\u306a\u3044\uff09<br \/>\n\u4f3c\u305f\u3088\u3046\u306a\u500b\u6240\u3092\u7f6e\u304d\u304b\u3048\u308b\u306e\u3067\u3042\u308c\u3070DSL\u306b\u3057\u305f\u307b\u3046\u304c\u826f\u3044\u3068\u601d\u3063\u3066\u30c8\u30e9\u30a4\u3002<\/p>\n<p>[ruby]<br \/>\nsysloghash = { &#8220;syslog&#8221; => &#8220;td.syslog.messages&#8221;}<br \/>\n#{ &#8220;syslog&#8221; => &#8220;td.syslog.messages&#8221;}.each do |key,value|<br \/>\nsysloghash.each do |key,value|<br \/>\nsource {<br \/>\n    type :tail<br \/>\n    path &#8220;\/var\/log\/messages&#8221;<br \/>\n    format &#8220;#{key}&#8221;<br \/>\n    tag &#8220;#{value}&#8221;<br \/>\n    pos_file &#8220;\/tmp\/td-agent\/syslog_messages.pos&#8221;<br \/>\n}<br \/>\nend<br \/>\n# apche setting<br \/>\napache_hash = { &#8220;access&#8221; => &#8220;apache&#8221;, &#8220;error&#8221; => &#8220;apache_error&#8221;}<br \/>\napache_hash.each do |key,value|<br \/>\nsource {<br \/>\n    type :tail<br \/>\n    path &#8220;\/var\/log\/httpd\/*_#{key}_log&#8221;<br \/>\n    format &#8220;#{value}&#8221;<br \/>\n    tag &#8220;apache_#{key}&#8221;<br \/>\n    pos_file &#8220;\/tmp\/td-agent\/apache_#{key}.pos&#8221;<br \/>\n}<br \/>\nend<br \/>\nmatch (&#8216;td.syslog.messages&#8217;) {<br \/>\n        type :copy<br \/>\n        store {<br \/>\n                type &#8220;mongo&#8221;<br \/>\n                database &#8220;syslog&#8221;<br \/>\n                collection &#8220;syslog&#8221;<br \/>\n                host &#8220;localhost&#8221;<br \/>\n                port &#8220;27017&#8221;<br \/>\n        }<br \/>\n}<br \/>\n[\/ruby]<\/p>\n<p>\u53ef\u8aad\u6027\u304c\u60aa\u304f\u306a\u308b\u3088\u3046\u306a\u6c17\u3082\u3059\u308b\u304c\u3001\u30eb\u30fc\u30d7\u51e6\u7406\u304c\u3067\u304d\u308b\u306e\u304c\u697d\u3002<br \/>\n\u6700\u7d42\u7684\u306b\u3053\u308c\u3089\u306f\u30d1\u30fc\u30b9\u3055\u308c\u3066XML\u5f62\u5f0f\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u304c\u51fa\u529b\u3055\u308c\u308b\u3002<br \/>\n(\u306a\u306e\u3067\u65e2\u5b58\u3068\u306e\u6bd4\u8f03\u3082\/var\/log\/td-agent\/td-agent.log\u3092\u8d77\u52d5\u6642\u306b\u898b\u3066\u3044\u308c\u3070\u6bd4\u8f03\u3067\u304d\u308b\uff09<\/p>\n<p>[xml]<br \/>\n<ROOT><source>type tail<br \/>\n    path \/var\/log\/messages<br \/>\n    format syslog<br \/>\n    tag td.syslog.messages<br \/>\n    pos_file \/tmp\/td-agent\/syslog_messages.pos<br \/>\n  <\/source><source>type tail<br \/>\n    path \/var\/log\/httpd\/*_access_log<br \/>\n    format apache<br \/>\n    tag apache_access<br \/>\n    pos_file \/tmp\/td-agent\/apache_access.pos<br \/>\n  <\/source><source>type tail<br \/>\n    path \/var\/log\/httpd\/*_error_log<br \/>\n    format apache_error<br \/>\n    tag apache_error<br \/>\n    pos_file \/tmp\/td-agent\/apache_error.pos<br \/>\n  <\/source><br \/>\n  <match td.syslog.messages><br \/>\n    type copy<br \/>\n    <store><br \/>\n      type mongo<br \/>\n      database syslog<br \/>\n      collection syslog<br \/>\n      host localhost<br \/>\n      port 27017<br \/>\n    <\/store><br \/>\n  <\/match><br \/>\n<\/ROOT><br \/>\n[\/xml]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>td-agent\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306fXML\u5f62\u5f0f\u3067\u306f\u306a\u304f\u3001ruby\u306eDSL\u5f62\u5f0f\u3067\u8a18\u8ff0\u3059 &hellip; <a href=\"https:\/\/blog.rutake.com\/techmemo\/2015\/10\/09\/td-agentfluentd-%e8%a8%ad%e5%ae%9a%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92dsl%e5%8c%96%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[458],"tags":[464,437,449],"_links":{"self":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts\/2317"}],"collection":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/comments?post=2317"}],"version-history":[{"count":4,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts\/2317\/revisions"}],"predecessor-version":[{"id":2321,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts\/2317\/revisions\/2321"}],"wp:attachment":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/media?parent=2317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/categories?post=2317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/tags?post=2317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}