官方網址:https://prometheus.io/html
GitHub網址:https://github.com/prometheus/prometheusnode
軟件下載地址:https://prometheus.io/download/python
第三方中文介紹:https://github.com/1046102779/prometheusmysql
prometheus介紹
Prometheus是一個開源的系統監控和報警的工具包,最初由SoundCloud發佈。linux
特色:git
- 多維數據模型(有metric名稱和鍵值對肯定的時間序列)
- 靈活的查詢語言
- 不依賴分佈式存儲
- 經過pull方式採集時間序列,經過http協議傳輸
- 支持經過中介網關的push時間序列的方式
- 監控數據經過服務或者靜態配置來發現
- 支持圖表和dashboard等多種方式
組件:github
- Prometheus 主程序,主要是負責存儲、抓取、聚合、查詢方面。
- Alertmanager 程序,主要是負責實現報警功能。
- Pushgateway 程序,主要是實現接收由Client push過來的指標數據,在指定的時間間隔,由主程序來抓取。
- *_exporter 這類是不一樣系統已經實現了的集成。
架構:redis
prometheus部署
一、下載安裝包prometheus-1.6.2.linux-amd64.tar.gzsql
https://github.com/prometheus/prometheus/releases/tag/v1.6.2json
二、解壓
1
2
|
tar
-
xvf prometheus
-
1.6
.
2.linux
-
amd64.tar.gz
cd prometheus
-
1.6
.
2.linux
-
amd64
|
三、配置prometheus.yml
- scrape_interval: 15s # 默認15秒到目標處抓取數據
四、啓動
1
2
3
|
nohup .
/
prometheus
-
config.
file
=
prometheus.yml &
或
nohup
/
opt
/
prometheus
-
1.6
.
2.linux
-
amd64
/
prometheus &
|
五、WEB頁面訪問http://localhost:9090/ ,能夠看到Prometheus的graph頁面。
備註:參考文章 http://www.cnblogs.com/vovlie/p/Prometheus_install.html
grafana部署
http://docs.grafana.org/installation/rpm/
一、安裝
1
2
3
|
wget https:
/
/
s3
-
us
-
west
-
2.amazonaws
.com
/
grafana
-
releases
/
release
/
grafana
-
4.2
.
0
-
1.x86_64
.rpm
sudo yum install initscripts fontconfig
-
y
sudo rpm
-
Uvh grafana
-
4.2
.
0
-
1.x86_64
.rpm
|
二、啓動服務service grafana-server start
三、訪問頁面http://localhost:3000 ,默認帳號、密碼admin/admin
四、Prometheus 和 Grafana 的對接
https://prometheus.io/docs/visualization/grafana/
參考文章:http://www.cnblogs.com/sfnz/p/6566951.html
MySQL的dashboards(Grafana)
https://github.com/percona/grafana-dashboards
1
2
|
git clone https:
/
/
github.com
/
percona
/
grafana
-
dashboards.git
cp
-
r grafana
-
dashboards
/
dashboards
/
var
/
lib
/
grafana
/
dashboards
|
編輯Grafana配置文件
1
2
3
4
|
vi
/
etc
/
grafana
/
grafana.ini
[dashboards.json]
enabled
=
true
path
=
/
var
/
lib
/
grafana
/
dashboards
|
重啓service grafana-server restart
mysql監控部署
在須要監控的mysql上安裝 node_exporter和 mysqld_exporter
下載 https://prometheus.io/download/
1
2
3
|
tar
-
xvf node_exporter
-
0.14
.
0.linux
-
amd64.tar.gz
cd node_exporter
-
0.14
.
0.linux
-
amd64
nohup .
/
node_exporter &
|
1
2
3
4
5
6
7
8
9
|
tar
-
xvf mysqld_exporter
-
0.10
.
0.linux
-
amd64.tar.gz
cd mysqld_exporter
-
0.10
.
0.linux
-
amd64
vi .my.cnf
[client]
user
=
root
password
=
root
.
/
mysqld_exporter
-
config.my
-
cnf
=
".my.cnf"
&
|
服務端配置,文件prometheus.yml
1
2
3
4
5
6
7
8
9
10
|
scrape_configs:
-
job_name:
'prometheus'
static_configs:
-
targets: [
'localhost:9090'
]
-
job_name:
'mysql'
static_configs:
-
targets: [
'10.10.83.162:9104'
]
labels:
instance: db
-
10.10
.
83.162
|
redis監控部署
下載 https://github.com/oliver006/redis_exporter/releases
1
2
|
tar
-
xvf redis_exporter
-
v0.
11.linux
-
amd64.tar.gz
nohup
/
opt
/
redis_exporter
-
redis.addr
"redis://10.10.83.162:16379"
&
|
grafana配置
下載 redis_exporter-0.11.tar.gz
1
2
3
|
tar
-
xvf redis_exporter
-
0.11
.tar.gz
cd redis_exporter
-
0.11
cp
*
json
/
var
/
lib
/
grafana
/
dashboards
/
|
服務端配置,文件prometheus.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
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'
]
-
job_name:
'mysql'
static_configs:
-
targets: [
'10.10.83.162:9104'
]
labels:
instance: db
-
10.10
.
83.162
-
job_name: redis_exporter
static_configs:
-
targets: [
'10.10.83.162:9121'
]
labels:
instance: redis
-
10.10
.
83.162
|