ãã°ã¯ã·ã¹ãã ã®éèŠãªéšåã§ãããæåŸ
ã©ããã«æ©èœããïŒãŸãã¯æ©èœããªãïŒããšãç解ã§ããŸãã ãã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ã®æ¡ä»¶ã§ã¯ããã°ã®æäœã¯ç¹å¥ãªãªãªã³ãã¢ãŒãã®å¥ã®åéã«ãªããŸãã ããã«äžé£ã®è³ªåã解決ããå¿
èŠããããŸãã
- ã¢ããªã±ãŒã·ã§ã³ãããã°ãæžã蟌ãæ¹æ³ã
- ãã°ãæžã蟌ãå Žæã
- ã¹ãã¬ãŒãžããã³åŠçã®ããã«ãã°ãé
ä¿¡ããæ¹æ³ã
- ãã°ãåŠçããã³ä¿åããæ¹æ³ã
çŸåšæ®åããŠããã³ã³ããåãã¯ãããžãŒã®äœ¿çšã«ãããåé¡ã解決ããããã®ãªãã·ã§ã³ã®åéã«çæã®äžã«ç ãè¿œå ãããŸãã
ãŠãŒãªã»ããã·ã¥ã¡ã¬ãã®å ±åæžã®ããã®åéã«ã€ããŠãããã°ã®åéãšé
ä¿¡ã®åéã§ã®å°å³ã®äœæã
ç«ã®äžã§èª°ãæ°ã«ããŠãã ããã
ç§ã®ååã¯ãŠãŒãªã»ããã·ã¥ã¡ã¬ãã§ãã ã©ã¶ãã§åããŠããŸãã ä»æ¥ã¯ããã°ã®äœææ¹æ³ããã°ã®åéæ¹æ³ããã°ãžã®æžã蟌ã¿ã«ã€ããŠèª¬æããŸãã
ã©ãããæ¥ãã®ïŒ ç§ãã¡ã¯èª°ã§ããïŒ Lazadaã¯ãæ±åã¢ãžã¢ã®6ãåœã§1çªç®ã®ãªã³ã©ã€ã³ã¹ãã¢ã§ãã ãããã®åœã¯ãã¹ãŠããŒã¿ã»ã³ã¿ãŒã«ãã£ãŠé
åžãããŠããŸãã çŸåš4ã€ã®ããŒã¿ã»ã³ã¿ãŒããããŸããããªããããéèŠãªã®ã§ããïŒ ããã€ãã®æ±ºå®ã¯ãã»ã³ã¿ãŒéã«éåžžã«åŒ±ããªã³ã¯ããããšããäºå®ã«ãããã®ã ã£ãããã§ãã ãã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ããããŸãã ãã§ã«80ã®ãã€ã¯ããµãŒãã¹ãããããšãç¥ã£ãŠé©ããã ãã°ã䜿çšããŠã¿ã¹ã¯ãéå§ãããšãã20åãããããŸããã§ãããããã«ãããªã倧ããªPHPã¬ã¬ã·ãŒããããŸãã ããã¯ãã¹ãŠãçŸæç¹ã§ã·ã¹ãã å
šäœã§æ¯å600äžãè¶
ããã¡ãã»ãŒãžãçæããŸãã ããã«ãç§ãã¡ãã©ã®ããã«ãããšå
±ã«çããããšããŠããã®ãããããŠãªããããªã®ãã瀺ããŸãã
ãªããšãããŠãããã®600äžã®ã¡ãã»ãŒãžãšå
±ã«çããªããã°ãªããŸããã ãããã§äœããã¹ãã§ããããïŒ å¿
èŠãª600äžã®ã¡ãã»ãŒãžïŒ
- ã¢ããªã±ãŒã·ã§ã³ããéä¿¡
- é
éãåãå
¥ãã
- åæãšä¿ç®¡ã®ããã«æäŸããŸãã
- åæãã
- ã©ããããããåºã
300äžã®ã¡ãã»ãŒãžã衚瀺ããããšããç§ã¯ã»ãŒåãå€èŠ³ã§ããã äœã»ã³ãããå§ããããã§ãã ã¢ããªã±ãŒã·ã§ã³ãã°ãããã«æžã蟌ãŸããŠããããšã¯æããã§ãã ããšãã°ãããŒã¿ããŒã¹ã«æ¥ç¶ã§ãããããŒã¿ããŒã¹ã«æ¥ç¶ã§ããŸããããäœããèªãããšãã§ããŸããã§ããã ãã ããããã«å ããŠãåãã€ã¯ããµãŒãã¹ã¯ã¢ã¯ã»ã¹ãã°ãæžã蟌ã¿ãŸãã ãã€ã¯ããµãŒãã¹ã«å°çããåãªã¯ãšã¹ãã¯ãã°ã«åé¡ãããŸãã ãªããããè¡ãã®ã§ããïŒ éçºè
ã¯ãã¬ãŒã¹ã§ããããã«ããããšèããŠããŸãã åã¢ã¯ã»ã¹ãã°ã«ã¯traceidãã£ãŒã«ãããããããã«æ²¿ã£ãŠç¹å¥ãªã€ã³ã¿ãŒãã§ã€ã¹ããã§ãŒã³å
šäœãããã«å·»ãæ»ãããã¬ãŒã¹ãçŸãã衚瀺ããŸãã ãã¬ãŒã¹ã¯ããªã¯ãšã¹ããã©ã®ããã«éä¿¡ããããã瀺ããŸããããã«ãããéçºè
ã¯æªç¢ºèªã®ã¬ããŒãžãè¿
éã«åŠçã§ããŸãã
ãããšäžç·ã«æ®ããã«ã¯ïŒ ããã§ããªãã·ã§ã³ã®åéã«ã€ããŠç°¡åã«èª¬æããŸããäžè¬ã«ãã®åé¡ã¯ã©ã®ããã«è§£æ±ºãããŸããã ãã°ã®åéã転éãä¿åã®åé¡ã解決ããæ¹æ³ã
ã¢ããªã±ãŒã·ã§ã³ããæžãæ¹æ³ã¯ïŒ ããŸããŸãªæ¹æ³ãããããšã¯æããã§ãã ç¹ã«ããã¡ãã·ã§ããã«ãªä»²éãã¡ãèšãããã«ããã¹ããã©ã¯ãã£ã¹ããããŸãã ç¥ç¶ãèšã£ãããã«ã2ã€ã®åœ¢åŒã®å€ãåŠæ ¡ããããŸãã ä»ã®æ¹æ³ããããŸãã
ãã°ãåéããç¶æ³ã¯ã»ãŒåãã§ãã ãã®ç¹å®ã®éšåã解決ããããã®å€ãã®ãªãã·ã§ã³ã¯ãããŸããã ãã§ã«å€ããããŸãããããã»ã©å€ãã¯ãããŸããã
ããããé
ä¿¡ãšãã®åŸã®åæã§ã¯ãããªãšãŒã·ã§ã³ã®æ°ãççºçã«å¢ãå§ããŸãã ããã§ã¯ãåãªãã·ã§ã³ã«ã€ããŠèª¬æããŸããã äž»ãªéžæè¢ã¯ããã®ãããã¯ã«èå³ãæã£ãŠãããã¹ãŠã®äººã«èããããšæããŸãã
ã©ã¶ãã§ãããã©ã®ããã«è¡ããå®éã«ãã¹ãŠãå§ãŸã£ãã®ãã瀺ããŸãã
1幎åãç§ã¯Lazadaã«æ¥ãŠã圌ãã¯ç§ããã°ã«é¢ãããããžã§ã¯ãã«éããŸããã ãããªæãã§ããã ã¢ããªã±ãŒã·ã§ã³ããã®ãã°ã¯ãstdoutããã³stderrã«æžã蟌ãŸããŸããã ãã¹ãŠããã¡ãã·ã§ããã«ãªæ¹æ³ã§è¡ãããŸããã ãããããã®åŸãéçºè
ã¯ãããæšæºãããŒããé€å€ããã€ã³ãã©ã¹ãã©ã¯ãã£ã®å°é家ããããäœããã®æ¹æ³ã§æŽçããŸãã ã€ã³ãã©ã¹ãã©ã¯ãã£ã®å°é家ãšéçºè
ã®éã«ã¯ãããããš...ããããŸãããã·ã§ã«ã§ãã¡ã€ã«ã«ã©ããããŠã¿ãŸãããããšèšã£ããªãªãŒã¹è
ãããŸãã ãããŠããããã¯ãã¹ãŠã³ã³ããå
ã«ããã®ã§ã圌ãã¯ãããã³ã³ããèªäœã«å
ã¿ãã«ã¿ãã°ãããŠã³ããŒãããŠããã«çœ®ããã ç§ã¯ããã誰ããæ¥ãã®ãã¯ã»ãŒæããã ãšæããŸãã
ããå°ãèŠãŠã¿ãŸãããã ãããã®ãã°ãã©ã®ããã«é
ä¿¡ããŸããã 誰ããtd-agentãéžæããŸãããããã¯å®éã«ã¯æµfluentã§ãããããã»ã©æµfluentã§ã¯ãããŸããã ç§ã¯ãŸã ããã2ã€ã®ãããžã§ã¯ãã®é¢ä¿ãç解ãââãŠããŸããã§ãããããããã¯ã»ãŒåããã®ã®ããã§ãã ãããŠããã®æµãããããªRubyã§æžããããã°ãã¡ã€ã«ãèªã¿åããäžå®ã®æéãJSONã§è§£æããŸããã ãããã圌ã¯ã«ãã«ã«ããããéããŸããã ãŸããåAPIã®Kafkaã§ã¯ã4ã€ã®åå¥ã®ãããã¯ããããŸããã ãªã4ïŒ ã©ã€ãããããããã¹ããŒãžã³ã°ããããstdoutãšstderrãããããã§ãã éçºè
ã¯ããããç£ã¿ãã€ã³ãã©ã¹ãã©ã¯ãã£ãšã³ãžãã¢ã¯ããããKafkaã§äœæããå¿
èŠããããŸãã ããã«ãã«ãã«ã¯å¥ã®éšéã«ãã£ãŠç®¡çãããŠããŸããã ãããã£ãŠããã±ãããäœæããŠãåAPIã«4ã€ã®ãããã¯ãäœæããå¿
èŠããããŸããã 誰ãããããå¿ããŠããŸããã äžè¬çã«ããŽããå»æ£ç©ããããŸããã
ããã§æ¬¡ã«äœãããŸãããïŒ ãããã«ãã«ã«éããŸããã ããã«ã«ãã«ããããã°ã®ååããã°ã¹ã¿ãã·ã¥ã«é£ãã ã ãã°ã®æ®ãã®ååã¯å
±æãããŸããã äžéšã¯1ã€ã®Graylogã«é£ã³ãäžéšã¯å¥ã®Graylogã«é£ã³ãŸããã ãã®çµæãããããã¹ãŠã1ã€ã®Elasticsearchã¯ã©ã¹ã¿ãŒã«é£ã³èŸŒã¿ãŸããã ã€ãŸãããã®æ··ä¹±ã¯æçµçã«ããã«èœã¡ãŸããã ãããããå¿
èŠã¯ãããŸããïŒ
ããã¯ãäžããé ããèŠããšã©ã®ããã«èŠãããã§ãã ãããããªãã§ãã ããïŒ ããã§ãçªå·ã¯åé¡ã®ããé åãããã«ç€ºããŸãã å®éã«ã¯ãã£ãšå€ããããŸããã6ã€ã¯éåžžã«åé¡ãå€ããããäœããè¡ãå¿
èŠããããŸãã ãããã«ã€ããŠåå¥ã«èª¬æããŸãã
ããïŒ1,2,3ïŒã§ã¯ãã¡ã€ã«ãäœæããŠãããããäžåºŠã«3ã€ã®ã¬ãŒãããããŸãã
æåã®ïŒ1ïŒã¯ãã©ããã«æžã蟌ãå¿
èŠããããšããããšã§ãã APIã«ãã¡ã€ã«ã«çŽæ¥æžã蟌ãæ©èœãåžžã«äžããããšã¯æããªãã§ãããã APIã¯ã³ã³ããå
ã§éé¢ãããããšãæãŸãããèªã¿åãå°çšã§ããããšãããã«æãŸããã§ãã ç§ã¯ã·ã¹ãã 管çè
ã§ããããããããã®ããšã«ã€ããŠå°ãã ãå¥ã®èŠæ¹ãããŠããŸãã
2çªç®ã®ãã€ã³ãïŒ2,3ïŒ-APIã«ã¯å€ãã®ãªã¯ãšã¹ãããããŸãã APIã¯ã倧éã®ããŒã¿ããã¡ã€ã«ã«æžã蟌ã¿ãŸãã ãã¡ã€ã«ã¯æé·ããŠããŸãã ããããå転ãããå¿
èŠããããŸãã ããããªããšãããã«ãã£ã¹ã¯ãå±ããªãããã§ãã ã·ã§ã«ãä»ããŠãã£ã¬ã¯ããªã«ãªãã€ã¬ã¯ãããããããããããå転ãããã®ã¯è¯ããããŸããã 移åããããšã¯ã§ããŸããã èšè¿°åãåçºèŠããããã«ã¢ããªã±ãŒã·ã§ã³ã«æ瀺ããããšã¯ã§ããŸããã éçºè
ã¯ããªããæãè
ã®ããã«èŠãŠããããã§ãããèšè¿°åãšã¯äœã§ããïŒ éåžžãstdoutã«æžã蟌ã¿ãŸããã ã€ã³ãã©ã¹ãã©ã¯ãã£ãšã³ãžãã¢ã¯ãlogrotateã§copytruncateãäœæããŸãããããã«ããããã¡ã€ã«ã®ã³ããŒãäœæãããå
ã®ãã¡ã€ã«ãã³ããŒãããŸãã ãããã£ãŠããããã®ã³ããŒããã»ã¹ã®éã«ããã£ã¹ã¯ã¹ããŒã¹ã¯éåžžçµäºããŸãã
ïŒ4ïŒç°ãªããã©ãŒãããããããç°ãªãAPIã䜿çšããŠããŸããã ãããã¯ãããã«ç°ãªã£ãŠããŸããããæ£èŠè¡šçŸã¯ç°ãªã£ãŠæžããªããã°ãªããŸããã§ããã ãããã¯ãã¹ãŠPuppetã«ãã£ãŠå¶åŸ¡ãããŠããããããŽãããªãšã¯ã©ã¹ã®å€§èŠæš¡ãªãã³ãã«ããããŸããã ããã«ãã»ãšãã©ã®å Žåãtd-agentã¯ã¡ã¢ãªãé£ã¹ãæãã§ãåäœããŠãããµããããŠãäœãããŸããã å€ã§ã¯ã圌ãäœãããŠããªãããšãç解ããããšã¯äžå¯èœã§ããã ããããã圌ã¯åãã誰ããåŸã§åœŒãæŸããŸãã ããæ£ç¢ºã«ã¯ãã¢ã©ãŒããå°çãã誰ããæã§ç¢ºèªããŸãã
ïŒ6ïŒãããŠãã»ãšãã©ã®ãŽããšå»æ£ç©-ããã¯elasticsearchã§ããã å€ãããŒãžã§ã³ã ã£ãããã§ãã ãªããªããåœæã¯å°ä»»ã®ãã¹ã¿ãŒãããªãã£ãããã§ãã ãã£ãŒã«ãã亀差ããç°çš®ãã°ããããŸããã ç°ãªãã¢ããªã±ãŒã·ã§ã³ã®ç°ãªããã°ãåããã£ãŒã«ãåã§æžã蟌ãããšãã§ããŸãããåæã«ç°ãªãããŒã¿ãå
éšã«ååšããå¯èœæ§ããããŸãã ã€ãŸãã1ã€ã®ãã°ã«ã¯ããã£ãŒã«ãïŒããšãã°ãã¬ãã«ïŒã«æŽæ°ãå«ãŸããŠããŸãã å¥ã®ãã°ã«ã¯ãã¬ãã«ãã£ãŒã«ãã«æååãå«ãŸããŠããŸãã éçãããã³ã°ãååšããªãå Žåããã®ãããªçŽ æŽããããã®ãåŸãããŸãã elasticsearchã§ã€ã³ããã¯ã¹ãããŒããŒã·ã§ã³ããåŸãæååãå«ãæåã®ã¡ãã»ãŒãžãå°çããå Žåãæ£åžžã«åäœããŠããŸãã ãããŠãIntegerã§æåã«å°çããå ŽåãStringã§å°çããåŸç¶ã®ã¡ãã»ãŒãžã¯ãã¹ãŠåã«ç Žæ£ãããŸãã ãã£ãŒã«ãã¿ã€ããäžèŽããªãããã§ãã
ç§ãã¡ã¯ãããã®è³ªåããå§ããŸããã ç§ãã¡ã¯æ眪ãæ¢ããªãããšã«ããŸããã
ããããäœãããå¿
èŠããããŸãïŒ æçœãªããšã¯ãåºæºãèšå®ããããšã§ãã ãã§ã«ããã€ãã®æšæºããããŸããã å°ãåŸã§å
¥æãããã®ããããŸãã 幞ããªããšã«ããã®æç¹ã§ãã¹ãŠã®APIã®çµ±äžããããã°åœ¢åŒãæ¢ã«æ¿èªãããŠããŸããã ãµãŒãã¹ã®çžäºäœçšã®æšæºã«çŽæ¥æžã蟌ãŸããŸãã ãããã£ãŠããã°ãåä¿¡ããã人ã¯ãã®åœ¢åŒã§ãã°ãæžãå¿
èŠããããŸãã 誰ãããã®åœ¢åŒã§ãã°ãæžã蟌ãŸãªãå Žåãäœãä¿èšŒããŸããã
ããã«ããã°ã®èšé²ãé
ä¿¡ãããã³åéã®æ¹æ³ã«é¢ããåäžã®æšæºã確ç«ããããšæããŸãã å®éã«ãããããã©ãã§æžããã©ã®ããã«é
ä¿¡ãããã çæ³çãªç¶æ³ã¯ããããžã§ã¯ããåãã©ã€ãã©ãªã䜿çšããå Žåã§ãã Goçšã®åå¥ã®ãã®ã³ã°ã©ã€ãã©ãªãšãPHPçšã®åå¥ã®ã©ã€ãã©ãªããããŸãã ç§ãã¡ãæã£ãŠãããã¹ãŠã®äºº-誰ãããããã䜿çšããå¿
èŠããããŸãã çŸæç¹ã§ã¯ãç§ãã¡ã¯ããã80ïŒ
ç²åŸããŠãããšèšããŸãã ãããããµããã³ãé£ã¹ç¶ãã人ãããŸãã
ãããŠãïŒã¹ã©ã€ãäžïŒããã°é
ä¿¡çšã®SLAããšãããããŠç»å ŽããŸããã 圌ã¯ãŸã ããã«ããŸããããç§ãã¡ã¯ããã«åãçµãã§ããŸãã ãªããªããããªãããã®ãããªå Žæã«ãã®ãããªåœ¢åŒã§æžã蟌ã¿ã1ç§ãããNã¡ãã»ãŒãžãè¶
ããªãå Žåããã®ãããªå Žæã«é
ä¿¡ããå¯èœæ§ãé«ããšã€ã³ãã©ãèšãã®ã¯éåžžã«äŸ¿å©ã ããã§ãã ããã¯é ââçã®æã軜æžããŸãã SLAãããå Žåãããã¯ãã°ãããã§ãïŒ
ã©ã®ããã«ããŠåé¡ã解決ãå§ããŸãããïŒ äž»ãªã¬ãŒãã¯td-agentã§ããã ãã°ã®è¡ãå
ãæ確ã§ã¯ãããŸããã§ããã 圌ãã¯é
éãããŸããïŒ åœŒãã¯è¡ããŸããïŒ ã©ãã«ããã®ïŒ ãããã£ãŠãæåã®é
ç®ã¯td-agentã眮ãæããããšã決å®ãããŸããã äœã«çœ®ãæãããã®ãªãã·ã§ã³ãç°¡åã«ã¹ã±ããããŸããã
æµFlu æåã«ãç§ã¯åã®ä»äºã§åœŒã«åºããããŸããããããŠã圌ã¯ãŸãå®æçã«ããã«èœã¡ãŸããã 第äºã«ãããã¯ãããã¡ã€ã«ã®ã¿ã§åãã§ãã
Filebeatã ç§ãã¡ã«ãšã£ãŠã©ã®ããã«äŸ¿å©ã§ãããïŒ åœŒãå²Goã«ãããšããäºå®ããããŠå²weã«ã¯å€ãã®å°éç¥èããããŸãã ãããã£ãŠããããããªããã©ããããããèªåã§è¿œå ããããšãã§ããŸãã ãããã£ãŠãæã
ã¯ãããåããªãã£ãã ãã®ãããèªåã§æžãçŽãããšããèªæã¯ãããŸããã§ããã
sysadminã®æãããªè§£æ±ºçã¯ããã®éã®ãã¹ãŠã®syslogïŒsyslog-ng / rsyslog / nxlogïŒã§ãã
ãŸãã¯ãç¬èªã®äœããäœæããŸãããfilebeatã®ããã«åé€ããŸããã äœããæžãå Žåã¯ãããžãã¹ã«åœ¹ç«ã€äœããæžãæ¹ãè¯ãã§ãããã ãã°ãé
ä¿¡ããã«ã¯ãäœããçšæããŠããããšããå§ãããŸãã
ãããã£ãŠãéžæã¯å®éã«ã¯syslog-ngãšrsyslogã®éã®éžæã«ãªããŸããã Puppetã«rsyslogã®ã¯ã©ã¹ããã§ã«ãããšããçç±ã ãã§ã圌ã¯rsyslogã«åŸåããŸãããããããã®éã«æãããªéãã¯èŠåœãããŸããã§ããã syslogãšã¯äœããsyslogãšã¯äœãã ã¯ããããã¥ã¡ã³ãã®è³ªãæªã人ãåªãã人ãããŸãã 圌ã¯ãã®æ¹æ³ãç¥ã£ãŠããã圌ã¯å¥ã®æ¹æ³ã§ã
rsyslogã«ã€ããŠãå°ã説æããŸãã ãŸããã¢ãžã¥ãŒã«ãããããããã®ã§ã¯ãŒã«ã§ãã 人éãèªããRainerScriptïŒææ°ã®æ§æèšèªïŒããããŸãã çŽ æŽãããããŒãã¹ã¯ãéåžžã®æ段ã䜿çšããŠtd-agentã®åäœããšãã¥ã¬ãŒãã§ããããšã§ãããã¢ããªã±ãŒã·ã§ã³ã§ã¯äœãå€ãããŸããã ã€ãŸããtd-agentãrsyslogã«å€æŽããŠãããä»ã®ãã¹ãŠã«è§ŠããŠããããã§ã¯ãããŸããã ãããŠããã«ç§éã¯åãé
éãåŸãŸãã 次ã«ãmmnormalizeã¯rsyslogã§çŽ æŽãããããšã§ãã ãã°ã解æã§ããŸãããGrokãšæ£èŠè¡šçŸã¯äœ¿çšã§ããŸããã 圌女ã¯æœè±¡çãªæ§æããªãŒãäœæããŸãã ã³ã³ãã€ã©ããœãŒã¹ã³ãŒãã解æãããšãã«ããã°ãããã解æããŸãã ããã«ãããéåžžã«è¿
éã«äœæ¥ã§ããCPUãã»ãšãã©æ¶è²»ãããäžè¬çã«éåžžã«ã¯ãŒã«ãªããšã§ãã ä»ã«ãããããã®ããŒãã¹ããããŸãã ç§ã¯ãããã«ã€ããŠãããŸããã
Rsyslogã«ã¯ãŸã å€ãã®æ¬ é¥ããããŸãã ãããã¯ããŒãã¹ãšã»ãŒåãã§ãã äž»ãªåé¡-ããªãã¯ããã調çã§ããããã«ããå¿
èŠããããããªãã¯ããŒãžã§ã³ãéžæããå¿
èŠããããŸãã
UNIXãœã±ããã«ãã°ãæžã蟌ãããšã«ããŸããã / dev / logã§ã¯ãªããã·ã¹ãã ãã°ããããªããžãããããããã®ãã€ãã©ã€ã³ã«ã¯ãžã£ãŒãã«ããããŸãã ããã§ã¯ãã«ã¹ã¿ã ãœã±ããã«æžã蟌ã¿ãŸãããã å¥ã®ã«ãŒã«ã»ããã«æ·»ä»ããŸãã å¹²æžããŸããã ãã¹ãŠãéæã§æ確ã«ãªããŸãã ã ããå®éã«ãã£ãã ãããã®ãœã±ããã®ãããã£ã¬ã¯ããªã¯æšæºåãããŠããããã¹ãŠã®ã³ã³ããã«è»¢éãããŸãã ã³ã³ããã¯å¿
èŠãªãœã±ããã確èªããéããŠæžã蟌ã¿ãŸãã
ãªããã¡ã€ã«ã§ã¯ãªãã®ã§ããïŒ èª°ãããã¡ã€ã«ãdockerã«è»¢éããããšããBadushechkaã«é¢ããèšäºãèªã¿ã rsyslogãåèµ·åãããšãã¡ã€ã«èšè¿°åãå€æŽãããdockerããã®ãã¡ã€ã«ã倱ãããšãå€æããããã§ãã 圌ã¯ä»ã®äœããéãããŸãŸã«ããŸããã圌ããæžããã®ãšåããœã±ããã¯éããŸããã ãã®åé¡ãåé¿ãããšåæã«ãããããã³ã°ã®åé¡ãåé¿ããããšã«ããŸããã
Rsyslogã¯ã¹ã©ã€ãã«ç€ºãããã¢ã¯ã·ã§ã³ãå®è¡ãããã°ããªã¬ãŒãŸãã¯Kafkaã«éä¿¡ããŸãã ã«ãã«ã¯æã®ããæ¹ã«ãããããŸãã ãªã¬ãŒ-ãã°ãé
ä¿¡ããããã«çŽç²ãªrsyslogã䜿çšããããšããŸããã Message Queueãªãã§ãæšæºã®rsyslogããŒã«ã åºæ¬çã«ã¯æ©èœããŸãã
ãã ããåŸã§ãã®éšåã«è©°ã蟌ãæ¹æ³ã«ã¯åŸ®åŠãªéãããããŸãïŒLogstash / Graylog / ESïŒã ãã®éšåïŒrsyslog-rsyslogïŒã¯ãããŒã¿ã»ã³ã¿ãŒéã§äœ¿çšãããŸãã ããã¯å§çž®ãããtcpãªã³ã¯ã§ããããã«ããã垯åå¹
ãç¯çŽããããã«å¿ããŠããã£ãã«ããã£ã±ãã®ç¶æ
ã§å¥ã®ããŒã¿ã»ã³ã¿ãŒããäœããã®ãã°ãåä¿¡ããå¯èœæ§ãé«ããããšãã§ããŸãã ãªããªããã€ã³ããã·ã¢ã«ã¯ãã¹ãŠãæªãããã§ãã ãããããã®çµ¶ãéãªãåââé¡ã®ããå Žæã§ãã
ã¢ããªã±ãŒã·ã§ã³ããèšé²ãããã°ãã©ã®çšåºŠã®ç¢ºçã§å®éã«ç£èŠãããããèããŸããã ã¡ããªãã¯ãååŸããããšã«ããŸããã Rsyslogã«ã¯ç¬èªã®çµ±èšåéã¢ãžã¥ãŒã«ããããããã«ã¯äœããã®çš®é¡ã®ã«ãŠã³ã¿ãŒããããŸãã ããšãã°ããã¥ââãŒã®ãµã€ãºããŸãã¯ãã®ãããªã¢ã¯ã·ã§ã³ã§åä¿¡ããã¡ãã»ãŒãžã®æ°ã衚瀺ã§ããŸãã ãããããäœãããã§ã«åãããšãã§ããŸãã ããã«ãæ§æå¯èœãªã«ã¹ã¿ã ã«ãŠã³ã¿ãŒããããããšãã°ãããAPIãæžã蟌ãã ã¡ãã»ãŒãžã®æ°ã衚瀺ããŸãã 次ã«ãPythonã§rsyslog_exporterãäœæãããã¹ãŠãPrometheusã«éä¿¡ããŠããããããŸããã Graylogã¡ããªãã¯ã¯æ¬åœã«å¿
èŠã§ãããããããŸã§ã®ãšãããæ§æããæéããããŸããã§ããã
åé¡ã¯äœã§ããïŒ ã©ã€ãAPIã1ç§ããã5äžä»¶ã®ã¡ãã»ãŒãžãæžã蟌ãããšãçºèŠããïŒçªç¶ïŒïŒãšããäºå®ã«åé¡ãçºçããŸããã ããã¯ã¹ããŒãžã³ã°ã®ãªãã©ã€ãAPIã®ã¿ã§ãã ãŸããGraylogã§ã¯ã1ç§ããã12,000件ã®ã¡ãã»ãŒãžãã衚瀺ãããŸããã ãããŠãåççãªçåãçããŸããããæ®ãç©ã¯ã©ãã«ãããŸããïŒ ãããããGraylogã¯å¯Ÿå¿ã§ããªããšçµè«ä»ããŸããã 圌ãã¯èŠãããããŠå®éãElasticsearchãåããGraylogã¯ãã®ã¹ããªãŒã ããã¹ã¿ãŒããªãã£ãã
ããã«ããã®éçšã§è¡ã£ãä»ã®çºèŠã
ãœã±ãããžã®æžã蟌ã¿ã¯ãããã¯ãããŸãã ããã¯ã©ã®ããã«èµ·ãããŸãããïŒ é
ä¿¡ã«rsyslogã䜿çšãããšãããæç¹ã§ããŒã¿ã»ã³ã¿ãŒéã®ãã£ãã«ãå£ããŸããã é
éã¯ããå Žæã§èµ·ããé
éã¯å¥ã®å Žæã§èµ·ããŸããã ãããã¯ãã¹ãŠãrsyslogãœã±ããã«æžã蟌ãAPIãåãããã·ã³ã«å°éããŸããã ãã¥ãŒããããŸããã 次ã«ãUnixãœã±ããã«æžã蟌ãããã®ãã¥ãŒããã£ã±ãã«ãªããŸãããããã©ã«ãã¯128ãã±ããã§ãã ãããŠãã¢ããªã±ãŒã·ã§ã³å
ã®æ¬¡ã®æžã蟌ã¿ïŒïŒã¯ãããã¯ãããŸãã Goã®ã¢ããªã±ãŒã·ã§ã³ã§äœ¿çšããã©ã€ãã©ãªãèŠããšãéæžã蟌ã¿ã¢ãŒãã§ãœã±ãããžã®æžã蟌ã¿ãçºçããããšãæžãããŠããŸãã äœããããã¯ããŠããªããšç¢ºä¿¡ããŠããŸããã ããã¥ã·ã§ãã«ã«ã€ããŠæžããèšäºãèªãã ããã§ãã ããããç¬éããããŸãã ãã®åŒã³åºãã®åšãã«ã¯ãã¡ãã»ãŒãžããœã±ããã«ããã·ã¥ããããšçµ¶ããè©Šã¿ãããç¡éã®ãµã€ã¯ã«ããŸã ãããŸããã 圌ã«ã¯æ°ã¥ããªãã£ãã ã©ã€ãã©ãªãæžãçŽãå¿
èŠããããŸããã ãã以æ¥ãæ°åå€æŽãããŸããããä»ã§ã¯ãã¹ãŠã®ãµãã·ã¹ãã ã®ããã¯ããªããªããŸããã ãããã£ãŠãrsyslogãåæ¢ã§ããäœãèœã¡ãŸããã
ãã¥ãŒã®ãµã€ãºãç£èŠããå¿
èŠããããŸããããã¯ããã®ã¬ãŒããèžãŸãªãããã«ããã®ã«åœ¹ç«ã¡ãŸãã ãŸããã¡ãã»ãŒãžã倱ããå§ããã®ãç£èŠã§ããŸãã 第äºã«ãååãšããŠé
ä¿¡ã®åé¡ãããããšãç£èŠã§ããŸãã
ãããŠå¥ã®äžå¿«ãªç¬é-ãã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ã§10åã®å¢å¹
-ããã¯éåžžã«ç°¡åã§ãã çä¿¡ãªã¯ãšã¹ãã¯ããŸããããŸãããããããã®ã¡ãã»ãŒãžãå®è¡ãããã°ã©ãã®ãããã¢ã¯ã»ã¹ãã°ã®ããããã°ã®è² è·ã¯å®éã«çŽ10åã«å¢å ããŸãã æ®å¿µãªãããæ£ç¢ºãªæ°å€ãèšç®ããæéã¯ãããŸããã§ãããããã€ã¯ããµãŒãã¹ã¯ããã§ãã ããã«çæããå¿
èŠããããŸãã çŸæç¹ã§ã¯ããã°åéãµãã·ã¹ãã ãã©ã¶ãã§æãè² è·ãé«ãããšãå€æããŠããŸãã
elasticsearchã®åé¡ã解決ããã«ã¯ïŒ ãã¹ãŠã®ãã·ã³ã«ãŸããã£ãŠãã°ãåéããªãããã«ããã°ã1ãæã§ãã°ããååŸããå¿
èŠãããå Žåã¯ããã¡ã€ã«ã¹ãã¬ãŒãžã䜿çšããŸãã ããã¯æ©èœããããšãä¿èšŒãããŠããŸãã ä»»æã®ãµãŒããŒããäœæãããŸãã ããã«ãã£ã¹ã¯ã貌ãä»ããŠsyslogãé
眮ããã ãã§ãã ãã®åŸããã¹ãŠã®ãã°ã1ãæã«ä¿åããããšãä¿èšŒãããŸãã ããã«ãElasticsearchãgraylogãªã©ããã£ãã調æŽããããšã¯ãã§ã«å¯èœã§ãã ãããããã§ã«ãã¹ãŠã®ãã°ããããããã«ãååãªãã£ã¹ã¯ã¢ã¬ã€ãŸã§ãã°ãä¿åã§ããŸãã
ç§ã®å ±åã®æç¹ã§ãåè·¯ã¯ãã®ããã«èŠãå§ããŸããã ãã¡ã€ã«ãžã®æžã蟌ã¿ãå®è³ªçã«åæ¢ããŸããã ä»ãã»ãšãã©ã®å Žåãæ®ãç©ããªãã«ããŸãã APIãå®è¡ããŠããããŒã«ã«ãã·ã³ã§ã¯ããã¡ã€ã«ãžã®æžã蟌ã¿ãåæ¢ããŸãã ãŸããéåžžã«ããŸãæ©èœãããã¡ã€ã«ã¹ãã¬ãŒãžããããŸãã 第äºã«ããããã®ãã·ã³äžã®å Žæã¯çµ¶ããå°œããŠããã絶ããç£èŠããå¿
èŠããããŸãã
LogstashãšGraylogã®ãã®éšåã¯ãæ¬åœã«æ¥äžæããŠããŸãã ãããã£ãŠããããåãé€ãå¿
èŠããããŸãã 1ã€éžæããå¿
èŠããããŸãã
LogstashãšKibanaãæããããšã«ããŸããã ã»ãã¥ãªãã£éšéãããããã§ãã æ¥ç¶ãšã¯äœã§ããïŒ æ¥ç¶ã¯ãX-Packããã³Shieldãªãã®Kibanaã§ã¯ããã°ãžã®ã¢ã¯ã»ã¹æš©ãåºå¥ã§ããªãããšã§ãã ãããã£ãŠã圌ãã¯ã°ã¬ã€ãã°ãåããŸããã 圌ã¯ããããã¹ãŠæã£ãŠããŸãã ç§ã¯åœŒã奜ãã§ã¯ãããŸããããããŸããããŸãã æ°ããéã賌å
¥ããããã«æ°ããGraylogãé
眮ããå³æ Œãªåœ¢åŒã®ãã¹ãŠã®ãã°ãå¥ã®Graylogã«ç§»åããŸããã ããŸããŸãªã¿ã€ãã®åäžã®ãã£ãŒã«ããçµç¹çã«è§£æ±ºããŠåé¡ã解決ããŸããã
æ°ããGraylogã«æ£ç¢ºã«å«ãŸãããã®ã Dockerã«ãã¹ãŠãèšé²ããŸããã ãµãŒããŒã®æãåãã3ã€ã®Kafkaã€ã³ã¹ã¿ã³ã¹ã7ã€ã®GraylogãµãŒããŒããŒãžã§ã³2.3ãå±éããŸããïŒElasticsearchããŒãžã§ã³5ãå¿
èŠã ã£ãããïŒã HDDããã®è¥²æã«é¢ããããã¯ãã¹ãŠçºçããŸããã 1ç§ãããæ倧10äžã¡ãã»ãŒãžã®ã€ã³ããã¯ã¹äœæçãèŠãŸããã é±ã«140ãã©ãã€ãã®ããŒã¿ãããããšãããããŸããã
ãããŠåã³çæïŒ 2ã€ã®è²©å£²ãæ¥ãŠããŸãã 600äžéã®ã¡ãã»ãŒãžã移åããŸããã ã°ã¬ã€ãã°ã«ã¯åãæéããããŸããã ã©ãããããããç§ãã¡ã¯åã³çãæ®ãå¿
èŠããããŸãã
ãã®ããã«çã延ã³ãŸããã ããã«ããã€ãã®ãµãŒããŒãšSSDãè¿œå ããŸããã çŸæç¹ã§ã¯ãç§ãã¡ã¯ãã®ããã«çããŠããŸãã çŸåšããã§ã«1ç§ããã160kã®ã¡ãã»ãŒãžãåãã§ããŸãã ç§ãã¡ã¯ãŸã éçã«éããŠããªãã®ã§ãã©ãã ãå®éã«ããããæãåºãããã¯ãŸã æ確ã§ã¯ãããŸããã
ãããã¯å°æ¥ã®èšç»ã§ãã ãããã®ãã¡ãæãéèŠãªã®ã¯ããããé«å¯çšæ§ã§ãã ãŸã ãããŸããã è€æ°ã®è»ãåãããã«æ§æãããŠããŸããããããŸã§ã®ãšããããã¹ãŠã1å°ã®è»ãééããŠããŸãã ãããã®éã«ãã§ã€ã«ãªãŒããŒãã»ããã¢ããããã«ã¯æéãããããŸãã
Graylogã§ã¡ããªãã¯ãåéããŸãã
垯åå¹
ããã®ä»ãã¹ãŠãç ç²ã«ããªããã¯ã¬ã€ãžãŒãªAPIã1ã€ããããã«ãã¬ãŒãå¶éãèšå®ããŸãã
ãããŠæåŸã«ãéçºè
ãšäœããã®SLAã«çœ²åããŠãããã ãã®ãµãŒãã¹ãæäŸã§ããããã«ããŸãã ãã£ãšæžããªããããããªããã
ãããŠãããã¥ã¡ã³ããæžããŸãã
ç°¡åã«èšãã°ãç§ãã¡ãçµéšãããã¹ãŠã®çµæã§ãã ãŸããæšæºã 第äºã«ãsyslogã¯ã±ãŒãã§ãã 第äžã«ãrsyslogã¯ã¹ã©ã€ãã«æžãããŠãããšããã«æ©èœããŸãã ãããŠè³ªåã«è¡ããŸãããã
質å
質å ïŒãªã圌ãã¯æçšããªãããšã«æ±ºããã®ã§ãã...ïŒfilebeatïŒïŒ
åç ïŒãã¡ã€ã«ã«æžã蟌ãå¿
èŠããããŸãã æ¬åœã«ããããããŸããã§ãã APIã1ç§éã«æ°åã®ã¡ãã»ãŒãžãæžã蟌ãå Žåã1æéã«1åããŒããŒã·ã§ã³ããŠããããã¯ãŸã ãªãã·ã§ã³ã§ã¯ãããŸããã ãã€ãã§æžãããšãã§ããŸãã éçºè
ãç§ã«å°ãããã®ïŒãç§ãã¡ãæžãããã»ã¹ãèœã¡ããã©ããªããŸããïŒã ç§ã¯åœŒãã«äœãçããã¹ããèŠã€ããããªãã£ãã®ã§ãããŸããããã¯ãããŸãããããšèšããŸããã
質å ïŒåçŽã«HDFSã§ãã°ãæžããŸãããïŒ
åç ïŒããã¯æ¬¡ã®ã¹ãããã§ãã ç§ãã¡ã¯æåããããã«ã€ããŠèããŸããããçŸåšãããè¡ãããã®ãªãœãŒã¹ããªããããé·æçãªè§£æ±ºçã«ããã£ãŠããŸãã
質å ïŒå圢åŒã®æ¹ãé©ããŠããŸãã
åç ïŒç§ã¯ãã¹ãŠãç解ããŠããŸãã ç§ãã¡ã¯äž¡æã®ããã§ãã
質å ïŒããªãã¯rsyslogã«æžããŠããŸãã ããã§TCPãšUDPã䜿çšã§ããŸãã ããããUDPã®å Žåãã©ã®ããã«é
ä¿¡ãä¿èšŒããŸããïŒ
åç ïŒ2ã€ã®ãã€ã³ãããããŸãã æåã«ããã°ã®é
ä¿¡ãä¿èšŒããªãããšãããã«å
šå¡ã«äŒããŸãã éçºè
ãæ¥ãŠãã財åããŒã¿ãæžãå§ããŸããããäœããèµ·ãã£ãå Žåã«åããŠãã©ããã«çœ®ããŠãã ããããšèšãã®ã§ãç§ãã¡ã¯ãçŽ æŽãããïŒ ãœã±ãããžã®æžã蟌ã¿ããããã¯ãå§ãããã©ã³ã¶ã¯ã·ã§ã³ã§ãããè¡ããŸããããããããšã§ããœã±ããã«ç¢ºå®ã«æ¿å
¥ãããã®åŽããåä¿¡ããããšã確èªã§ããŸãã ãããå¿
èŠã§ãªãå Žåãç§ãã¡ã®è³ªåã¯äœã§ããïŒ ãœã±ãããžã®æžã蟌ã¿ãä¿èšŒããããªãå Žåããªãé
ä¿¡ãä¿èšŒããã®ã§ããïŒ æåãå°œãããŸãã ç§ãã¡ã¯ãå¯èœãªéãæ倧éã«é
ä¿¡ããããã«å¿ãããŠããŸããã100ïŒ
ã®ä¿èšŒã¯ããããŸããã ãããã£ãŠãããã«è²¡åããŒã¿ãæžã蟌ãŸãªãã§ãã ããã ãã®ããã®ãã©ã³ã¶ã¯ã·ã§ã³ãæã€ããŒã¿ããŒã¹ããããŸãã
質å ïŒAPIããã°ã«ã¡ãã»ãŒãžãçæããå¶åŸ¡ããã€ã¯ããµãŒãã¹ã«è»¢éãããšãã«ãç°ãªããã€ã¯ããµãŒãã¹ããã®ã¡ãã»ãŒãžã®é åºãééã£ãŠãããšããåé¡ãçºçããŸãããïŒ ããã«ããæ··ä¹±ãçããŸãã
åç ïŒé çªãéãã®ã¯æ®éã§ãã ãã®ããã«æºåããå¿
èŠããããŸãã ãããã¯ãŒã¯é
ä¿¡ã¯é åºãä¿èšŒãããã®ã§ã¯ãªãããããŸãã¯ããã«ç¹ã«ãªãœãŒã¹ãè²»ããå¿
èŠãããããã§ãã ãã¡ã€ã«ã¹ãã¬ãŒãžã䜿çšããå ŽåãåAPIã¯ç¬èªã®ãã¡ã€ã«ã«ãã°ãä¿åããŸãã ããããrsyslogã¯ãããããã£ã¬ã¯ããªã«å解ããŸãã åAPIã«ã¯ç¬èªã®ãã°ããããããã«è¡ã£ãŠèŠãããšãã§ãããã®ãã°ã®ã¿ã€ã ã¹ã¿ã³ãã䜿çšããŠããããæ¯èŒã§ããŸãã Graylogã調ã¹ã«è¡ããšãããã§ã¿ã€ã ã¹ã¿ã³ãã§ãœãŒããããŸãã ããã¯ãã¹ãŠããŸããããŸãã
質å ïŒã¿ã€ã ã¹ã¿ã³ãã¯ããªç§åäœã§ç°ãªãå ŽåããããŸãã
åç ïŒã¿ã€ã ã¹ã¿ã³ãã¯APIèªäœãçæããŸãã å®éãããããã¹ãŠã§ãã NTPããããŸãã APIã¯ãã¡ãã»ãŒãžèªäœã«æ¢ã«ã¿ã€ã ã¹ã¿ã³ããçæããŸãã rsyslogã¯è¿œå ãããŸããã
質å ïŒããŒã¿ã»ã³ã¿ãŒéã®çžäºäœçšã¯ããŸãæ確ã§ã¯ãããŸããã ããŒã¿ã»ã³ã¿ãŒã®ãã¬ãŒã ã¯ãŒã¯ã§ã¯ããã°ãã©ã®ããã«åéãåŠçãããããæ確ã§ãã ããŒã¿ã»ã³ã¿ãŒéã®çžäºäœçšã¯ã©ãã§ããïŒ ãŸãã¯ãåããŒã¿ã»ã³ã¿ãŒã¯ç¬èªã®ç掻ãéã£ãŠããŸããïŒ
åç ïŒã»ãŒã - . , . . Log Relay. Rsyslog . . . . . . , (), Graylog. storage. , , . . .
: ?
: ( ) .
: , ?
: , . . , Go API, . , socket. . . socket. , . . , . prometheus, Grafana . . , .
: elasticsearch . ?
: .
: ?
: . .
: rsyslog - ?
: unix socket. 128 . . . , 128 . , , , , . , . .
c : JSON?
: JSON relay, . Graylog, JSON . , , rsyslog. issue, .
c : Kafka? RabbitMQ? Graylog ?
: Graylog . Graylog . . . , , . rsyslog elasticsearch Kibana. . , Graylog Kibana. Logstash . , rsyslog. elasticsearch. Graylog - . . .
Kafka. ããã¯æŽå²çã«äºå®ã§ãã , , . . , , . RabbitMQ⊠c RabbitMQ. RabbitMQ . , . , . . ãã1ã€ãã€ã³ãããããŸãã Graylog AMQP 0.9, rsyslog AMQP 1.0. , , . . Kafka. . omkafka rsyslog, , , rsyslog. .
c : Kafka , ? ?
: Kafka, , Data Sience. , , , . . Data Sience. , . Graylog, , Kafka. . API. live, staging . Graylog .
c : ? log- syslog .
: , . docker 1.0 0.9. Docker . -, ⊠, , . API , API , stdout stderr. . , syslog- . Graylog . log- . GELF Graylog. , , . , - , , .
質åïŒrsyslogã§ããŒã¿ã»ã³ã¿ãŒéã®é
ä¿¡ãè¡ããŸãããªãã«ãã«ã«ããŸãããïŒ
åçïŒç§ãã¡ã¯äž¡æ¹ãè¡ã£ãŠããã®ã§ãå®éã«ã¯ããã§ãã2ã€ã®çç±ããããŸãããã£ãã«ãå®å
šã«åæ¢ããŠããå Žåãå§çž®ããã圢åŒã§ããã¹ãŠã®ãã°ãã¯ããŒã«ãããŸããããŸããkafkaã䜿çšãããšãããã»ã¹ã§ããããåçŽã«å€±ããŸãããã®ããã«ããŠããããã®ãã°ã貌ãä»ããå¿
èŠããªããªããŸãããã®å ŽåãKafkaãçŽæ¥äœ¿çšããŸããè¯ããã£ãã«ããããããã解æŸãããå Žåã¯ãrsyslogã䜿çšããŸãããããå®éã«ã¯ãã¯ããŒã«ãããªãã£ããã®ã圌èªèº«ãèœãšãããã«èšå®ã§ããŸããçŸæç¹ã§ã¯ãrsyslogé
ä¿¡ãçŽæ¥äœ¿çšããŠããå ŽæãKafkaã䜿çšããŠããŸãã