update maintenance to delete only hourly metrics older than 3 months
This commit is contained in:
parent
8c3cfa877b
commit
c8b5301267
|
@ -78,11 +78,10 @@ $cli
|
||||||
->trigger();
|
->trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifyDeleteUsageStats(int $interval1h, int $interval1d)
|
function notifyDeleteUsageStats(int $interval1h)
|
||||||
{
|
{
|
||||||
(new Delete())
|
(new Delete())
|
||||||
->setType(DELETE_TYPE_USAGE)
|
->setType(DELETE_TYPE_USAGE)
|
||||||
->setDateTime1d(DateTime::addSeconds(new \DateTime(), -1 * $interval1d))
|
|
||||||
->setDateTime1h(DateTime::addSeconds(new \DateTime(), -1 * $interval1h))
|
->setDateTime1h(DateTime::addSeconds(new \DateTime(), -1 * $interval1h))
|
||||||
->trigger();
|
->trigger();
|
||||||
}
|
}
|
||||||
|
@ -144,11 +143,11 @@ $cli
|
||||||
$executionLogsRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', '1209600');
|
$executionLogsRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_EXECUTION', '1209600');
|
||||||
$auditLogRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', '1209600');
|
$auditLogRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', '1209600');
|
||||||
$abuseLogsRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', '86400');
|
$abuseLogsRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', '86400');
|
||||||
$usageStatsRetention1h = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_USAGE_30M', '129600'); //36 hours
|
$usageStatsRetention1h = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_USAGE_1H', '8640000'); //100 days
|
||||||
$usageStatsRetention1d = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_USAGE_1D', '8640000'); // 100 days
|
|
||||||
$cacheRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_CACHE', '2592000'); // 30 days
|
$cacheRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_CACHE', '2592000'); // 30 days
|
||||||
|
|
||||||
Console::loop(function () use ($interval, $executionLogsRetention, $abuseLogsRetention, $auditLogRetention, $usageStatsRetention1h, $usageStatsRetention1d, $cacheRetention) {
|
Console::loop(function () use ($interval, $executionLogsRetention, $abuseLogsRetention, $auditLogRetention, $usageStatsRetention1h, $cacheRetention) {
|
||||||
$database = getConsoleDB();
|
$database = getConsoleDB();
|
||||||
|
|
||||||
$time = DateTime::now();
|
$time = DateTime::now();
|
||||||
|
@ -157,7 +156,7 @@ $cli
|
||||||
notifyDeleteExecutionLogs($executionLogsRetention);
|
notifyDeleteExecutionLogs($executionLogsRetention);
|
||||||
notifyDeleteAbuseLogs($abuseLogsRetention);
|
notifyDeleteAbuseLogs($abuseLogsRetention);
|
||||||
notifyDeleteAuditLogs($auditLogRetention);
|
notifyDeleteAuditLogs($auditLogRetention);
|
||||||
notifyDeleteUsageStats($usageStatsRetention1h, $usageStatsRetention1d);
|
notifyDeleteUsageStats($usageStatsRetention1h);
|
||||||
notifyDeleteConnections();
|
notifyDeleteConnections();
|
||||||
notifyDeleteExpiredSessions();
|
notifyDeleteExpiredSessions();
|
||||||
renewCertificates($database);
|
renewCertificates($database);
|
||||||
|
|
|
@ -217,16 +217,10 @@ class DeletesV1 extends Worker
|
||||||
* @param string $datetime1d
|
* @param string $datetime1d
|
||||||
* @param string $datetime1h
|
* @param string $datetime1h
|
||||||
*/
|
*/
|
||||||
protected function deleteUsageStats(string $datetime1d, string $datetime1h)
|
protected function deleteUsageStats(string $datetime1h)
|
||||||
{
|
{
|
||||||
$this->deleteForProjectIds(function (string $projectId) use ($datetime1d, $datetime1h) {
|
$this->deleteForProjectIds(function (string $projectId) use ($datetime1h) {
|
||||||
$dbForProject = $this->getProjectDB($projectId);
|
$dbForProject = $this->getProjectDB($projectId);
|
||||||
// Delete Usage stats
|
|
||||||
$this->deleteByGroup('stats', [
|
|
||||||
Query::lessThan('time', $datetime1d),
|
|
||||||
Query::equal('period', ['1d']),
|
|
||||||
], $dbForProject);
|
|
||||||
|
|
||||||
$this->deleteByGroup('stats', [
|
$this->deleteByGroup('stats', [
|
||||||
Query::lessThan('time', $datetime1h),
|
Query::lessThan('time', $datetime1h),
|
||||||
Query::equal('period', ['1h']),
|
Query::equal('period', ['1h']),
|
||||||
|
|
|
@ -12,7 +12,6 @@ class Delete extends Event
|
||||||
protected ?string $resource = null;
|
protected ?string $resource = null;
|
||||||
protected ?string $datetime = null;
|
protected ?string $datetime = null;
|
||||||
protected ?string $dateTime1h = null;
|
protected ?string $dateTime1h = null;
|
||||||
protected ?string $dateTime1d = null;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -55,18 +54,6 @@ class Delete extends Event
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set datetime for 1 day interval.
|
|
||||||
*
|
|
||||||
* @param string $datetime
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function setDateTime1d(string $datetime): self
|
|
||||||
{
|
|
||||||
$this->dateTime1d = $datetime;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets datetime for 1h interval.
|
* Sets datetime for 1h interval.
|
||||||
*
|
*
|
||||||
|
@ -140,7 +127,6 @@ class Delete extends Event
|
||||||
'document' => $this->document,
|
'document' => $this->document,
|
||||||
'resource' => $this->resource,
|
'resource' => $this->resource,
|
||||||
'datetime' => $this->datetime,
|
'datetime' => $this->datetime,
|
||||||
'dateTime1d' => $this->dateTime1d,
|
|
||||||
'dateTime1h' => $this->dateTime1h,
|
'dateTime1h' => $this->dateTime1h,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue