1.Prometheus支持的数据库
这里使用Influxdb:https://docs.influxdata.com/influxdb/v1.8/supported_protocols/prometh
eus
2.Influxdb 部署
配置yum镜像
cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL $releasever
baseurl =
https://repos.influxdata.com/rhel/$releasever/$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF
安装并启动influxdb
[root@docker-2 ~]# yum install influxdb -y
[root@docker-2 ~]# systemctl start influxdb ##启动
创建prometheus 数据库
修改服务脚本指定存储路径
–storage.tsdb.path=/usr/local/prometheus/data
检查prometheus 的systemd配置
[root@docker-3 prometheus]# cat /usr/lib/systemd/system/prometheus.service
[Unit]
Description=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/usr/local/prometheus/prometheus
--config.file=/usr/local/prometheus/prometheus.yml
--storage.tsdb.path=/usr/local/prometheus/data
[Install]
WantedBy=multi-user.target
配置prometheus 添加远程读写
remote_write:
- url: "http://172.16.0.8:8086/api/v1/prom/write?db=prometheus"
remote_read:
- url: "http://172.16.0.8:8086/api/v1/prom/read?db=prometheus"
重启prometheus
[root@docker-3 prometheus]# systemctl restart prometheus
验证influxdb 是否有数据写入
> use prometheus
> show measurements
> select * from prometheus_http_requests_total limit 5;
验证数据可靠性
停止Prometheus 服务。同时删除Prometheus 的data 目录,重启Prometheus。打开Prometheus
UI 如果配置正常,Prometheus 可以正常查询到本地存储以删除的历史数据记录。
[root@docker-3 prometheus]# systemctl stop prometheus
[root@docker-3 prometheus]# mv data/ /tmp/