ã¯ããã«
ããã«ã¡ã¯ãã¯ãã¯ããã SRE ã® @mozamimy ã§ããå æ¥ãã®éçºè ããã°ã§ One Experience ããã¸ã§ã¯ãã«ã¤ãã¦ã®ç´¹ä»ãããã¾ããã
ãã®ããã¸ã§ã¯ãã«ããã¦ããããã¯æ¥æ¬çããã°ãã¼ãã«çã¸ã®ç§»è¡ã®éã®å ¨è¬çãªããã©ã¼ãã³ã¹å¨ãã«ã¤ãã¦åãçµãã§ãã¾ããã
ããã©ã¼ãã³ã¹ã¨ä¸è¨ã§ãã£ã¦ãããã®ä¸ã«ã¯ãããã¯ã¼ã¯ãã¢ããªã±ã¼ã·ã§ã³ã¬ã¤ã¤ã§ã®ã¬ã¤ãã³ã·ãMySQL ãªã©ã®ããã«ã¦ã§ã¢ã§ã®ã¬ã¤ãã³ã·ãªã©ãæ§ã ãªè¦å ãé¢ãã£ã¦ãã¾ãããããã®æ¹åã«ããã¦ãä½ãããéè¦ãªã®ã¯ã¾ã観測ãããã¨ã§ãã移è¡ã«ããã¦åãçµãã æ§ã ãªä½æ¥ã®ãã¡ãããã§ã¯ CloudWatch RUM ã Calibre ã¨ãã£ããã¼ã«ãç¨ãã Web ãã©ã¦ã¶ããã®ã¢ã¯ã»ã¹ã®ããã©ã¼ãã³ã¹è¦³æ¸¬ã«ç¦ç¹ãå½ã¦ã¦ç´¹ä»ãã¾ãã
ãã©ãããã©ã¼ã 移è¡ã«ããããã©ã¼ãã³ã¹ã®å£åãã§ããéãé¿ããã
å è¿°ã® One Experience ã®ç´¹ä»è¨äºã§ãæ¸ããã¦ããéããæ¥æ¬çã¨ã°ãã¼ãã«çã¯å®å ¨ã«ç¬ç«ãããã©ãããã©ã¼ã ä¸ã§åä½ãã¦ãã¾ããããªãã¡æ¥æ¬çã¨ã°ãã¼ãã«çã§ã¯ããã©ã¼ãã³ã¹ç¹æ§ãã¾ã£ããç°ãªãã¨ãããã¨ã§ãã
ã¾ãããã¼ã¿ã®çµ±åã«ãã MySQL é¢é£ã®ãã¼ã¿å¢å ã«ããããã©ã¼ãã³ã¹ç¹æ§ã®å¤åãæ¸å¿µäºé ã®ä¸ã¤ã§ãããã°ãã¼ãã«çã¨æ¥æ¬çã®ãã¼ã¿éãæ¯è¼ããã¨æ¥æ¬çã®æ¹ã大ãããçµ±åå¾ã«ã¯ãã¼ã¿éãå¤§å¹ ã«å¢å ããããã§ãããã¼ã¿ç§»è¡ã®ä½æ¥ã®ä¸é¨ã§ããç¶ç¶çãªãã¼ã¿ç§»è¡ã«ã¤ãã¦ã¯ãå æ¥é´æ¨ã«ããè¨äºãå ¬éããã¦ãã¾ãã
ãã®ä»ã«ãã¦ã¼ã¶ã«ã¨ã£ã¦ç¢ºå®ã«æªå½±é¿ãããã¨è¦è¾¼ã¾ãã¦ããã®ããã·ã¹ãã ãåä½ãã¦ãããªã¼ã¸ã§ã³ã®éãã«ããã¬ã¤ãã³ã·ã®å¢å ã§ãã両æ¹ã¨ã AWS ãå©ç¨ãã¦ãã¾ãããæ¥æ¬ç㯠ap-northeast-1 (æ±äº¬) ã«ãã°ãã¼ãã«ç㯠us-east-1 (ãã¼ã¸ãã¢åé¨) ã«ãããã¤ããã¦ãã¾ã1ã
One Experience ã§ã¯ã°ãã¼ãã«çã«æ¥æ¬çãçµ±åããã¨ããæ¹éã«ãªã£ã以ä¸ããã®ã¾ã¾ã®ã¢ã¼ããã¯ãã£ã ã¨æ¥æ¬ããã®ãã©ãã£ãã¯ã¯å¤ªå¹³æ´ã¨åç±³ã横æãããã¨ã«ãªãããããããã¯ã¼ã¯èµ·å ã®ã¬ã¤ãã³ã·ã®å¢å ã¯é¿ãããã¾ããããã®å·®ãåããããã«ã
- ã°ãã¼ãã«çã® Rails ã¢ããªã±ã¼ã·ã§ã³ã®å®è£ ãæ¹åãã¦ããã©ã¼ãã³ã¹ãä¸ãã
- MySQL ã¯ã¨ãªã®æ¹åãé©åãªãã£ãã·ã¥ã®å©ç¨ãªã©ã§ããã©ã¼ãã³ã¹ãä¸ãã
- ããã³ãã¨ã³ãã®å®è£ ãæ¹åãã¦è¦ããã®ããã©ã¼ãã³ã¹ãä¸ãã
- ãã«ããªã¼ã¸ã§ã³ãããã¤: æ¥æ¬ã¦ã¼ã¶ããè¿ãå ´æã«ãµã¼ããç½®ã
ãªã©ãªã©ã移è¡ã«ã¤ãã¦åãå§ãã段éã§ããããã¨æ¹åããä½å°ã»æ段ããããã¨ã¯æ¼ ç¶ã¨åãã£ã¦ãã¾ããããã ãåãçµã¿ã«ãã£ã¦ã¯å®è£ ã»éç¨ã³ã¹ãã大ãããããã¾ãã¯ç¾ç¶ããã£ããã¨ææ¡ãã¦ä½ããåãçµãã§ããã¨ããããèããå¿ è¦ãããã¾ãããã¾ããããã©ã¼ãã³ã¹å·®ãåããããã®å¤æææã¨ãã¦ã®è¨æ¸¬ããã¡ããã§ãããããã¯ããã¨ãã¦å®éã«ç§»è¡ãé²ãã¦ããã«ããã£ã¦æ¥æ¬çã¨ã°ãã¼ãã«çã®ããã©ã¼ãã³ã¹å·®ã®æ¥ã ã®å¤åããã©ãã¯ããå¿ è¦ãããã¾ããã
ã¦ã¼ã¶ããè¦ãç·åçãªããã©ã¼ãã³ã¹ã測å®ããããã®ææ³ã¨ãã¦ãRUM (Real User Monitoring) ããã³ synthetic monitoring ãããã¾ããOne Experience ã§ã¯ RUM ã¨ã㦠Amazon CloudWatch RUM (ä»¥ä¸ CloudWatch RUM ã¨è¡¨è¨) ãæ¡ç¨ããsynthetic monitoring ã¨ã㦠Calibre ãæ¡ç¨ãã¾ãããCloudWatch RUM ã®å©ç¨ã«ããã£ã¦ãããã工夫ããç¹ãããã®ã§ãæ¬ç¨¿ã§ã¯ç¹ã« CloudWatch RUM ã«ã¤ãã¦æ·±æããã¦ããã¾ãã
CloudWatch RUM ã®å°å ¥ã¨æ´»ç¨ããããã®å·¥å¤«
RUM ã«ã¤ãã¦
RUM (Real User Monitoring) ã¯ã¦ã¼ã¶ããè¦ãç·åçãªããã©ã¼ãã³ã¹ãè¨æ¸¬ããä¸ã§ã¡ã¤ã³ã¨ãªããã®ã§ãã¯ã©ã¤ã¢ã³ããµã¤ãã§è¨æ¸¬ããããã©ã¼ãã³ã¹ææ¨ã¨ãªãæ°å¤ãã¨ã©ã¼ãªã©ãåéããåæã»å¯è¦åããããã®ãã¼ã«ã§ãã
One Experience ã«ããã¦ã¯ RUM ã§åéãã Core Web Vitals ã®ãã¡ãLCP (Largest Contentful Paint) ã KPI ã¨ãã¦å©ç¨ãããã¨ã«ãã¾ããã詳細ãªèª¬æã¯ãªã³ã¯å ã«è²ãã¾ãããLCP ã¨ã¯ã¦ã§ããã¼ã¸ä¸ã®ãã£ã¨ã大ããªé¢ç©ãå ããç»åã¾ã㯠HTML ã¨ã¬ã¡ã³ããæç»ãããã¾ã§ã®æéãæãã¾ãã
RUM ãå®ç¾ããããã®ãµã¼ãã¹ã¯ Datadog ãªã©ãã¯ããããããã¨é¸æè¢ã¯ããã¾ããã以ä¸ã®çç±ãã CloudWatch RUM ãé¸æãã¾ããã
- 競åã®ã½ãªã¥ã¼ã·ã§ã³ã¨æ¯ã¹ã¦æ¯è¼çå®ä¾¡
- æ¢ã« AWS ãå©ç¨ãã¦ããã社å ã§ã®æç¶ãã®ãããããçããããå°å ¥ã®ãã¼ãã«ãä½ã
- çã®ãã°ã CloudWatch Logs ã«åºããã®ã§é«åº¦ãªåæããããããAWS ã®å¥ãµã¼ãã¹ã¨ã®é£æºãå¯è½
CloudWatch RUM ã®å°å ¥
CloudWatch RUM ã® Rails ã¢ããªã±ã¼ã·ã§ã³ã¸ã®çµã¿è¾¼ã¿ã AWS å´ã§ã®ãªã½ã¼ã¹ã®æºåã¯ç¹ã«é£ãããã¨ããªããããã¥ã¡ã³ãã«ãããã£ã¦ä»¥ä¸ã®ãããªæé ãè¸ãã°å®éã«ã¤ãã³ããã¼ã¿ãéä¿¡ãããç¶æ ã«ãªãã¾ããã
- Cognito identity pool ãç¨æ
- RUM ã® app monitor ãä½æ
- 2 ã§ä½æãã app monitor ã«ãã°ãéä¿¡ã§ãã権éãæ㤠IAM role ãä½æ
- identity pool ã« IAM role ãç´ä»ã
- Rails ã¢ããªã±ã¼ã·ã§ã³ã®ããã³ãã¨ã³ãã« RUM ç¨ã®ã³ã¼ãã¹ããããã追å
対象ã¨ãªã Rails ã¢ããªã±ã¼ã·ã§ã³ã¯æ¥æ¬çã¨ã°ãã¼ãã«çã®ä¸¡æ¹ã«ãªãã¾ãããapp monitor ã¯ããã¦ä¸ã¤ã«ãã¾ãããæ¥æ¬çã»ã°ãã¼ãã«çã¨ãã«åä¸ã® web origin ã§ãã https://cookpad.com ãå©ç¨ãã¦ãããã¨ã¨ãã®ã¡ã»ã©ç´¹ä»ããåæã«ããã¦ã¤ãã³ããã¼ã¿ãä¸ã¤ã® CloudWatch Logs ã°ã«ã¼ãã«ã¾ã¨ã¾ã£ã¦ããã»ããé½åãããããã§ãã
å°å ¥èªä½ã¯ç°¡åã§ããã詳細ãªåæãè¡ãããã«ããã¤ãã®è¨å®ãè¡ãå¿ è¦ããã£ãã®ã§ã以ä¸ã®ã»ã¯ã·ã§ã³ã§ãããã«ã¤ãã¦èª¬æãã¾ãã
CloudWatch Logs ã¸ã®ã¨ã¯ã¹ãã¼ã
ã¤ãã³ããã¼ã¿ã®è©³ç´°ãªåæããããå ´åãapp monitor ã®ä½ææã« CloudWatch Logs ã«åºåããè¨å®ãå ¥ããã¨ä¾¿å©ã§ããã¾ããã®éããã°ã°ã«ã¼ãã« expire ãè¨å®ãã¦ããã¨ããã§ããããCloudWatch Logs ã®ã³ã¹ãã®å¤ãããã°ã®åãè¾¼ã¿ãå ããã¨ã¯ãããã¹ãã¬ã¼ã¸ã«ãããã³ã¹ããç¡è¦ã§ãã¾ããã
è¦ä»¶ã«å¿ãã attribute ã®è¿½å
Rails ã¢ããªã±ã¼ã·ã§ã³ã® JavaScript ã³ã¼ã㧠RUM ã¯ã©ã¤ã¢ã³ããåæåããéãä»»æã® attribute ã追å ãããã¨ãã§ãã¾ããä»åã¯ãã°ãã¼ãã«çãæ¥æ¬çãåºå¥ããããã® railsAppãRails ã®ã³ã³ããã¼ã©ãåºå¥ããããã® railsControllerãRails ã®ã¢ã¯ã·ã§ã³ãåºå¥ããããã® railsAction ãããããè¨å®ãããã¨ã§åæãããããã¾ãããããããè¨å®ãã¦ãããã¨ã§ CloudWatch RUM ã®ã³ã³ã½ã¼ã«ã§ã¤ãã³ããçµãè¾¼ãã§åæã§ãã¾ãããã¨ãã°ãããã©ã«ãã§ä»ä¸ããã countryCode ãªã©ã® attribute ãçµã¿åããã¦ä»¥ä¸ã®ããã«ãã£ã«ã¿ããã¨ããã°ãã¼ãã«çã®ã¬ã·ã詳細ãã¼ã¸ã«æ¥æ¬ããã¹ãã¼ããã©ã³ã§ã¢ã¯ã»ã¹ããã¤ãã³ããã«çµãè¾¼ããã¨ãã§ãã¾ãã
ãµã³ããªã³ã°ã¬ã¼ãã®è¨å®
RUM ã¯ã©ã¤ã¢ã³ãã®è¨å®ã®éã«ã¯é©åãªãµã³ããªã³ã°ã¬ã¼ããå®ããå¿ è¦ãããã¾ãã100% ã«è¿ä»ããã°è¿ä»ããã»ã©ãããã精度ã§ãã¼ã¿ãå¾ããã¾ããå½ç¶ã³ã¹ãã¯å¢å ãã¾ããCloudWatch RUM ã¯ã¤ãã³ãæ°ã«ãã課éãªã®ã§ãã©ãã£ãã¯éããããããã®æéãäºæ¸¬ããããã§ãããã£ããã¯ã©ã¦ãç ´ç£ããªããããããç¨åº¦è¦ç©ãã£ãä¸ã§å°ãªãå²åããå§ãã¦ãAWS Cost Explorer ãçºããªããè¦ä»¶ãå¶ç´ã«å¿ãã¦é©åã«èª¿æ´ããã¨ããã§ãããã
åéãããã¼ã¿ã AWS ã³ã³ã½ã¼ã«ããåæã»ãã©ãã¯ãã
ã¤ãã³ããã¼ã¿ã®åéãéå§ããã°ã以ä¸ã®ã¹ã¯ãªã¼ã³ã·ã§ããã®ããã« CloudWatch RUM ã®ã³ã³ã½ã¼ã«ãããã£ã«ã¿ãæéã§æãä¸ãã¦ããå½¢ã§ããã©ã¼ãã³ã¹ã«ã¤ãã¦åæãããã¨ãã§ãã¾ããã¨ã©ã¼ã JavaScript ã«ãã HTTP(S) éä¿¡ã®å®è¡ãã»ãã·ã§ã³ãã¨ã«ã¤ãã³ãã確èªãããªã©ãã¤ã³ã¯ãªã¡ã³ã¿ã«ã«åæããããããã©ã¼ãã³ã¹ã«ã¤ãã¦ãã£ã¨çºãããã§ãã¾ãã
75 ãã¼ã»ã³ã¿ã¤ã«ã§ LCP ã確èªããã
ãã£ã½ãã§å°ãèéã®å¹ããªãã¨ããããããç¹ã« LCP ã® 75 ãã¼ã»ã³ã¿ã¤ã«ã®å¤ãã³ã³ã½ã¼ã«ä¸ã§ç¢ºèªã§ããªããã¨ã¯åé¡ã§ããã
Core Web Vitals ããå¼ç¨ãã以ä¸ã®å³ã®ããã«ãLCP ã®è¯ãæªããå¤æãããããå¤ã¨ãã¦ä¸è¬çã« 75 ãã¼ã»ã³ã¿ã¤ã«ãç¨ããã¨ããã¨ããã¦ãã¾ããå¹³åå¤ã§ã¯ãã¼ã¿ã«åããããå ´åã«ææ¨ã¨ãã¦é©åã§ãªããªã£ã¦ãã¾ãå ´åãããããã§ãããã¡ããè¦ä»¶ã«ãã£ã¦ãã®æ¡ä»¶ãã«ã¹ã¿ãã¤ãºã§ãã¾ãããOne Experience ã«ããã¦ã¯åºæ¬ã® 75 ãã¼ã»ã³ã¿ã¤ã«ã§ 2.5 ç§ä»¥å ãåºæºã¨ãããã¨ã«æ±ºãã¦ããã®ã§ãå¹³åå¤ããè¦ãããªããã¨ã¯åé¡ã§ããã
ãã®ç¹ã«ã¤ãã¦ã¯ AWS ã«æ¢ã«è¦æãããã¦ãã¾ããããããèªåã§è§£æ±ºã§ããªããèãã¦ã¿ã¾ãããããããããã«ãã£ã³ã°ãããã¯ã®çµã¿åããã§ã¦ã¼ã¶ãã¨ã®è¦æ±ã«æè»ã«å¯¾å¿ã§ããã®ã AWS ã®å¼·ã¿ã§ãã
CloudWatch RUM ã§åéãããã¼ã¿ãå©ç¨ããããããã«éè¨ãã
ãã¦ãããã¾ã§ã®æµãã§ã³ã³ã½ã¼ã«ã«é ¼ããã« RUM ã®ãã¼ã¿ãç¬èªã«éè¨ãã¦åæãããã¨ããã¢ããã¼ã·ã§ã³ã«ã¤ãã¦èª¬æãã¾ããããã®ã»ã¯ã·ã§ã³ã§ã¯ããããå®éã«ã©ã®ããã«å®ç¾ããããèãã¦ã¿ã¾ãã
CloudWatch Logs Insights ãå©ç¨ãã
ã¯ããã«æãã¤ãã®ã CloudWatch Logs Insights ã§ããRUM ã®ãã¼ã¿ã¯ JSON æååã¨ã㦠CloudWatch Logs ã«ã¨ã¯ã¹ãã¼ãããã¦ããã®ã§èªç¶ã« Insights ãå©ç¨ã§ãã¾ããGrafana ããã¼ã¿ã½ã¼ã¹ã¨ã㦠CloudWatch Logs Insights ããµãã¼ããã¦ããã®ã§ããããå©ç¨ããã° Grafana ã§ããã·ã¥ãã¼ããä½ãããã§ãã
SQL ã«è¦ªããã§ãã身ã¨ãã¦æ§æã«ã¡ãã£ã¨ã¯ã»ãæãã¾ããããã¨ãã°ä»¥ä¸ã®ãããªã¯ã¨ãªã§ãæ¥æ¬ããã¢ãã¤ã«ããã¤ã¹ã§ã¬ã·ããã¼ã¸ã«ã¢ã¯ã»ã¹ããã¨ãã® LCP ã p75 ã§éè¨ãã¦æ±ãããã¨ãã§ãã¾ããæ¼ãå¨ã¨ãªã filter ããã¤ãã§ã¤ãªãã§ä¸ããã¬ã³ã¼ããæµãã¦ãããæå¾ã« stats ã§éè¨ããã¨ããã¤ã¡ã¼ã¸ã§ããã
filter event_type = "com.amazon.rum.largest_contentful_paint_event" | filter metadata.railsApp = "Global" | filter metadata.railsController = "recipes" | filter metadata.railsAction = "show" | filter metadata.countryCode = "JP" | filter (metadata.deviceType = "mobile" or metadata.deviceType = "tablet") | stats pct(event_details.value, 75)
ããã§ãã§ãããã§ãã... ã¨ã¯ããã¾ãããã¹ã¯ãªã¼ã³ã·ã§ããã®éè¨çµæã® 7.8 GB (!) ã¨ããå¤ã«æ³¨ç®ãã¦ãã ãããããã¯è¦ãã¾ã¾ã¹ãã£ã³éã§ãããã«æ¯ä¾ãã¦ééçã³ã¹ãã¨ã¯ã¨ãªå®è¡æéããããã¾ããä¸è¿°ã®ä¾ã§ã¯æéã1 æ¥ã«çµã£ã¦éè¨ãã¦ãã®ã¹ãã£ã³éã¨ãªã£ã¦ãããã¢ãããã¯ãªåæãªã大ããªåé¡ã«ãªãã¾ããããæéã伸ã°ããä¸ã§ Grafana ä¸ã«ãããããã¤ã³ãä½ã£ã¦è¡¨ç¤ºãããã¨ãããã ãããããã®ã¯ã¨ãªãçºè¡ããããã¨ã«ãªã£ã¦ãã¾ãã®ã§å®ç¨çã§ã¯ããã¾ããã§ããã
Timestream ãå©ç¨ãããµããªã¼ãã¼ãã«ã®ä½æ
ãã®ãããªã·ãã¥ã¨ã¼ã·ã§ã³ã¯ CloudWatch Logs Insights ã«éããä¸è¬çãªãã¼ã¿åæããããã§ãããã®ãããªå ´åãéè¨ãå®æå®è¡ãã¦å°ç¨ã®ãã¼ãã«ã«ä¿åãã¦ããã®ã常å¥æ段ã§ãã
ã§ã¯ã©ãã«éè¨çµæãä¿åããã®ãã¨ãããã¨ãåé¡ã¨ãªãã¾ãããããã§ã¯ Amazon Timestream for LiveAnalytics (ä»¥ä¸ Timestream ã¨è¡¨è¨ãã¾ã) ãæ¡ç¨ãã¾ãããTimestream 㯠AWS ã®ããã¼ã¸ããªæç³»åãã¼ã¿ãã¼ã¹ã§ããããã¼ã¦ã¼ã¹ã«èãããã¨ãç¹é·ã¨ãã¦ãã¾ãããã©ã¤ããªä½¿ãæ¹ã§ãã³ã¹ããé常ã«å°ãªãæ¸ã¿ãéã«ãã¼ã¿ãå ¥ãã¦ã¯ã¨ãªã§ãã便å©ã¹ãã¬ã¼ã¸ã§ãããã¨ãå人çã«ã¯é åã ã¨æãã¦ãã¾ããDynamoDB ãä¼¼ããããªç¨éã§ä½¿ãã¾ãããã·ã³ãã«ãª KVS ã§ã¯å¾®å¦ã«ãããã¨ããã«æãå±ããªãã¦ã¼ã¹ã±ã¼ã¹ãã«ãã¼ãã¦ããã¨ããã好ãã§ãã
ãã¦ã以ä¸ã« Timestream ããã³ Lambda ãç¨ããéè¨ã·ã¹ãã ã®æ¦è¦ã示ãã¾ãã
ç¢å°ã¯ã¤ãã³ããã¼ã¿ã®æµãã示ãã¦ãããCloudWatch RUM ããã¨ã¯ã¹ãã¼ããããçã®ã¤ãã³ããã¼ã¿ã CloudWatch Logs ã«éãããCloudWatch Logs Insights API ãå©ã Lambda function ã Timestream table ã«çµæãä¿åããéçºè ããã® Timestream table ã« Grafana ãéãã¦ã¯ã¨ãªããã¨ããå½¢ã«ãªã£ã¦ãã¾ãããã® Lambda function 㯠EventBridge ã«ãã£ã¦æ¥æ¬¡ã§å®è¡ãããããã«è¨å®ããã¦ãã¾ãã
ãã® Timestream ãã¼ãã«ã«å¯¾ãã¦ããã¨ãã°ä»¥ä¸ã®ãããªã¯ã¨ãªãå®è¡ããã¨ä»¥ä¸ã®ãããªçµæãè¿ã£ã¦ãã¾ããSQL 風ã«ã¯ã¨ãªã§ããã®ã§è³ã«ããããã§ãã
select * from cookpad_rum.global_web_lcp_jp where time between ago(7d) and now() order by time desc ;
d_ ãã¬ãã£ãã¯ã¹ããã¤ã«ã©ã ã dimension (ãã¼ã®ãããªãã®) ã¨ãã¦è¨å®ãã¦ãã¾ããããã§ã¯ããã¤ã¹ã»Rails ã¢ã¯ã·ã§ã³ã»Rails ã³ã³ããã¼ã©ã dimension ã«ããããã«å¯¾ã㦠LCP ãä¿åããã¨ããå½¢ã«ãªã£ã¦ãã¾ãã
å®éã« Grafana ããã·ã¥ãã¼ãã«è¨å®ããã¦ããã¯ã¨ãªã¯ä»¥ä¸ã®ãããªæãã«ãªã£ã¦ãã¾ãããã¼ã»ã³ã¿ã¤ã«ãããã¤ã¹ãããã·ã¥ãã¼ãã®ãã«ãã¦ã³ããå¤æ´ã§ããããã« Grafana ã®å¤æ°ãå©ç¨ãã¦ãããã¨ãããã®ã¾ã¾ã ã¨ã®ã¶ã®ã¶ãã¦åããã«ããå¾åããªãããã«è¦ãããããããã«ç§»åå¹³åãã¨ã£ã¦ããã¨ããããã½ã§ãã
select time , avg(lcp_p${statistics}_ms) over (order by time rows between 5 preceding and current row) as JP from cookpad_rum.global_web_lcp_jp where d_controller = 'recipe' and d_action = 'show' and d_device = '$device' ;
ããã¾ã§ã®ä½æ¥ã«ãã£ã¦ã以ä¸ã®ãããªæã㧠Grafana 㧠LCP ãå¯è¦åãããã¨ãã§ãã¾ãã2ãæ°´è²ã®ç·ã¯ One Experience ã® web çã®ç§»è¡ãå®å ¨ã«å®äºããæ¥ã§ãã
ã¡ãªã¿ã«æ¥æ¬çã®ã¬ã·ããã¼ã¸ã® LCP ã¯ããã 0.9s ã§ãæ¥æ¬ããã¢ã¯ã»ã¹ããã°ãã¼ãã«çã® LCP ã¯ããã 1.3s ã§ããå ããæªåãã¦ãããã¨ã¯å¦å®ã§ãã¾ãããã太平æ´ãã¾ãããã¨ã«ãã 150ms ã»ã©ã®ããã«ãã£ãããç¶æ ã§ãCore Web Vitals ã§åºæºã¨ããã¦ãã 2.5s ããã¯éãã§ãããã¾ãã¾ãæªããªãã¨è¨ã£ã¦å·®ãæ¯ããªãã®ã§ã¯ãªãã§ããããã
ãã®ããã«ãã¦ãTimestream ãå©ç¨ã㦠RUM ã§åéããçã®ãã¼ã¿ã Grafana ããå©ç¨ããããå½¢ã«å¤ãããã¨ã§ãCloudWatch Metrics ã Prometheus ãéãã¦ã¯ã¨ãªã§ããä»ã®ã·ã¹ãã ã¡ããªã¯ã¹ã¨ãããã¦å®ä¾¡ãã¤é«éã«è¡¨ç¤ºã§ããããã«ãªãã¾ãããã¾ããGrafana ã®ä»ã«ã QuickSight ãªã©ã® BI ãã¼ã«ã¨é£æºãããã¨ãã§ããRedshift ã Athena ãéãã¦ã¯ã¨ãªã§ããå¤æ§ãªãã¼ã¿ã½ã¼ã¹ã¨çµã¿åããããªã©å¿ç¨ã®å¹ ãåºããã¾ãã
å®éã«ç§»è¡ããåã«æ¥æ¬ããã¢ã¯ã»ã¹ããå ´åã®ããã©ã¼ãã³ã¹ã«ã¤ãã¦ç¥ããã
ãã¦ãããã¾ã§ã®è©±ã§ãCloudWatch ã§åéãã RUM ãã¼ã¿ã®åæãã§ããããã«ãªãã¾ãããããã RUM ã«ããã¦ã¯ãå®éã«ã¦ã¼ã¶ã« RUM ã¯ã©ã¤ã¢ã³ããéãã¦ãã¼ã¿ãéã£ã¦ãããå¿ è¦ãããã¾ããããªãã¡ãå®éã«ãªãªã¼ã¹ããã¾ã§ãã¼ã¿ãã¨ããªããã¨ãããã¨ã§ãã
ãã®ãããªåé¡ããããããä¸è¬çã« RUM 㨠synthetic monitoring ã®ä¸¡æ¹ã使ãåããã¨ããã¨ããã¦ãã¾ããsynthetic monitoring ã¯ãµã¼ãä¸ã®ãããã¬ã¹ãã©ã¦ã¶ãã人工çãªãªã¯ã¨ã¹ããçºçãããRUM ã®ããã«ã¡ããªã¯ã¹ãåéãã¦ããã©ã¼ãã³ã¹æ¹åã«å½¹ç«ã¦ããã¼ã«ã§ãããã¼ã«ã«ããæ©è½ã®å·®ç°ãããã¾ãããããã©ã¼ãã³ã¹ã®æ°å¤ãæç»æã®åç»ãåç·ç¶æ³ã®ã·ãã¥ã¬ã¼ã·ã§ã³ (å ã±ã¼ãã«ãã¢ãã¤ã«åç·ãªã©)ãããã©ã¼ãã³ã¹æ¹åã®ããã®ãã³ããªã©ãæä¾ãããã®ãä¸è¬çã§ãã
One Experience ã§ã¯ãRUM 㨠synthetic monitoring ãçµã¿åããã¦ã以ä¸ã®ããã«ãã¦ãªãªã¼ã¹åãã観測ãè¡ã£ã¦ãã¾ããã
- ã°ãã¼ãã«çã«å°æ¹¾ããã¢ã¯ã»ã¹ããã¨ãã® RUM ãã¼ã¿ãæ´»ç¨ãã
- synthetic monitoring ã¨ã㦠Calibre ãæ¡ç¨ãã¦ãã¹ããè¨å®ãã
ã°ãã¼ãã«ç㯠One Experience 以åããå¤ãã®å½ã¨å°åã«åãã¦ãµã¼ãã¹ãå±éãã¦ãããå°æ¹¾ããã®ä¸ã®ä¸ã¤ã§ããå°æ¹¾ã«ã¯æ¥æ¬ã¨ä¼¼ãæ¯è¼çé«éãªãããã¯ã¼ã¯ç°å¢ããããå°ççã«ãè¿ãå ´æã«ããã¾ãããã®ãããå°æ¹¾ããéããã¦ãã RUM ã®ãã¼ã¿ã¯ãã³ããã¼ã¯ã¨ãã¦å©ç¨ããããã¨èãã¾ããã
å°æ¹¾ã® RUM ãã¼ã¿ã ãã§ã¯ä¸ååãªã¨ãããè£ããããå è¿°ã® Calibre ãå°å ¥ãã¦ã°ãã¼ãã«çã®æ¥æ¬åããã¼ã¸ (https://cookpad.com/jp) ã«å¯¾ãã¦ãã¢ã¯ã»ã¹å ã®ãã±ã¼ã·ã§ã³ãæ¥æ¬ã«è¨å®ãã¦ãã¹ããè¨å®ãã¾ãããæ¬ç¨¿ã®è¶£æ¨ããå¤ãããã詳細ãªèª¬æã¯å²æãã¾ãããæ¯è¼çå®ä¾¡ã§æ¢ã«å©ç¨å®ç¸¾ããã£ããã¨ã¨ãæã ã«ã¨ã£ã¦å¿ è¦ååãªæ©è½ãæãã¦ããã®ã Calibre ãæ¡ç¨ããçç±ã§ãã
Synthetic monitoring ã«ãã決ã¾ã£ããã¼ã¸ã¸ã®äººå·¥çãªãªã¯ã¨ã¹ãã§ã¯ãã©ããã¦ãåç·ç¶æ³ãå«ããå®éã®ã¦ã¼ã¶ã®ç¶æ³ã¨ä¹é¢ãã¦ãã¾ãé¨åã¯ããã¾ãããããã¾ããªå¾åã¯æ´ãã¾ããã©ãã«æ¹åããä½å°ãããã®ãã調æ»ããå©ãã«ãªãã¾ãããCalibre ãã¯ããã¨ãã synthetic monitoring ãã¼ã«ã«å®è£ ããã¦ãããæ¹åç¹ãã¢ããã¤ã¹ãã¦ãããæ©è½ãæ´»ç¨ãã¾ããã
å®æãã¹ãå®äºæã« webhook ãä»ãã¦å¤é¨ã«éç¥ããæ©è½ã Calibre ã«ã¯ããã®ã§ããããã®éç¥ãåã㦠Timestream ã«ãã¼ã¿ãæ ¼ç´ããGrafana ã§å¯è¦åããä»çµã¿ãä½ãã¾ãããããã¯ãã㧠Lambda ã® Function URL ãæ´»ç¨ãã¦ããããFunction URL ã®å¼±ç¹ãè£ãã¡ãã£ã¨ããèªè¨¼ã®ä»çµã¿ãå ¥ãã¦ã¿ãããTimestream ãæ´»ç¨ããããªã©å人çã«é¢ç½ãã¨æã£ã¦ããè¦ç´ ãè©°ã¾ã£ãä»çµã¿ãªã®ã§ãããè¨äºãã©ãã©ã大ãããªãã®ã§ããã§ã¯å²æãã¾ããã¨ãããã以ä¸ã®ã¹ã¯ãªã¼ã³ã·ã§ããã®ãããªæã㧠synthetic monitoring ã®ã¡ããªã¯ã¹ã Grafana ã«åºããããã«ãªãã¾ããã
ã¾ã¨ã
æ¬ç¨¿ã§ã¯ãOne Experience ã«ãããããã©ã¼ãã³ã¹é¢é£ã®åãçµã¿ã®ãã¡ãã¦ã¼ã¶ããä¸çªè¿ãå ´æã§ã®ããã©ã¼ãã³ã¹æ å ±ãåéãã¦å¯è¦åãããã¨ã«ãã©ã¼ã«ã¹ãã¦èª¬æãã¾ããã
ãããã®ä»çµã¿ãæ´ããä¸ã§ãä»ã®ã·ã¹ãã ã¡ããªã¯ã¹ãæä½æ¥ã§è¡ããã¹ãã«ããå®æ§çãªåé¡ã®èª¿æ»ããã³ãããã©ã¼ãã³ã¹ã®è¦³æ¸¬çµæãçµã¿åããã¦ããã©ã¼ãã³ã¹ãæ¹åãã¦ãã¾ãããä¸éã One Experience ããªãªã¼ã¹ãããç¾å¨ããã¯ãã¯ããããå¿«é©ã«ä½¿ã£ã¦ãããããã®ããã©ã¼ãã³ã¹æ¹åã®åãçµã¿ã¯ç¶ãã¦ãã¾ãã
- æ¥æ¬ããã¢ã¯ã»ã¹ããå ´åãæ±äº¬ã§ 5msãç±³å½è¥¿é¨ã§ 100msãç±³å½æ±é¨ã§ 150ms ãããããã® RTT ã®ç®å®ã¨ããã¦ãã¾ã↩
- One Experience ãªãªã¼ã¹åã®ãµã³ãã«æ°ãå°ãªããã¡ãããã®ä»çµã¿ãå ¥ãã¦ããããã7 æä¸æ¬ãããã®æ°å¤ãã¨ãã§ããªããã¨ã«ãªã£ã¦ãã¾ã£ã¦ãã¾ãã...ã↩