锛?锛塸rometheus瀹夎閮ㄧ讲

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了锛?锛塸rometheus瀹夎閮ㄧ讲相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/%e6%97%b6%e5%ba%8f' title='鏃跺簭'>鏃跺簭   nat   mamicode   grafana   tor   list   ati   閫昏緫   nta   

浠€涔堟槸prometheus?

Prometheus 鏄敱 SoundCloud 寮€婧愮洃鎺у憡璀﹁В鍐虫柟妗堬紝浠?2012 骞村紑濮嬬紪鍐欎唬鐮侊紝鍐嶅埌 2015 骞?github 涓婂紑婧愪互鏉ワ紝宸茬粡鍚稿紩浜?9k+ 鍏虫敞锛屼互鍙婂緢澶氬ぇ鍏徃鐨勪娇鐢紱2016 骞?Prometheus 鎴愪负缁?k8s 鍚庯紝绗簩鍚?CNCF(Cloud Native Computing Foundation) 鎴愬憳銆?/p>

涓昏鍔熻兘锛?/h3>

澶氱淮 鏁版嵁妯″瀷锛堟椂搴忕敱 metric 鍚嶅瓧鍜?k/v 鐨?labels 鏋勬垚锛夈€?br/>鐏垫椿鐨勬煡璇㈣鍙ワ紙PromQL锛夈€?br/>鏃犱緷璧栧瓨鍌紝鏀寔 local 鍜?remote 涓嶅悓妯″瀷銆?br/>閲囩敤 http 鍗忚锛屼娇鐢?pull 妯″紡锛屾媺鍙栨暟鎹紝绠€鍗曟槗鎳傘€?br/>鐩戞帶鐩爣锛屽彲浠ラ噰鐢ㄦ湇鍔″彂鐜版垨闈欐€侀厤缃殑鏂瑰紡銆?br/>鏀寔澶氱缁熻鏁版嵁妯″瀷锛屽浘褰㈠寲鍙嬪ソ銆?/p>

鏍稿績缁勫缓锛?/h3>

Prometheus Server锛?涓昏鐢ㄤ簬鎶撳彇鏁版嵁鍜屽瓨鍌ㄦ椂搴忔暟鎹紝鍙﹀杩樻彁渚涙煡璇㈠拰 Alert Rule 閰嶇疆绠$悊銆?br/>client libraries锛岀敤浜庡鎺?Prometheus Server, 鍙互鏌ヨ鍜屼笂鎶ユ暟鎹€?br/>push gateway 锛岀敤浜庢壒閲忥紝鐭湡鐨勭洃鎺ф暟鎹殑姹囨€昏妭鐐癸紝涓昏鐢ㄤ簬涓氬姟鏁版嵁姹囨姤绛夈€?br/>exporters 锛岄儴缃插湪瀹㈡埛绔殑agent 渚嬪姹囨姤鏈哄櫒鏁版嵁鐨?node_exporter, 姹囨姤 MongoDB 淇℃伅鐨?MongoDB exporter 绛夌瓑銆?br/>alertmanager 鐢ㄤ簬鍛婅閫氱煡绠$悊鐨?/p>

鍩虹鏋舵瀯鍥撅細

鎶€鏈浘鐗? src=

浠庤繖涓灦鏋勫浘锛屼篃鍙互鐪嬪嚭 Prometheus 鐨勪富瑕佹ā鍧楀寘鍚紝 Server, Exporters, Pushgateway, PromQL, Alertmanager, WebUI 绛夈€?/p>

