Mackerel ã§éã®è²·åç¸å ´ãç£è¦ãã
å»å¹´æ«ã社å¡æ è¡ã§ã®æ½é¸ä¼ã§ç´éãå½ãã£ãã
社å¡æ è¡ã®æ½é¸ä¼ã§ç´éå½ãã£ãâ¦
— è°·å£ (@ravelll) 2016å¹´12æ27æ¥
ãããéã§ãã https://t.co/mivJigz8LO
— è°·å£ (@ravelll) 2016å¹´12æ28æ¥
ã¾ã ãã°ãã売ãæ°ã¯ãªãã®ã ãã©ãã²ã¨ã¾ãéç¸å ´ãè¦ãããã¨ãããã¨ã§ Mackerel ã§ç£è¦ãããã¨ã«ããã
稼åç°å¢ã¯ Amazon EC2ï¼Amazon Linuxï¼ã§ãã
æé
ã¾ã㯠mackerel-agent ãã¤ã³ã¹ãã¼ã«ãAPIKEY ã¯åèªã®ãã®ã«èªã¿æãã¦ãã ããã
$ curl -fsSL https://mackerel.io/file/script/amznlinux/setup-all-yum.sh | MACKEREL_APIKEY='yourmackerelapikey' sh
次ã«ç£è¦ãããã©ã¡ã¼ã¿ãåå¾ã»è¨å®ããã¹ã¯ãªãããè¨ç½®ã
#!/bin/bash name="GoldPrice" monitor_time=`date +%s` market_rate=`curl http://gold.mmc.co.jp/market/gold-price/ | grep -A1 metalType1 | tail -1 | tr -d "\t" | tr -d "," | cut -b 4-7` echo -e "${name}\t${market_rate}\t${monitor_time}"
è¨ç½®ããã¹ã¯ãªããã使ãã¡ããªãã¯ãä½æãããã mackerel-agent.conf ãä¿®æ£ã
$ sudo vim /etc/mackerel-agent/mackerel-agent.conf [plugin.metrics.process] command="bash /path/to/script.sh" type="metric"
ããã§ã«ã¹ã¿ã ã¡ããªãã¯ã¨ãã¦éç¸å ´ã®ã°ã©ãã表示ããã¾ãã
ã©ãã«ã¯ã°ã©ãå³ä¸ã®è¨å®ãã¼ã¸ã§å¤æ´ã§ãã¾ããä»åã¯ã¹ãã¬ã¼ãã«ãéç¸å ´ãã¨ãã¾ããã
ããããã§ãã
ã°ã©ãã表示ãããªãã¨ã㯠/var/log/mackerel-agent.log ãè¦ãã¨åå ãç¹å®ã§ããã¨æãã¾ãã
ä»å¾
éç¸å ´ã®æ å ±ãåå¾ãã¦ãããã¼ã¸ã®æ´æ°ãæ¥ã«1åã®ããã ããä¸å¿ è¦ã«é«é »åº¦ãªã¹ã¯ã¬ã¤ãã³ã°ã¯è¡åãæªãã®ã§ã¨ã¼ã¸ã§ã³ãã®ãã§ããééãåºãããã
ä»ã¯1åæ¯ã«ã¡ããªãã¯ã« Post ããã¦ãããã²ãããå¹³å¦ãªã°ã©ããç¶ãã¦ãã¦æ å ±ä¾¡å¤ãä½ããç¸å ´ãä¸ä¸ããçµéãè¦ããã®ã ã
plugin.metrics.* ã®å®è¡ééã¯è¨å®ã§ããã®ããªã¨ mackerel-agent ã®ã³ã¼ããèªãã ã®ã ãã©ãconfig/config.go#L214 ã®å¤æ°ã toml ããã®å ¥åã§å¤æ´ããç®æã¯ç¡ãããã«è¦ããã®ã§ã§ããªãâ¦ï¼
plugin.checks.* ã§ã® check_interval ã execution_interval ã®ãããªãã©ã¡ã¼ã¿ãããã®ããªã¨æã£ãã®ã ãã©ç¡ãã®ããªãä¼ç¤¾ã®æèè ã®æ¹ã ã«èãã¦ã¿ããã
追è¨
ã¯ã¦ãªç¤¾ã®ã»ã¼ã«ã¹ã¨ã³ã¸ãã¢ã§ãã id:a-know ããããããµã¼ãã¹ã¡ããªãã¯ã«ããã¨ããã¨ã®ã¢ããã¤ã¹ãããã ãã¾ããããããã¨ããããã¾ãï¼ï¼
@ravelll @buty4649 ãããããæ稿ããããã¨ããããã¾ãã£ð
— ããã®ã¼ (@a_know) 2017å¹´2æ14æ¥
ã«ã¹ã¿ã ã¡ããªãã¯ã®ãããªãã¹ãã«ç´ä»ãã¡ããªãã¯ã¯æ¯åæ稿ãåæã®ããããããã£ãç¨éã®å ´åã¯ããµã¼ãã¹ã¡ããªãã¯ãã¨ãã¦ã®æ稿ããããã¨æãã¾ãï¼https://t.co/i9CJP9m10A