Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Edit the prometheus.service file

    Code Block
    vi /usr/lib/systemd/system/prometheus.service
  2. Change the value of “--storage.tsdb.retention.time=15d" below to "ExecStart=/usr/local/bin/prometheus \" line.
    The config will look like below for 45 days of data retention. (e.g. 1 year: 1y or 365d)

    Code Block
    # /etc/systemd/system/prometheus.service
    [Unit]
    Description=Prometheus Server
    Documentation=https://prometheus.io/docs/introduction/overview/
    After=network-online.target
    
    [Service]
    User=prometheus
    Restart=on-failure
    ExecStart=/usr/local/bin/prometheus \
                                    --config.file=/etc/prometheus/prometheus.yml \
                                    --storage.tsdb.path=/var/lib/prometheus/data \
                                    --storage.tsdb.retention.time=45d \
                                    --web.console.templates=/etc/prometheus/consoles \
                                    --web.console.libraries=/etc/prometheus/console_libraries
    
    [Install]
    WantedBy=multi-user.target

NOTE: Ensure that the unit of time is correctly specified. For instance:
- ‘m' for minutes
- ‘h’ for hours
- ‘d' for days
- 'y’ for years

  1. Reload systemd manager configuration

    Code Block
    systemctl daemon-reload
  2. Restart Prometheus service

    Code Block
    systemctl restart prometheus

See the Prometheus documentation.