mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
add: database read, write metrics.
This commit is contained in:
@@ -3904,7 +3904,9 @@ App::get('/v1/databases/usage')
|
||||
METRIC_DATABASES,
|
||||
METRIC_COLLECTIONS,
|
||||
METRIC_DOCUMENTS,
|
||||
METRIC_DATABASES_STORAGE
|
||||
METRIC_DATABASES_STORAGE,
|
||||
METRIC_DATABASES_OPERATIONS_READS,
|
||||
METRIC_DATABASES_OPERATIONS_WRITES,
|
||||
];
|
||||
|
||||
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
|
||||
@@ -3956,10 +3958,14 @@ App::get('/v1/databases/usage')
|
||||
'collectionsTotal' => $usage[$metrics[1]]['total'],
|
||||
'documentsTotal' => $usage[$metrics[2]]['total'],
|
||||
'storageTotal' => $usage[$metrics[3]]['total'],
|
||||
'databasesReadsTotal' => $usage[$metrics[4]]['total'],
|
||||
'databasesWritesTotal' => $usage[$metrics[5]]['total'],
|
||||
'databases' => $usage[$metrics[0]]['data'],
|
||||
'collections' => $usage[$metrics[1]]['data'],
|
||||
'documents' => $usage[$metrics[2]]['data'],
|
||||
'storage' => $usage[$metrics[3]]['data'],
|
||||
'databasesReads' => $usage[$metrics[4]]['data'],
|
||||
'databasesWrites' => $usage[$metrics[5]]['data'],
|
||||
]), Response::MODEL_USAGE_DATABASES);
|
||||
});
|
||||
|
||||
@@ -3992,7 +3998,9 @@ App::get('/v1/databases/:databaseId/usage')
|
||||
$metrics = [
|
||||
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_COLLECTIONS),
|
||||
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_DOCUMENTS),
|
||||
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE)
|
||||
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE),
|
||||
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASES_OPERATIONS_READS),
|
||||
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASES_OPERATIONS_WRITES)
|
||||
];
|
||||
|
||||
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
|
||||
@@ -4044,9 +4052,13 @@ App::get('/v1/databases/:databaseId/usage')
|
||||
'collectionsTotal' => $usage[$metrics[0]]['total'],
|
||||
'documentsTotal' => $usage[$metrics[1]]['total'],
|
||||
'storageTotal' => $usage[$metrics[2]]['total'],
|
||||
'databaseReadsTotal' => $usage[$metrics[3]]['total'],
|
||||
'databaseWritesTotal' => $usage[$metrics[4]]['total'],
|
||||
'collections' => $usage[$metrics[0]]['data'],
|
||||
'documents' => $usage[$metrics[1]]['data'],
|
||||
'storage' => $usage[$metrics[2]]['data'],
|
||||
'databaseReads' => $usage[$metrics[3]]['data'],
|
||||
'databaseWrites' => $usage[$metrics[4]]['data'],
|
||||
]), Response::MODEL_USAGE_DATABASE);
|
||||
});
|
||||
|
||||
|
||||
@@ -50,7 +50,9 @@ App::get('/v1/project/usage')
|
||||
METRIC_FILES_STORAGE,
|
||||
METRIC_DATABASES_STORAGE,
|
||||
METRIC_DEPLOYMENTS_STORAGE,
|
||||
METRIC_BUILDS_STORAGE
|
||||
METRIC_BUILDS_STORAGE,
|
||||
METRIC_DATABASES_OPERATIONS_READS,
|
||||
METRIC_DATABASES_OPERATIONS_WRITES,
|
||||
],
|
||||
'period' => [
|
||||
METRIC_NETWORK_REQUESTS,
|
||||
@@ -60,7 +62,9 @@ App::get('/v1/project/usage')
|
||||
METRIC_EXECUTIONS,
|
||||
METRIC_DATABASES_STORAGE,
|
||||
METRIC_EXECUTIONS_MB_SECONDS,
|
||||
METRIC_BUILDS_MB_SECONDS
|
||||
METRIC_BUILDS_MB_SECONDS,
|
||||
METRIC_DATABASES_OPERATIONS_READS,
|
||||
METRIC_DATABASES_OPERATIONS_WRITES,
|
||||
]
|
||||
];
|
||||
|
||||
@@ -336,10 +340,12 @@ App::get('/v1/project/usage')
|
||||
'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE],
|
||||
'buildsStorageTotal' => $total[METRIC_BUILDS_STORAGE],
|
||||
'deploymentsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE],
|
||||
'databasesReadsTotal' => $total[METRIC_DATABASES_OPERATIONS_READS],
|
||||
'databasesWritesTotal' => $total[METRIC_DATABASES_OPERATIONS_WRITES],
|
||||
'executionsBreakdown' => $executionsBreakdown,
|
||||
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
|
||||
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
|
||||
'bucketsBreakdown' => $bucketsBreakdown,
|
||||
'databasesReads' => $usage[METRIC_DATABASES_OPERATIONS_READS],
|
||||
'databasesWrites' => $usage[METRIC_DATABASES_OPERATIONS_WRITES],
|
||||
'databasesStorageBreakdown' => $databasesStorageBreakdown,
|
||||
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
|
||||
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
|
||||
|
||||
@@ -34,6 +34,18 @@ class UsageDatabase extends Model
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databaseReadsTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total number of databases reads.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databaseWritesTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total number of databases writes.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('collections', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of collections per period.',
|
||||
@@ -55,6 +67,18 @@ class UsageDatabase extends Model
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('databaseReads', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'An array of aggregated number of database reads.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databaseWrites', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'An array of aggregated number of database writes.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,18 @@ class UsageDatabases extends Model
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databasesReadsTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total number of databases reads.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databasesWritesTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total number of databases writes.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databases', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of databases per period.',
|
||||
@@ -68,6 +80,18 @@ class UsageDatabases extends Model
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('databasesReads', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'An array of aggregated number of database reads.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databasesWrites', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'An array of aggregated number of database writes.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,18 @@ class UsageProject extends Model
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databasesReadsTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total number of databases reads.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databasesWritesTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total number of databases writes.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('requests', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of requests per period.',
|
||||
@@ -171,6 +183,18 @@ class UsageProject extends Model
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('databasesReads', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'An array of aggregated number of database reads.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('databasesWrites', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'An array of aggregated number of database writes.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user