Where and How to declare the ---storage.tsdb.retention.time=90d flag

10 views
Skip to first unread message

Anirudh Pasalapudi

unread,
Jul 6, 2020, 10:59:56 PM7/6/20
to Prometheus Users
Hello,


I deployed prometheus using automation and I used a shell file to run the configuration file of prometheus. The contents of the file are mentioned below. However currently the default storage retention period is 15d. I want this to be changed to 90d. I tried to declare the flag --storage.tsdb.retention.time=90d in the prometheus.yml file and also in the below mentioned bash file. When I do that application is not coming up. If I have to add that flag in the below file, where exactly I need to declare that flag and how can I do that. Can anyone please help.


#!/bin/bash

prometheus_binary=/apps/prometheus/prometheus-2.19.0.linux-amd64/prometheus
prometheus_pid=/var/run/prometheus.pid

prometheus_flags=--config.file=/apps/prometheus/prometheus-2.19.0.linux-amd64/prometheus.yml

case "$1" in
    start)
        if [ -f "$prometheus_binary" ]; then
            $prometheus_binary $prometheus_flags> /dev/null 2>&1 &
            echo $! >$prometheus_pid;
            echo $prometheus_flags
        fi
        ;;
    stop)
        PID=$(cat $prometheus_pid);
        kill -9 $PID;
        rm -rf $prometheus_pid
        ;;
    restart)
  if [ -f $prometheus_pid ]; then
    PID=$(cat $prometheus_pid);
          kill -9 $PID;
          $prometheus_binary $prometheus_flags > /dev/null 2>&1 &
          echo $! >$prometheus_pid
  else
    $prometheus_binary -i $prometheus_flags > /dev/null 2>&1 &
                echo $! >$prometheus_pid
  fi
        exit 0
  ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
  exit 1
esac
exit 0

Brian Candler

unread,
Jul 7, 2020, 9:25:47 AM7/7/20
to Prometheus Users
With the other flags:

prometheus_flags="--config.file=/apps/prometheus/prometheus-2.19.0.linux-amd64/prometheus.yml --storage.tsdb.retention.time=90d"

Reply all
Reply to author
Forward
0 new messages