statsig-io / statuspage

A simple, zero-dependency, pure js/html status page based on GitHub Pages and Actions.
ISC License
685 stars 289 forks source link

[Feature Request] Delete Old Data From Logs Via Bash Script! #13

Closed IzumiSenaSora closed 2 years ago

IzumiSenaSora commented 2 years ago

If Its running all day and night it will make "logs/example_report.logs" file too big with time! so can you guys add some script which will calculate days like "30 days for example" from 2021-01-01 to 2021-01-31 data is valid! and older data from 2020-12-31 will automatically remove something like this! cause website can show 30 days data only! others just doing nothing so removing them is better in my opinion!

BTW Thanks for this simple solution!

vijaye-statsig commented 2 years ago

Good idea. I’ll add some cleanup options.

IzumiSenaSora commented 2 years ago

Good idea. I’ll add some cleanup options.

Is there any news?....

I found a solution if its okay! Can you review a bit? If it is ok to apply in your work

after getting result "success"

    echo $dateTime, $result >> "logs/${key}_report.log"
    tail -n 1440 "logs/${key}_report.log" > "logs/${key}_report.log.tmp" && mv "logs/${key}_report.log.tmp" "logs/${key}_report.log"

It can run this tail command!... tail -n 1440 shows last 1440 lines in ".log" files!...

In a hour it runs 2 time so in 24 hour it will run 48 times So in 30 days it will run 1440 times means 1440 lines of log!... So it's still smaller file compared to 5680 lines of mine 😅😅 i am using this solution for a while! Working great!... So if you have any other solution to make it even smaller then it will be cool!

For those who run every hour instead of every 30 minutes Just need to change "1440" to "720" (whice will make ".log" file size even more smaller)

    echo $dateTime, $result >> "logs/${key}_report.log"
    tail -n 720 "logs/${key}_report.log" > "logs/${key}_report.log.tmp" && mv "logs/${key}_report.log.tmp" "logs/${key}_report.log"
vijaye-statsig commented 2 years ago

thanks for the prodding, @IzumiSena . Updating in a few mins.

vijaye-statsig commented 2 years ago

https://github.com/statsig-io/statuspage/pull/19

vijaye-statsig commented 2 years ago

This should now be addressed. Thank you!