MTA ãåã maillog ã¯æ®æ®µãã¾ãè¦ãªãã®ã ãã©ããã©ãã«ããã£ãã¨ãã«ã¯å¤§å¤éè¦ãããã Mongo ã«å ¥ããã°ãåãåããããã£ãã¢ãã¬ã¹ã§æ¤ç´¢ãã¦ãã°ã管çç»é¢ã§è¦ãã¨ãã§ãã¦ä¾¿å©ï¼ã¨ãããã¨ã§ãã£ã¦ã¿ãã
# fluentd.conf <source> type tail path /var/log/maillog tag maillog format /^(?<date>[^ ]+) (?<host>[^ ]+) (?<process>[^:]+): (?<message>((?<key>[^ :]+)[ :])? ?((to|from)=<(?<address>[^>]+)>)?.*)$/ </source>
æ£è¦è¡¨ç¾ããªããªãã§ããããã㧠maillog ã parse ãã¦ä»¥ä¸ã®ãããªçãã°ãã
2012-03-26T19:49:56+09:00 worker001 postfix/smtp[13747]: 31C5C1C000C: to=<[email protected]>, relay=mx.example.com[127.0.0.1]:25, delay=0.74, delays=0.06/0.01/0.25/0.42, dsn=2.0.0, status=sent (250 ok dirdel)
以ä¸ã®ããã«æ§é åããããã°ã«å¤æããä¸ã§ MongoDB ã«æå ¥ã§ãã¾ãã
{ "address" : "[email protected]", "date" : "2012-03-26T19:49:56+09:00", "host" : "worker001", "key" : "31C5C1C000C", "message" : "31C5C1C000C: to=<[email protected]>, relay=mx.example.com[127.0.0.1]:25, delay=0.74, delays=0.06/0.01/0.25/0.42, dsn=2.0.0, status=sent (250 ok dirdel)", "process" : "postfix/smtp[13747]" }
Postfix ããã°ã«åã queue id ("31C5C1C000C") ã¨ã(to|from)=
- { address : "foo@example.com" } ã§æ¤ç´¢ã㦠queue id ãå¾ã
- ãã® queue id ã§æ¤ç´¢ãã¦ä¸é£ã®å¦çã®ãã°ãæ½åº
ã¨ãããã¨ã (indexã使ã£ã¦é«éã«) å¯è½ã«ãªãã¾ãã
è¤æ°å°ããã®çãã°ã«ã¯æç³»åã§è¤æ°ã®å¦çãå ¥ã交ããã®ã§ãä¸é£ã®ãã°ã®ã¿æ½åºããã«ã¯å¤å°å·¥å¤«ãå¿ è¦ã§ããã