监控组件普罗米修斯Prometheus
Prometheus是Google BorgMon监控系统的开源版本。伴随着容器及Kubernetes技术的兴起,Prometheus越来越受到大家的关注。
Prometheus下载地址:
Prometheus服务端安装
下载服务端
wget -c https://github.com/prometheus/prometheus/releases/download/v2.15.2/prometheus-2.15.2.linux-amd64.tar.gz
tar -zxvf prometheus-2.15.2.linux-amd64.tar.gz -C /usr/local/
主要文件
- prometheus.yml --主配置文件
- prometheus --启动脚本
启动服务端
./prometheus --config.file=prometheus.yml --storage.tsdb.path=data/
添加用户
groupadd -r prometheus
useradd -r -g prometheus -s /sbin/nologin prometheus
编辑服务单元配置
[Unit]
Description=Prometheus monitor Server
Documentation=/usr/local/prometheus-2.15.2.linux-amd64/prometheus --help
Documentation=https://prometheus.io/docs/introduction/overview/
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/prometheus-2.15.2.linux-amd64/prometheus --config.file=/usr/local/prometheus-2.15.2.linux-amd64/prometheus.yml --storage.tsdb.path=/usr/local/prometheus-2.15.2.linux-amd64/data/
Restart=on-failure
通过服务单元进行启动
systemctl daemon-reload
systemctl start prometheus
访问服务端UI界面
http://ipAddr:9090
Prometheus支持多语言客户端,可对核心业务进行埋点
一些主流应用可以通过官方或第三方的导出器,来对这些应用做核心指标的收集例如Redis和MySQL等等
prometheus同样也支持系统和网络相关的exporter方便服务器资源的监控
下载并启动node_exporter监控服务器资源
wget -c https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz -C /usr/local
./node_exporter
服务器编辑prometheus.yml添加node地址
- job_name: 'node_localhost'
static_configs:
- targets: ['localhost:9100']
重新启动服务端
systemctl restart prometheus
安装grafana
grafana下载地址
https://grafana.com/grafana/download
dashboard下载地址
https://grafana.com/grafana/dashboards
插件下载地址
wget -c https://dl.grafana.com/oss/release/grafana-6.1.4-1.x86_64.rpm
yum localinstall grafana-6.1.4-1.x86_64.rpm
systemctl start grafana-server
导入方式
Grafana首页–>左上角图标–>Dashboard–>import
加入1-node-exporter-0-16-0-17-for-prometheus_rev7.json这个插件