summaryrefslogtreecommitdiff
path: root/src/ingestor.hpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-12-20 15:16:25 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-12-20 15:16:25 +0000
commit30a9d45f5322a63c2adf1de7a248ba3a9a0c3903 (patch)
treea384473d3be0d5f3fc8c358c827b6cf158d187b3 /src/ingestor.hpp
parentf8276d22b6501e3d6164f9b26df94d2d57f597e5 (diff)
downloadwebstat-30a9d45f5322a63c2adf1de7a248ba3a9a0c3903.tar.bz2
webstat-30a9d45f5322a63c2adf1de7a248ba3a9a0c3903.tar.xz
webstat-30a9d45f5322a63c2adf1de7a248ba3a9a0c3903.zip
Add job for puring old access log entries from the databaseHEADmain
Diffstat (limited to 'src/ingestor.hpp')
-rw-r--r--src/ingestor.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ingestor.hpp b/src/ingestor.hpp
index 3e25938..a19c8ec 100644
--- a/src/ingestor.hpp
+++ b/src/ingestor.hpp
@@ -17,6 +17,7 @@ namespace WebStat {
using namespace std::chrono_literals;
struct IngestorSettings : Settings {
+ // NOLINTBEGIN(readability-magic-numbers)
std::string dbConnStr = "dbname=webstat user=webstat";
std::string userAgentAPI = "https://useragentstring.com";
std::filesystem::path fallbackDir = "/var/log/webstat";
@@ -24,6 +25,12 @@ namespace WebStat {
unsigned int dbKeep = 2;
int idleJobsAfter = duration_cast<milliseconds>(1min).count();
minutes freqIngestParkedLines = 30min;
+ minutes freqPurgeOldLogs = 6h;
+ unsigned int purgeDaysToKeep = 61; // ~2 months
+ unsigned int purgeDeleteMax = 10'000;
+ minutes purgeDeleteMaxTime = 5min;
+ seconds purgeDeletePause = 3s;
+ // NOLINTEND(readability-magic-numbers)
};
class Ingestor {
@@ -48,6 +55,7 @@ namespace WebStat {
void runJobsIdle();
void jobIngestParkedLines();
+ unsigned int jobPurgeOldLogs();
template<typename... T> void storeLogLine(DB::Connection *, const std::tuple<T...> &) const;
@@ -64,6 +72,7 @@ namespace WebStat {
using JobLastRunTime = std::chrono::system_clock::time_point;
JobLastRunTime lastRunIngestParkedLines;
+ JobLastRunTime lastRunPurgeOldLogs;
private:
static constexpr size_t MAX_NEW_ENTITIES = 6;