Warm tip: This article is reproduced from serverfault.com, please click

monitoring-增加Prometheus的存储保留

(monitoring - Increasing Prometheus storage retention)

发布于 2019-12-12 06:23:59

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

Questioner
Rohit Bharati
Viewed
0
3,048 2021-02-12 18:29:32
  1. 编辑prometheus.service文件vi /etc/systemd/system/prometheus.service

  2. 在“ ExecStart = / usr / local / bin / prometheus”中添加下面的“ --storage.tsdb.retention.time = 1y”。

因此,该配置看起来像下面这样,可以保留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