首页 > 解决方案 > 增加 Prometheus 存储保留

问题描述

嗨,我在我的 AWS 实例上安装了 Prometheus 服务器,但数据会在 15 天后自动删除。我需要一年或几个月的数据,我的 prometheus 配置有什么需要更改的吗?或者我需要像 Thanos 这样的扩展吗,我是 Prometheus 的新手,所以请轻松回答

标签: monitoringprometheus

解决方案


  1. 编辑 prometheus.service 文件

vi /etc/systemd/system/prometheus.service

  1. 在下面添加"--storage.tsdb.retention.time=1y""ExecStart=/usr/local/bin/prometheus \"行。

因此,配置将如下所示,保留 1 年的数据。

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
    --config.file /etc/prometheus/prometheus.yml \
    --storage.tsdb.path /var/lib/prometheus/ \
    --web.console.templates=/etc/prometheus/consoles \
    --web.console.libraries=/etc/prometheus/console_libraries \
    --web.external-url=http://34.89.26.156:9090 \
    --storage.tsdb.retention.time=1y
[Install]
WantedBy=multi-user.target

推荐阅读