以åã®åºçç©ã§ã¯ãã¡ããªãã¯ã®ç£èŠãšåéã®åé¡ã«æ¢ã«åãçµãã§ããŸãã ä»æ¥ã®èšäºã§ã¯ããã®ãããã¯ã«æ»ãã ããã¡ããŠã¹ãšåŒã°ããèå³æ·±ãããŒã«ã«ã€ããŠã話ããããšæããŸãã 2012幎ã«æªåé«ãSoundCloudãããžã§ã¯ãã®å éšç£èŠã·ã¹ãã ãšããŠäœæãããŸãããããã®åŸããã«æ®åããŸããã
Prometheusã¯å®å šã«æ°ããããŒã«ã§ããïŒæåã®å ¬éãªãªãŒã¹ã¯2015幎ã®åãã«è¡ãããŸããïŒããã·ã¢èªã§ã¯ã»ãšãã©å ¬éãããŠããŸããïŒæ°ãæåã«Hackerèªã«èšäºãæ²èŒãããŸãããã賌èªè ã®ã¿ãå©çšã§ããŸãïŒã
SoundCloudéçºè ã¯ããã€ã¯ããµãŒãã¹ã¢ãŒããã¯ãã£ãžã®ç§»è¡ã«é¢é£ããŠæ°ããç£èŠããŒã«ãå¿ èŠã§ãã£ãããšã«æ³šæããŠãã ããïŒãã¡ãã®è©³çŽ°ã¬ããŒããåç § ïŒã ãã€ã¯ããµãŒãã¹ãžã®é¢å¿ã®é«ãŸãã¯ãããæ°å¹Žã®ç¹åŸŽçãªåŸåã®1ã€ã§ãã
ãã€ã¯ããµãŒãã¹ã¢ãããŒãã®èŠ³ç¹ããèŠããšãã¢ããªã±ãŒã·ã§ã³ã¯ã¢ããªã¹ãšããŠã§ã¯ãªãããµãŒãã¹ã®ã»ãããšããŠç解ãããŸãã ãããã®åãµãŒãã¹ã¯ç¬èªã®ããã»ã¹ã§åäœããåçŽãªã¡ã«ããºã ïŒéåžžã¯HTTPãããã³ã«ã䜿çšïŒã䜿çšããŠç°å¢ãšå¯Ÿè©±ããŸãã
ãã€ã¯ããµãŒãã¹ã®ç£èŠã¯ç°¡åãªäœæ¥ã§ã¯ãããŸããããªã¢ã«ã¿ã€ã ã§ãåã ã®ã³ã³ããŒãã³ãã®ç¶æ ãšã·ã¹ãã å šäœã®ç¶æ ã®äž¡æ¹ãç£èŠããå¿ èŠããããŸãã æè¡çãªãã®ã«å ããŠãããžãã¹é¢é£ã®ã€ã³ãžã±ãŒã¿ã確èªããå¿ èŠãããå Žåãã¿ã¹ã¯ã¯è€éã§ãã ããã¡ããŠã¹ã®éçºè èªèº«ãå€æ°ã®èšäºãã¬ããŒãã§ææããŠããããã«ãæ¢åã®ç£èŠã·ã¹ãã ã䜿çšããŠããã解決ããããšã«ã¯åé¡ããããŸãã ãããã£ãŠã圌ãã¯ç¬èªã®ããŒã«ãäœæããŸããã
Prometheusã¯ãç£èŠãã¬ãŒã ã¯ãŒã¯ãšç¬èªã®äžæããŒã¿ããŒã¹ã®äž¡æ¹ãå«ãå®å šãªãœãªã¥ãŒã·ã§ã³ã§ãã äžéšã®ã¬ãã¥ãŒã§ã¯ãã æ°äžä»£ç£èŠã·ã¹ãã ããšãåŒã°ããŠããŸãã
ç§ãã¡ã¯ããã¡ããŠã¹ã«é¢ããåºçç©ã«èå³ãããããã®ããŒã«ãããããç¥ãããšã«ããŸããã
ããã¡ããŠã¹ã¢ãŒããã¯ãã£
次ã®ã³ã³ããŒãã³ãã¯ãPrometheusã®äžéšã§ãã
- ã¡ããªãã¯ãèªã¿åããããããæç³»åããŒã¿ããŒã¹ã«ä¿åãããµãŒããŒã
- ããŸããŸãªããã°ã©ãã³ã°èšèªã®ã¯ã©ã€ã¢ã³ãã©ã€ãã©ãªïŒGoãJavaãPythonãRubyãã³ãã¥ããã£ã¯BashãNode.jsãHaskellã.NET / CïŒã®ã©ã€ãã©ãªãäœæããŸããïŒã
- Pushgateway-çæããã»ã¹ã®ã¡ããªãã¯ãåä¿¡ããããã®ã³ã³ããŒãã³ãã
- PROMDASH-ã¡ããªãã¯ã®ããã·ã¥ããŒãã
- ãµãŒãããŒãã£ã®ã¢ããªã±ãŒã·ã§ã³ïŒStatsdãGangliaãHAProxyãªã©ïŒããããŒã¿ããšã¯ã¹ããŒãããããã®ããŒã«ã
- AlertManageréç¥ãããŒãžã£ãŒïŒçŸåšããŒã¿ãã¹ãäžïŒã
- ããŒã¿ãç §äŒããããã®ã³ãã³ãã©ã€ã³ã¯ã©ã€ã¢ã³ã ã
ãããã®ã»ãšãã©ã¯Goã§æžãããŠãããéåžžã«å°ããªéšåã¯RubyãšJavaã§æžãããŠããŸãã
ãã¹ãŠã®Prometheusã³ã³ããŒãã³ãã¯ãHTTPãä»ããŠçžäºã«éä¿¡ããŸãã
ã·ã¹ãã å šäœã®äž»èŠã³ã³ããŒãã³ãã¯ãPrometheusãµãŒããŒã§ãã èªåŸçã«åäœãããã¹ãŠã®ããŒã¿ãããŒã«ã«ããŒã¿ããŒã¹ã«ä¿åããŸãã ãµãŒãã¹ã®æ€åºã¯èªåçã«è¡ãããŸãã ããã«ãããå±éæé ãç°¡çŽ åãããŸããåäžã®ãµãŒãã¹ãç£èŠããããã«ãåæ£ç£èŠã·ã¹ãã ãå±éããå¿ èŠã¯ãããŸããã ãµãŒããŒãšã¡ããªãã¯ã®åéãšãšã¯ã¹ããŒãã«å¿ èŠãªã³ã³ããŒãã³ããã€ã³ã¹ããŒã«ããã ãã§ãã HaproxyãMySQLãPostrgreSQLãªã©ãç¹å®ã®ãµãŒãã¹åãã«ã調æŽãããããã®ãããªã³ã³ããŒãã³ããæ¢ã«å€æ°ãããŸãïŒ GitHubã®ã»ãã ãã¡ãã®å šãªã¹ããã芧ãã ããïŒã
ããã¡ããŠã¹ã¡ããªãã¯ã¯ããã«ã¡ã«ããºã ã䜿çšããŠåéãããŸãã ããã·ã¥ã¡ã«ããºã ã䜿çšããŠã¡ããªãã¯ãåéããããšãã§ããŸãïŒãã®ããã« ãåå¥ã«ã€ã³ã¹ããŒã«ãããç¹å¥ãªããã·ã¥ã²ãŒããŠã§ã€ã³ã³ããŒãã³ãã䜿çšãããŸãïŒã ããã¯ãäœããã®çç±ã§ãã«ã䜿çšããŠã¡ããªãã¯ãåéã§ããªãå Žåã«å¿ èŠã«ãªãå ŽåããããŸããããšãã°ããã¡ã€ã¢ãŠã©ãŒã«ã§ä¿è·ããããµãŒãã¹ãç£èŠããå Žåã§ãã ãŸããããã·ã¥ã¡ã«ããºã ã¯ããããã¯ãŒã¯ã«å®æçã«çæéæ¥ç¶ãããµãŒãã¹ãç£èŠããå Žåã«åœ¹ç«ã¡ãŸãã
Prometheusã¯ãæç³»åãšããŠè¡šç€ºãããããŒã¿ã®åéãšåæã«é©ããŠããŸãã ãã¹ãŠã®ã¡ããªãã¯ãç¬èªã®äžæããŒã¿ããŒã¹ã«ä¿åããŸãïŒOpenTSDBããã³InfluxDBãšã®æ¯èŒã¯ãã¡ããåç §ããŠãã ãã ïŒã IndexDã¯LevelDBã䜿çšããŸãã
ããŒã¿ã¢ãã«
ããã¡ããŠã¹ã¯ããŒã¿ãæç³»åã®åœ¢åŒã§ä¿åããŸã-ã¿ã€ã ã¹ã¿ã³ãã«é¢é£ä»ããããå€ã®ã»ããã
æç³»åã®èŠçŽ ïŒãã£ã¡ã³ã·ã§ã³ïŒã¯ãã¡ããªãã¯ã®ååãã¿ã€ã ã¹ã¿ã³ããããã³ããŒãšå€ã®ãã¢ã§æ§æãããŸãã ã¿ã€ã ã¹ã¿ã³ãã¯ããªç§åäœã®ç²ŸåºŠã§ãå€ã¯64ãããã®ç²ŸåºŠã§è¡šç€ºãããŸãã
ã¡ããªãã¯åã¯ãããŒã¿ãåéãããŠããã·ã¹ãã ãã©ã¡ãŒã¿ã瀺ããŸãã ããšãã°ãç¹å®ã®APIãžã®HTTPãªã¯ãšã¹ãã®æ°ã«é¢ããæ å ±ãå«ãã¡ããªãã¯ã§ã¯ãååã¯api_http_requests_totalã®ããã«ãªããŸãã ãã®ã¡ããªãã¯ã®æç³»åã¯ãã³ãŒã200ã®å¿çãè¿ãããã¢ãã¬ã¹/ API /ãã©ãã¯ãžã®ãã¹ãŠã®GETãªã¯ãšã¹ãã«é¢ããæ å ±ãä¿åã§ããŸãããã®æç³»åã¯ã次ã®è¡šèšã®åœ¢åŒã§è¡šãããšãã§ããŸãã
api_http_requests_total{method="GET", endpoint="/api/tracks", status="200"}
Prometheusã䜿çšããããŒã¿ã¢ãã«ã¯ãOpenTSDBã䜿çšããããŒã¿ã¢ãã«ã«äŒŒãŠããŸãã ãã¹ãŠã®ã¡ããªãã¯ã«ã¯ååããããŸãããè€æ°ã®è¡ã§åãã«ãªãå ŽåããããŸãã
ããã«ãåæç³»åã«ã¯å°ãªããšã1ã€ã®ã¿ã°ãä»ããå¿ èŠããããŸãã 1ã€ã®ã¿ã°ã®æž¬å®å€ã¯é£ç¶ããŠä¿åããããããé«éã®ããŒã¿éçŽãä¿èšŒãããŸãã
次ã®ã¿ã€ãã®ã¡ããªãã¯ããµããŒããããŠããŸãã
- ã«ãŠã³ã¿ãŒ ïŒã«ãŠã³ã¿ãŒïŒ-æéãšãšãã«å¢å ããå€ïŒããšãã°ããµãŒããŒãžã®èŠæ±ã®æ°ïŒãæ ŒçŽããŸãã
- ã¹ã±ãŒã« ïŒã²ãŒãžïŒ-æéãšãšãã«å¢å ããã³æžå°ããå¯èœæ§ã®ããå€ïŒããšãã°ã䜿çšãããRAMã®éãI / Oæäœã®æ°ïŒãä¿åããŸãã
- ãã¹ãã°ã©ã ïŒãã¹ãã°ã©ã ïŒ-äžå®æéã«ããããã©ã¡ãŒã¿ãŒã®å€æŽã«é¢ããæ å ±ãä¿åããŸãïŒããšãã°ã11æéãã12æéãŸã§ã®ãµãŒããŒãžã®ãªã¯ãšã¹ãã®åèšæ°ãš11.30ãã11.40ãŸã§ã®åããµãŒããŒãžã®ãªã¯ãšã¹ãæ°ïŒã
- çµæã®èŠçŽïŒèŠçŽïŒ-ãã¹ãã°ã©ã ã®ããã«ãæéééã«ããããã©ã¡ãŒã¿ãŒã®å€ã®å€åã«é¢ããæ å ±ãä¿ç®¡ããŸããã移åæéééã®å€äœå€ãèšç®ããããšãã§ããŸãã
èšçœ®
次ã«ãPrometheusã䜿çšããå®éçãªåŽé¢ãèŠãŠã¿ãŸãããã ã€ã³ã¹ããŒã«æé ã®èª¬æããå§ããŸãããã
æè¿ã§ã¯ãPrometheusã¯å ¬åŒã®Debian 8ããã³Ubuntu 15.10ãªããžããªã«å«ãŸããŠããŸãã
Ubuntu 14.04ã§ã¯ãæšæºããã±ãŒãžãããŒãžã£ãŒã䜿çšããŠã€ã³ã¹ããŒã«ããããšãã§ããŸãã åœç¶ãããã«ã¯é©åãªãªããžããªãæ¥ç¶ããå¿ èŠããããŸãã
$ echo 'deb http://deb.robustperception.io/ precise nightly' > /etc/apt/sources.list $ wget https://s3-eu-west-1.amazonaws.com/deb.robustperception.io/41EFC99D.gpg $ sudo apt-key add 41EFC99D.gpg $ sudo apt-get update $ sudo apt-get install prometheus node-exporter alertmanager
äžèšã®ã³ãã³ãã䜿çšããŠãPrometheusãµãŒããŒãšãè¿œå ã®ã³ã³ããŒãã³ãnode_exporterããã³alertmanagerãã€ã³ã¹ããŒã«ããŸããã Node_exporterã¯ãµãŒããŒã¹ããŒã¿ã¹ããŒã¿ãåéããæå®ãããæ¡ä»¶ãæºããããŠãããæºããããŠããªãå Žåã«ã¢ã©ãŒããããŒãžã£ãŒïŒè©³çŽ°ã«ã€ããŠã¯åŸè¿°ããŸãïŒãéä¿¡ããŸãã
ã€ã³ã¹ããŒã«ã¯å®äºããŸãããããã1ã€å°ããªã¿ããããããŸããnode_exporterãããã¯ã°ã©ãŠã³ãã§ã¡ããªãã¯ãåžžã«åéããããã«ããå¿ èŠããããŸãã ãããè¡ãã«ã¯ããŸã/ usr / binã«ã·ã³ããªãã¯ãªã³ã¯ãäœæããŸãã
$ sudo ln -s ~/Prometheus/node_exporter/node_exporter /usr/bin
次ã«ããã¡ã€ã«/etc/init/node_exporter.confãäœæãã次ã®è¡ãè¿œå ããŸãã
# Run node_exporter start on startup script /usr/bin/node_exporter end script
å€æŽãä¿åããŠãã³ãã³ããå®è¡ããŸãã
$ sudo service node_exporter start
systemdã«åãæ¿ãããã£ã¹ããªãã¥ãŒã·ã§ã³ïŒUbuntu 15.10ãªã©ïŒã§ãnode_exporterãããã¯ã°ã©ãŠã³ãã§å®è¡ããã«ã¯ã/ etc / systemd / system / node_exporter.serviceãã¡ã€ã«ãäœæãã次ã®è¡ãè¿œå ããå¿ èŠããããŸãã
[Unit] Description=Node Exporter [Service] ExecStart=/usr/sbin/node_exporter Restart=Always [Install] WantedBy=default.target
å€æŽãä¿åããããã³ãã³ããå®è¡ããå¿ èŠããããŸãã
$ sudo systemctl enable node_exporter.service $ sudo systemctl start node_exporter
æ§æ
ããã©ã«ãã®Prometheusèšå®ã¯ãããŒã«ã«ãã·ã³ã§çºçãããã¹ãŠã远跡ããã®ã«ååã§ãã å¿ èŠã«å¿ããŠãèšå®ãã¡ã€ã«/etc/prometheus/prometheus.ymlã§è¿œå ã®èšå®ãåžžã«æå®ã§ããŸãã ãã®æ§é ããã詳现ã«æ€èšããŠãã ããã ããã¯ã°ããŒãã«ã»ã¯ã·ã§ã³ããå§ãŸããŸãïŒ
global: scrape_interval: 15s evaluation_interval: 15s rule_files:
次ã®ãªãã·ã§ã³ãå«ãŸããŸãã
- scrape_interval-ã¡ããªãã¯åéééïŒããã©ã«ãã¯15ç§ïŒ;
- evaluation_interval-ã«ãŒã«ãšã®èª¿æŽã®ééïŒããã©ã«ãã§ã¯15ç§ïŒã
- rule_files-ã«ãŒã«ãã¡ã€ã«ïŒãããã«ã€ããŠã¯åŸè¿°ããŸãïŒã
以äžã¯ããµãŒããŒäžã®ã¡ããªãã¯ãåéããããã®åºæ¬èšå®ãå«ãscrape_configsã»ã¯ã·ã§ã³ã§ãã
scrape_configs: - job_name: "prometheus" - scrape_interval: "15s" target_groups: - targets: - "localhost:9090"
以äžã®å¿ é ãã©ã¡ãŒã¿ãŒãå«ãŸããŸãã
- job_name-ã¿ã¹ã¯åã
- scrape_interval-ã¡ããªãã¯åéééïŒãã®äŸã§ã¯ã15ç§ããšïŒã
- target_groups-ã¡ããªãã¯ãåéããå¿ èŠããããµãŒãã¹ããã³ãµãŒãã¹ã®ã°ã«ãŒãã
åãã»ã¯ã·ã§ã³ã§ãè¿œå ã®èšå®ãæå®ã§ããŸãã
- scrape_timeout-ããŒã¿ã®ã¿ã€ã ã¢ãŠãã
- metrics_path-ã¡ããªãã¯ãéä¿¡ãããHTTPãªãœãŒã¹ã
- ã¹ããŒã -ã¡ããªãã¯ã®éä¿¡ã«äœ¿çšããããããã³ã«ã
- basic_auth-ã¡ããªãã¯ãåéããããµãŒããŒã§ã®æ¿èªã®è©³çŽ°ïŒãŠãŒã¶ãŒåïŒããã¹ã¯ãŒã:)ã
æ§æãã¡ã€ã«ã§ã«ãŒã«ãã¡ã€ã«ãåç §ã§ããããšã¯æ¢ã«è¿°ã¹ãŸããã ã«ãŒã«ã¯ãæãé »ç¹ã«äœ¿çšãããããŸãã¯ãªãœãŒã¹ãéäžçã«äœ¿çšãããã©ã¡ãŒã¿ãŒãäºåã«èšç®ããæ°ããæç³»åãšããŠä¿åããã®ã«åœ¹ç«ã¡ãŸãã äºåã«èšç®ããããã©ã¡ãŒã¿ãŒã«ããæ€çŽ¢ã¯ãåãªã¯ãšã¹ãã§å€ãåèšç®ãããããã¯ããã«ç°¡åã§ãã ããã¯ãããšãã°ãæŽæ°ããšã«ãã©ã¡ãŒã¿ãŒå€ãèŠæ±ããããã·ã¥ããŒãã䜿çšããå Žåã«åœ¹ç«ã¡ãŸãã
äžè¬çã«ãã«ãŒã«ã®æ§æã¯æ¬¡ã®ããã«è¡šãããšãã§ããŸãã
< >{} = < >
ããå ·äœçã§ç解ããããäŸã次ã«ç€ºããŸãã
job:http_inprogress_requests:sum = sum(http_inprogress_requests) by (job) new_time_series{label_to_change="new_value",label_to_drop=""} = old_time_series
Prometheusã¯ãèšå®ãã¡ã€ã«ã®evaluation_intervalãã©ã¡ãŒã¿ãŒã§æå®ãããç¹å®ã®é »åºŠã§ã«ãŒã«ããã§ãã¯ããŸãïŒã å調æŽã®åŸãPrometheusã¯ãã©ã¡ãŒã¿ãŒå€ãåã«ãŠã³ãããçŸåšã®ã¿ã€ã ã¹ã¿ã³ããæã€æ°ããååã§ä¿åããŸãã
ãã®ãããæ§æãã¡ã€ã«ã®æ§é ãšæ§æãäžè¬çãªçšèªã§èª¿ã¹ãŸããã èŠå®ã®èšå®ãæå¹ã«ããã«ã¯ã次ã®ã³ãã³ããå®è¡ããå¿ èŠããããŸãïŒãã¹/ / / prometheus.ymlã®ä»£ããã«ãæ§æãã¡ã€ã«ãžã®ãã¹ãæå®ããŸãïŒã
$ prometheus -config.file âpath/to/prometheus.ymlâ
Webã€ã³ã¿ãŒãã§ãŒã¹
Prometheus Webã€ã³ã¿ãŒãã§ãŒã¹ã¯ããã©ãŠã¶ã®httpïŒ// [ãµãŒããŒIP]ïŒ9090ïŒã§å©çšã§ããŸãã
[åŒ]ãã£ãŒã«ãã§ãã°ã©ãã衚瀺ããã¡ããªãã¯ãéžæã§ããŸãã ããšãã°ããµãŒããŒäžã®ã¢ã¯ãã£ããªã¡ã¢ãªã®éã远跡ããŠã¿ãŸãããã ã¡ããªãã¯node_memory_activeãéžæãããå®è¡ããã¿ã³ãã¯ãªãã¯ããŸãã
ãã£ãŒãã®äžã«ã¯ãçµ±èšã衚瀺ããæéãéžæã§ãããã¿ã³ããããŸãã
ã³ã³ãœãŒã«ãã³ãã¬ãŒã
確èªããã¡ã€ã³ã®Prometheusã³ã³ãœãŒã«ã ããå°éçãªãã£ãŒãã衚瀺ããã«ã¯ãã«ã¹ã¿ã ã³ã³ãœãŒã«ã䜿çšããŸãã
ãµãŒããŒã§ã¯ã/ etc / prometheus / consolesãã£ã¬ã¯ããªã«ä¿åãããŸãã ã«ã¹ã¿ã ã³ã³ãœãŒã«ã«ã¯ãäžè¬çãªãµãŒããŒçµ±èšïŒnode.htmlïŒãCPUçµ±èšïŒnode-cpu.htmlïŒããµãŒããŒI / Oçµ±èšïŒcpu-disk.htmlïŒãªã©ã衚瀺ãããŸãã ãã©ãŠã¶ã§ã¯ãhttpïŒ// [ãµãŒããŒIP]ïŒ9090 / consoles / <ã³ã³ãœãŒã«å> .htmlã§å©çšã§ããŸãã
ããã§ãããšãã°ãnode.htmlã³ã³ãœãŒã«ã¯æ¬¡ã®ããã«ãªããŸãã
䜿çšå¯èœãªã³ã³ãœãŒã«ãã©ããèªåã«åããªãå Žåã¯ãå¿ èŠãªçµ±èšã衚瀺ããç¬èªã®ã³ã³ãœãŒã«ãäœæã§ããŸãã Prometheusã¯Go HTMLãã³ãã¬ãŒããšã³ãžã³ã䜿çšããŠã³ã³ãœãŒã«ãèšè¿°ããŸãã ã«ã¹ã¿ã ã³ã³ãœãŒã«ãäœæããããã®è©³çŽ°ãªæé ã¯ãå ¬åŒããã¥ã¡ã³ãã«èšèŒãããŠããŸã ã
äœããã®çç±ã§äœ¿çšå¯èœãªã³ã³ãœãŒã«ã«æºè¶³ã§ããªãå Žåã¯ãPrometheus ã人æ°ã®ããGrafanaããŒã«ãšçµ±åã§ããŸã ã
Prometheuséçºè ã¯ãã€ã³ã¿ãŒãã§ã€ã¹äžã®Grafanaãé£æ³ãããPromdashãšåŒã°ããç¬èªã®ããã·ã¥ããŒãããŒã«ãäœæããŸããïŒ GitHubã®ãªããžããªãåç §ïŒã ç§ãã¡ã®æèŠã§ã¯ãããã¯ãŸã ãããçã®ãç¶æ ã§ããã䜿çšãæšå¥šããã«ã¯æ©ãããŸãã
AlertmanagerïŒéç¥ã®èšå®
éç¥é åžã³ã³ããŒãã³ããªãã§ã¯èããããªãç£èŠããŒã«ã¯ãããŸããã Prometheusã¯ãã®ç®çã®ããã«alertmanagerã䜿çšããŸãã éç¥èšå®ã¯ãalertmanager.confæ§æãã¡ã€ã«ã«ä¿åãããŸãã
次ã®ã¹ãããããæ€èšããŠãã ããã
notification_config { name: "alertmanager_test" email_config { email: "test@example.org" } aggregation_rule { notification_config_name: "alertmanager_test" }
ãã®æ§æã¯ç解ã§ããŸããç¹å®ã®æ¡ä»¶ãçºçãããšãã®éç¥ãé»åã¡ãŒã«ã§test@example.orgã«éä¿¡ããå¿ èŠãããããšã瀺ããŸããã
æ§æãã¡ã€ã«ã«ã«ãŒã«ãã¡ã€ã«ãžã®ãªã³ã¯ãè¿œå ã§ããŸãïŒå®éãäžèšã®ã¡ããªãã¯ãåéããããã®ã«ãŒã«ãã¡ã€ã«ãšéãã¯ãããŸããïŒã ã«ãŒã«ã¯ãéç¥ãéä¿¡ããå¿ èŠãããæ¡ä»¶ãæå®ããŸãã
äžè¬ã«ãã«ãŒã«ã®æ§æã¯æ¬¡ã®ããã«ãªããŸãã
ALERT < > IF < > FOR < > WITH < >> SUMMARY "< >" DESCRIPTION "< >"
ããå ·äœçãªäŸã«ã€ããŠã¯ãã«ãŒã«ã®æ©èœãèæ ®ããŠãã ããã
äŸ1ïŒ
ALERT InstanceDown IF up == 0 FOR 5m WITH { severity="page" } SUMMARY "Instance {{$labels.instance}} down" DESCRIPTION "{{$labels.instance}} of job {{$labels.job}} has been down for more than 5 minutes."
ãã®ã«ãŒã«ã¯ã5å以äžã€ã³ã¹ã¿ã³ã¹ãå©çšã§ããªãå Žåã«éç¥ãéä¿¡ããããšã瀺ããŸãã
äŸ2ïŒ
ALERT ApiHighRequestLatency IF api_http_request_latencies_ms{quantile="0.5"} > 1000 FOR 1m SUMMARY "High request latency on {{$labels.instance}}" DESCRIPTION "{{$labels.instance}} has a median request latency above 1s (current value: {{$value}})"
ãã®ã«ãŒã«ã«åŸã£ãŠãAPIãžã®ãªã¯ãšã¹ãã«å¯Ÿããå¹³åå¿çæéã1ããªç§ãè¶ ãããããã«éç¥ãéä¿¡ããå¿ èŠããããŸãã
æ§æãã¡ã€ã«ã§æå®ãããèšå®ãæå¹ã«ããã«ã¯ããããä¿åããŠã³ãã³ããå®è¡ããå¿ èŠããããŸãã
$ alertmanager -config.file alertmanager.conf
è€æ°ã®æ§æãã¡ã€ã«ãäœæããããŸããŸãªå Žåã«ãããã®éç¥èšå®ãæå®ã§ããŸãã
Prometheusã¯éç¥ãJSON圢åŒã§éä¿¡ããŸãã ãããã¯æ¬¡ã®ããã«ãªããŸãã
{ "version": "1", "status": "firing", "alert": [ { "summary": "summary", "description": "description", "labels": { "alertname": "TestAlert" }, "payload": { "activeSince": "2015-06-01T12:55:47.356+01:00", "alertingRule": "ALERT TestAlert IF absent(metric_name) FOR 0y WITH ", "generatorURL": "http://localhost:9090/graph#%5B%7B%22expr%22%3A%22absent%28metric_name%29%22%2C%22tab%22%3A0%7D%5D", "value": "1" } } ] }
éç¥ã¯ãé»åã¡ãŒã«ãWebããã¯ãããã³PagerDuty ã HipChatãªã©ã®å°çšãµãŒãã¹ã䜿çšããŠéä¿¡ãããŸãã
Prometheuséçºè ã¯ããããŸã§ã«alertmanagerããçã®ãç¶æ ã«ããããšã©ãŒã®å¯èœæ§ãèŠåããŠããããšã«æ³šæããŠããŸãã ãã ãããã®ã³ã³ããŒãã³ãã®åäœã«ç°åžžã¯ãããŸããã§ããã
ãããã«
ããã¡ããŠã¹ã¯èå³æ·±ããææãªããŒã«ã§ããã泚æãæã䟡å€ããããŸãã ãã®å©ç¹ã®äžã§ããŸã匷調ããå¿ èŠããããŸãïŒ
- å±éã®å®¹æãã
- ãµãŒãããŒãã£ã®ã¢ããªã±ãŒã·ã§ã³ããã³ãµãŒãã¹ãšã®åºç¯ãªçµ±åã
- ã¡ããªãã¯ãæäœããããã®äŸ¿å©ãªã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹ã
Prometheusã®äœ¿çšçµéšãããå Žåã¯ãå°è±¡ãå ±æããŠãã ããã æçãªã³ã¡ã³ããè¿œå ã«æè¬ããŸãã
詳现ãç¥ããã人ã®ããã«ãããã«ããã€ãã®äŸ¿å©ãªãªã³ã¯ããããŸãïŒ
- https://developers.soundcloud.com/blog/prometheus-monitoring-at-soundcloud-SoundCloudããã°ã®Prometheusã«é¢ããèšäºã
- http://www.robustperception.io/blog/-ããã¡ããŠã¹ãã©ã€ã¢ã³ãã©ãžã«ã®éçºè ã®1人ã®ããã°ãèå³æ·±ãå®çšäŸããããŸãã
- http://agiletesting.blogspot.ru/2015/11/initial-experiences-with-prometheus.html-ããã¡ããŠã¹ã®å®éšã«é¢ããèå³æ·±ãã¬ããŒãã
- https://www.digitalocean.com/community/tutorials/how-to-install-prometheus-using-docker-on-centos-7-Dockerã« Prometheusãã€ã³ã¹ããŒã«ããæé
- https://github.com/William-Yeh/ansible-prometheus-Prometheusãã€ã³ã¹ããŒã«ããããã®AnsibleããŒã«ã
äœããã®çç±ã§ããã«ã³ã¡ã³ããæ®ããªãå Žåã¯ãããã°ã«æåŸ ããŸãã