瀹冨ぇ鑷翠娇鐢ㄩ€昏緫鏄繖鏍凤細
Prometheus server 瀹氭湡浠庨潤鎬侀厤缃殑 targets 鎴栬€呮湇鍔″彂鐜扮殑 targets 鎷夊彇鏁版嵁銆?br/>褰撴柊鎷夊彇鐨勬暟鎹ぇ浜庨厤缃唴瀛樼紦瀛樺尯鐨勬椂鍊欙紝Prometheus 浼氬皢鏁版嵁鎸佷箙鍖栧埌纾佺洏锛堝鏋滀娇鐢?remote storage 灏嗘寔涔呭寲鍒颁簯绔級銆?br/>Prometheus 鍙互閰嶇疆 rules锛岀劧鍚庡畾鏃舵煡璇㈡暟鎹紝褰撴潯浠惰Е鍙戠殑鏃跺€欙紝浼氬皢 alert 鎺ㄩ€佸埌閰嶇疆鐨?Alertmanager銆?br/>Alertmanager 鏀跺埌璀﹀憡鐨勬椂鍊欙紝鍙互鏍规嵁閰嶇疆锛岃仛鍚堬紝鍘婚噸锛岄檷鍣紝鏈€鍚庡彂閫佽鍛娿€?br/>鍙互浣跨敤 API锛?Prometheus Console 鎴栬€?Grafana 鏌ヨ鍜岃仛鍚堟暟鎹€?/p>

浠ヤ笂鍐呭杞浇锛?a href="https://songjiayang.gitbooks.io/prometheus/content/introduction/what.html" rel="nofollow">https://songjiayang.gitbooks.io/prometheus/content/introduction/what.html

瀹夎锛歱rometheus

锛?锛変笅杞藉畨瑁呭寘https://prometheus.io/download/ 鑷虫寚瀹氱洰褰曞/Download
shell>gwet https://github.com/prometheus/prometheus/releases/download/v2.13.1/prometheus-2.13.1.darwin-amd64.tar.gz

锛?锛夎В鍘媝rometheus
shell>tar -xvzf ~/Download/prometheus-2.13.1.linux-amd64.tar.gz
shell>mv prometheus-2.13.1.linux-amd64 prometheus
shell>cd prometheus
shell>ls prometheus
prometheus 鍚姩鏂囦欢
prometheus.yml 閰嶇疆鏂囦欢
data 瀛樺偍鏂囦欢

锛?锛夋鏌rometheus鐗堟湰
shell> ./prometheus version

prometheus, version 2.13.0 (branch: HEAD, revision: 6ea4252299f542669aca11860abc2192bdc7bede)
  build user:       root@f30bdad2c3fd
  build date:       20191004-11:25:34
  go version:       go1.13.1

锛?锛夊惎鍔╬rometheus server
shell> ./prometheus #姝e父鍚姩浼氳緭鍑哄緢澶氫俊鎭?/p>

level=info ts=2019-10-17T09:29:45.851Z caller=main.go:332 msg="Starting Prometheus" version="(version=2.13.0, branch=HEAD, revision=6ea4252299f542669aca11860abc2192bdc7bede)"

锛?锛夋煡鐪嬬鍙g洃鍚紝鐩戝惉绔彛9090
shell>netstat -tunlp | grep prometheus
tcp6 0 0 :::9090 :::* LISTEN 31879/./prometheus

锛?锛夐€氳繃web璁块棶http://IP:9090

鎶€鏈浘鐗? src=

锛?锛変互鏈嶅姟鐨勬柟寮忓惎鍔?br/>shell>vim /etc/systemd/system/prometheus.service

[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System

[Service]
ExecStart=/Download/prometheus/prometheus   --config.file /Download/prometheus/prometheus.yml   --web.listen-address=:9090

[Install]
WantedBy=multi-user.target

shell> systemctl daemon-reload
shell> systemctl enable prometheus
shell> systemctl start prometheus

以上是关于锛?锛塸rometheus瀹夎閮ㄧ讲的主要内容,如果未能解决你的问题,请参考以下文章

k8s閮ㄧ讲涔媦um瀹夎锛堥樋閲屼簯婧愶級

k8s瀹炶返18:helm閮ㄧ讲瀹夎grafana閰嶇疆娴嬭瘯

Springboot 鎵撳寘閮ㄧ讲

mongodb 4.2鍗曟満閮ㄧ讲

Docker閮ㄧ讲Egg.js搴旂敤

Docker涔媠warm閮ㄧ讲闆嗙兢