Search code examples
kubernetesprometheus

rentention of prometheus data for a specific period of time


I am looking at saving the prometheus data of last year between sept-nov. I do not want to save the prometheus data of the remaining year except to have the latest 3 months of data. So that I will have last three months latest data and also can compare the data between sept-nov of last year to the present year.

I need help in understanding how I can achieve this requirement, so that I can reduce the cost and also to have my comparison with last year data for a specific time frame and not to maintain the data of the entire year which will be a overhead and extra cost.

Thanks in advance(my systems are on eks)


Solution

  • The Prometheus service used for monitoring the cluster runs and stores its data on the management node. By default, Prometheus metrics are stored for seven days and you can change this period in the Prometheus configuration file by doing the following:

    On the management node, open the /etc/sysconfig/prometheus file to edit, set the needed retention period for the STORAGE_RETENTION option, and then save your changes. For example:

    STORAGE_RETENTION="--storage.tsdb.retention.time=90d"
    

    Restart the Prometheus service:

    systemctl restart prometheus.service
    

    Note -In Prometheus it is not possible to set a retention period for a specific year directly or for certain months. The retention period in Prometheus is based on duration or interval specified rather than being dedicated to specific year.

    The retention period in Prometheus is defined in terms of duration, typically specified in hours, days, weeks or months.