4. Prometheus监控数据持久化
Prometheus 默认的本地存储是有限的,通常只能保留15天,不满足监控数据历史数据分析和预测分析那么我们可以可以通过修改--storage.tsdb.retention.time参数来改变数据保留的时长。该参数决定了何时删除旧数据
例如:--storage.tsdb.retention.time=365d会将保留时间设置为一年
1. 修改systemd启动行(前面的文章已经写了怎么把prometh做成系统服务)
vim /usr/lib/systemd/system/prometheus.service
ExecStart=/usr/local/prometheus/prometheus --storage.tsdb.retention=365d --config.file=/usr/local/prometheus/prometheus.yml
2. 重启prometheus
systemctl daemon-reload
systemctl restart prometheus.service
systemctl status prometheus.service
3. 访问Prometheus前台页面查看是否更改成功(9090端口)
Storage retention 等于:1y 表示生效