目錄:
1、Prometheus
1.1、安裝與配置
1.2、查看監(jiān)控指標(biāo)
1.3、監(jiān)控遠(yuǎn)程主機(jī)
1.4、監(jiān)控?cái)?shù)據(jù)庫(kù)
2、Grafana
2.1、安裝與配置
2.2、添加數(shù)據(jù)源
2.3、添加儀表板
2.4、官方儀表板
1、Prometheus
簡(jiǎn)介:
Prometheus是一個(gè)開(kāi)源系統(tǒng)監(jiān)控和警報(bào)工具包,最初是在SoundCloud上構(gòu)建的。自2012年成立以來(lái),許多公司和組織都采用了Prometheus,該項(xiàng)目擁有非常活躍的開(kāi)發(fā)者和用戶社區(qū)。它現(xiàn)在是一個(gè)獨(dú)立的開(kāi)源項(xiàng)目,獨(dú)立于任何公司進(jìn)行維護(hù)。為了強(qiáng)調(diào)這一點(diǎn),并澄清項(xiàng)目的治理結(jié)構(gòu),Prometheus于2016年加入云原生計(jì)算基金會(huì),作為繼Kubernetes之后的第二個(gè)托管項(xiàng)目。
Prometheus將其指標(biāo)收集并存儲(chǔ)為時(shí)間序列數(shù)據(jù),即指標(biāo)信息與記錄的時(shí)間戳一起存儲(chǔ),以及稱為標(biāo)簽的可選鍵值對(duì)。
官網(wǎng)地址:
https://prometheus.io/
下載地址:
https://prometheus.io/download/
1.1、安裝與配置
1、下載
根據(jù)服務(wù)器系統(tǒng),下載指定的版本。
例如下載prometheus-2.30.0.linux-amd64.tar.gz
并將已下載的文件上傳到服務(wù)器上
或者直接輸入命令,在服務(wù)器上進(jìn)行下載
wget https://github.com/prometheus/prometheus/releases/download/v2.30.0/prometheus-2.30.0.linux-amd64.tar.gz
2、解壓
tar xf prometheus-2.30.0.linux-amd64.tar.gz
3、移動(dòng)文件夾并命名為prometheus
mv prometheus-2.30.0.linux-amd64 /usr/local/prometheus
4、跳轉(zhuǎn)到prometheus文件夾
cd /usr/local/prometheus
目錄文件:
5、prometheus.yml文件詳解
# my global config
# 全局配置
global:
scrape_interval: 15s # 多久收集一次數(shù)據(jù)
evaluation_interval: 15s # 多久評(píng)估一次規(guī)則
# scrape_timeout is set to the global default (10s). 每次收集數(shù)據(jù)的超時(shí)時(shí)間,默認(rèn)10秒
# Alertmanager configuration
# 告警設(shè)置
alerting:
alertmanagers:
- static_configs: # 告警規(guī)則,也可以基于動(dòng)態(tài)方式進(jìn)行告警
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
# 規(guī)則文件
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
# 收集數(shù)據(jù)配置列表
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
6、查看版本
./prometheus --version
7、后臺(tái)啟動(dòng)
./prometheus &
(記住prometheus IP端口地址,后續(xù)會(huì)用到)
1.2、查看監(jiān)控指標(biāo)
1、瀏覽器訪問(wèn)
瀏覽器訪問(wèn) http://服務(wù)器ip地址(端口默認(rèn)9090)
Alerts:可以看到自定義的告警規(guī)則。
Graph:按查詢條件進(jìn)行數(shù)據(jù)查詢,并生成指定圖形。
Status:可以查看配置信息、規(guī)則、節(jié)點(diǎn)目標(biāo)等,其中Targets表示本地和遠(yuǎn)端的監(jiān)控,可以查看各節(jié)點(diǎn)運(yùn)行情況。