monitoringprometheus

Increasing Prometheus storage retention


I have Prometheus server installed on my AWS instance, but the data is being removed automatically after 15 days. I need to have data for a year or months. Is there anything I need to change in my prometheus configuration?

Or do I need any extensions like Thanos? I am new to Prometheus so please be easy on the answers.


Solution

    1. Edit the prometheus.service file

    vi /etc/systemd/system/prometheus.service

    1. add "--storage.tsdb.retention.time=1y" below to "ExecStart=/usr/local/bin/prometheus \" line.

    So the config will look like bellow for 1 year of data retention.

    [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://XX.XX.XX.XX:9090 \
        --storage.tsdb.retention.time=1y
    [Install]
    WantedBy=multi-user.target