目录
1. Prometheus介绍
Prometheus是一套开源的监控、报警、时间序列数据库的组合,Go语言开发。随着发展,越来越多公司和组织接受采用Prometheus,社区也十分活跃,他们便将它独立成开源项目,并且有公司来运作。google SRE的书内也曾提到跟他们BorgMon监控系统相似的实现是Prometheus。现在最常见的Kubernetes容器管理系统中,通常会搭配Prometheus进行监控。
Zabbix在监控界占有不可撼动的地位,功能强大。但是对容器监控显得力不从心。为解决监控容器的问题,引入了prometheus技术。prometheus号称是下一代监控。
2. 下载安装
2.1 下载解压
这里,我是从官方下载后上传到home目录下进行解压安装
# cd /home
# tar -zxvf prometheus-*.tar.gz
2.2 修改prometheus.yml
# cd prometheus-2.20.1.linux-amd64
# vim prometheus.yml
默认配置为9090端口,可修改配置
2.3 启动
# ./prometheus --config.file=prometheus.yml //前台启动
# c --config.file=prometheus.yml & //后台启动
# ps -ef |grep prometheus // 进程查看
# ./prometheus --help //启动帮助
2.4 加入开机服务自动
# vim /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System
[Service]
ExecStart=/home/prometheus-2.20.1.linux-amd64/prometheus \
--config.file=/home/prometheus-2.20.1.linux-amd64/prometheus.yml \
--web.listen-address=:9090
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动服务,设置开机自启,并检查服务开启状态
# systemctl daemon-reload
# systemctl enable prometheus
# systemctl start prometheus
# systemctl status prometheus
2.5 页面访问
3. 安装Grafana
3.1 下载安装
# cd /home
# wget https://dl.grafana.com/oss/release/grafana-6.6.1.linux-amd64.tar.gz
# tar -zxvf grafana-*.linux-amd64.tar.gz
# cd grafana-6.6.1
3.2 启动
# ./bin/grafana-server //前台启动
# nohup ./bin/grafana-server & //后台启动
3.3 访问
http://172.20.32.218:3000 默认账号/密码:admin/admin
具体使用可参考Grafana离线安装、Grafana在线安装
设置DataSource,把prometheus的地址配置到如下列表中
导入prometheus模板
左上角会显示已经选择的模板