diff --git a/.env b/.env index 3ce066dcaf..21d99e5305 100644 --- a/.env +++ b/.env @@ -75,7 +75,8 @@ _APP_MAINTENANCE_INTERVAL=86400 _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 _APP_MAINTENANCE_RETENTION_ABUSE=86400 _APP_MAINTENANCE_RETENTION_AUDIT=1209600 -_APP_USAGE_AGGREGATION_INTERVAL=15 +_APP_USAGE_TIMESERIES_INTERVAL=30 +_APP_USAGE_DATABASE_INTERVAL=900 _APP_USAGE_STATS=enabled _APP_LOGGING_PROVIDER= _APP_LOGGING_CONFIG= diff --git a/Dockerfile b/Dockerfile index 29d495ec26..ac8bc9416d 100755 --- a/Dockerfile +++ b/Dockerfile @@ -207,6 +207,8 @@ ENV _APP_SERVER=swoole \ _APP_SETUP=self-hosted \ _APP_VERSION=$VERSION \ _APP_USAGE_STATS=enabled \ + _APP_USAGE_TIMESERIES_INTERVAL=30 \ + _APP_USAGE_DATABASE_INTERVAL=900 \ # 14 Days = 1209600 s _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 \ _APP_MAINTENANCE_RETENTION_AUDIT=1209600 \ diff --git a/app/config/variables.php b/app/config/variables.php index 7b4c4b4ace..27dc20ee53 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -170,13 +170,31 @@ return [ ], [ 'name' => '_APP_USAGE_AGGREGATION_INTERVAL', - 'description' => 'Interval value containing the number of seconds that the Appwrite usage process should wait before aggregating stats and syncing it to mariadb from InfluxDB. The default value is 30 seconds.', + 'description' => 'Deprecated since 0.16.0, use `_APP_USAGE_TIMESERIES_INTERVAL` instead.', 'introduction' => '0.10.0', 'default' => '30', 'required' => false, 'question' => '', 'filter' => '' ], + [ + 'name' => '_APP_USAGE_TIMESERIES_INTERVAL', + 'description' => 'Interval value containing the number of seconds that the Appwrite usage process should wait before aggregating stats and syncing it to mariadb from InfluxDB. The default value is 30 seconds.', + 'introduction' => '0.16.0', + 'default' => '30', + 'required' => false, + 'question' => '', + 'filter' => '' + ], + [ + 'name' => '_APP_USAGE_DATABASE_INTERVAL', + 'description' => 'Interval value containing the number of seconds that the Appwrite usage process should wait before aggregating stats from data in MariaDB. The default value is 15 minutes.', + 'introduction' => '0.16.0', + 'default' => '900', + 'required' => false, + 'question' => '', + 'filter' => '' + ], [ 'name' => '_APP_WORKER_PER_CORE', 'description' => 'Internal Worker per core for the API, Realtime and Executor containers. Can be configured to optimize performance.', diff --git a/app/tasks/usage.php b/app/tasks/usage.php index 07e9530f32..dba356abb6 100644 --- a/app/tasks/usage.php +++ b/app/tasks/usage.php @@ -14,6 +14,7 @@ use Utopia\Database\Database; use Utopia\Database\Validator\Authorization; use Utopia\Registry\Registry; use Utopia\Logger\Log; +use Utopia\Validator\WhiteList; Authorization::disable(); Authorization::setDefaultStatus(false); @@ -112,12 +113,13 @@ $logError = function (Throwable $error, string $action = 'syncUsageStats') use ( $cli ->task('usage') + ->param('type', 'timeseries', new WhiteList(['timeseries', 'database'])) ->desc('Schedules syncing data from influxdb to Appwrite console db') - ->action(function () use ($register, $logError) { + ->action(function (string $type) use ($register, $logError) { Console::title('Usage Aggregation V1'); Console::success(APP_NAME . ' usage aggregation process v1 has started'); - $interval = (int) App::getEnv('_APP_USAGE_AGGREGATION_INTERVAL', '30'); // 30 seconds (by default) + $interval = (int) App::getEnv('_APP_USAGE_TIMESERIES_INTERVAL', '30'); // 30 seconds (by default) $database = getDatabase($register, '_console'); $influxDB = getInfluxDB($register); diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 45628f5bcc..f504892d56 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -569,7 +569,8 @@ services: - _APP_DB_PASS - _APP_INFLUXDB_HOST - _APP_INFLUXDB_PORT - - _APP_USAGE_AGGREGATION_INTERVAL + - _APP_USAGE_TIMESERIES_INTERVAL + - _APP_USAGE_DATABASE_INTERVAL - _APP_REDIS_HOST - _APP_REDIS_PORT - _APP_REDIS_USER diff --git a/docker-compose.yml b/docker-compose.yml index 20d2c5c2f9..f8b7f7947f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -609,7 +609,8 @@ services: - _APP_DB_PASS - _APP_INFLUXDB_HOST - _APP_INFLUXDB_PORT - - _APP_USAGE_AGGREGATION_INTERVAL + - _APP_USAGE_TIMESERIES_INTERVAL + - _APP_USAGE_DATABASE_INTERVAL - _APP_REDIS_HOST - _APP_REDIS_PORT - _APP_REDIS_USER