Revert "feat(influxdb): introduce official client SDK"
This reverts commit 15522c2cb9
.
This commit is contained in:
parent
15522c2cb9
commit
bf8994fa3a
|
@ -193,7 +193,6 @@ App::get('/v1/functions/:functionId/usage')
|
|||
],
|
||||
];
|
||||
|
||||
/** @var InfluxDB2\Client $client */
|
||||
$client = $register->get('influxdb');
|
||||
|
||||
$executions = [];
|
||||
|
@ -203,12 +202,13 @@ App::get('/v1/functions/:functionId/usage')
|
|||
if ($client) {
|
||||
$start = $period[$range]['start']->format(DateTime::RFC3339);
|
||||
$end = $period[$range]['end']->format(DateTime::RFC3339);
|
||||
$database = $client->createQueryApi();
|
||||
$database = $client->selectDB('telegraf');
|
||||
|
||||
// Executions
|
||||
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)');
|
||||
$points = $result->getPoints();
|
||||
|
||||
foreach ($result as $point) {
|
||||
foreach ($points as $point) {
|
||||
$executions[] = [
|
||||
'value' => (!empty($point['value'])) ? $point['value'] : 0,
|
||||
'date' => \strtotime($point['time']),
|
||||
|
@ -217,8 +217,9 @@ App::get('/v1/functions/:functionId/usage')
|
|||
|
||||
// Failures
|
||||
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' AND "functionStatus"=\'failed\' GROUP BY time('.$period[$range]['group'].') FILL(null)');
|
||||
$points = $result->getPoints();
|
||||
|
||||
foreach ($result as $point) {
|
||||
foreach ($points as $point) {
|
||||
$failures[] = [
|
||||
'value' => (!empty($point['value'])) ? $point['value'] : 0,
|
||||
'date' => \strtotime($point['time']),
|
||||
|
@ -227,8 +228,9 @@ App::get('/v1/functions/:functionId/usage')
|
|||
|
||||
// Compute
|
||||
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_time" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)');
|
||||
$points = $result->getPoints();
|
||||
|
||||
foreach ($result as $point) {
|
||||
foreach ($points as $point) {
|
||||
$compute[] = [
|
||||
'value' => round((!empty($point['value'])) ? $point['value'] / 1000 : 0, 2), // minutes
|
||||
'date' => \strtotime($point['time']),
|
||||
|
|
|
@ -206,7 +206,6 @@ App::get('/v1/projects/:projectId/usage')
|
|||
],
|
||||
];
|
||||
|
||||
/** @var InfluxDB2\Client $client */
|
||||
$client = $register->get('influxdb');
|
||||
|
||||
$requests = [];
|
||||
|
@ -216,12 +215,13 @@ App::get('/v1/projects/:projectId/usage')
|
|||
if ($client) {
|
||||
$start = $period[$range]['start']->format(DateTime::RFC3339);
|
||||
$end = $period[$range]['end']->format(DateTime::RFC3339);
|
||||
$database = $client->createQueryApi();
|
||||
$database = $client->selectDB('telegraf');
|
||||
|
||||
// Requests
|
||||
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)');
|
||||
$points = $result->getPoints();
|
||||
|
||||
foreach ($result as $point) {
|
||||
foreach ($points as $point) {
|
||||
$requests[] = [
|
||||
'value' => (!empty($point['value'])) ? $point['value'] : 0,
|
||||
'date' => \strtotime($point['time']),
|
||||
|
@ -230,8 +230,9 @@ App::get('/v1/projects/:projectId/usage')
|
|||
|
||||
// Network
|
||||
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)');
|
||||
$points = $result->getPoints();
|
||||
|
||||
foreach ($result as $point) {
|
||||
foreach ($points as $point) {
|
||||
$network[] = [
|
||||
'value' => (!empty($point['value'])) ? $point['value'] : 0,
|
||||
'date' => \strtotime($point['time']),
|
||||
|
@ -240,8 +241,9 @@ App::get('/v1/projects/:projectId/usage')
|
|||
|
||||
// Functions
|
||||
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)');
|
||||
$points = $result->getPoints();
|
||||
|
||||
foreach ($result as $point) {
|
||||
foreach ($points as $point) {
|
||||
$functions[] = [
|
||||
'value' => (!empty($point['value'])) ? $point['value'] : 0,
|
||||
'date' => \strtotime($point['time']),
|
||||
|
|
11
app/init.php
11
app/init.php
|
@ -170,12 +170,7 @@ $register->set('influxdb', function () { // Register DB connection
|
|||
return;
|
||||
}
|
||||
|
||||
$client = new InfluxDB2\Client([
|
||||
'url' => "http://{$host}:{$port}",
|
||||
'bucket' => 'telegraf/autogen',
|
||||
'timeout' => 5,
|
||||
'verifySSL' => false
|
||||
]);
|
||||
$client = new InfluxDB\Client($host, $port, '', '', false, false, 5);
|
||||
|
||||
return $client;
|
||||
});
|
||||
|
@ -195,10 +190,10 @@ $register->set('cache', function () { // Register cache connection
|
|||
$pass = App::getEnv('_APP_REDIS_PASS','');
|
||||
$auth = [];
|
||||
if(!empty($user)) {
|
||||
$auth['user'] = $user;
|
||||
$auth["user"] = $user;
|
||||
}
|
||||
if(!empty($pass)) {
|
||||
$auth['pass'] = $pass;
|
||||
$auth["pass"] = $pass;
|
||||
}
|
||||
if(!empty($auth)) {
|
||||
$redis->auth($auth);
|
||||
|
|
|
@ -55,11 +55,11 @@
|
|||
"resque/php-resque": "1.3.6",
|
||||
"matomo/device-detector": "4.2.2",
|
||||
"dragonmantank/cron-expression": "3.1.0",
|
||||
"influxdb/influxdb-php": "1.15.2",
|
||||
"phpmailer/phpmailer": "6.4.0",
|
||||
"chillerlan/php-qrcode": "4.3.0",
|
||||
"adhocore/jwt": "1.1.2",
|
||||
"slickdeals/statsd": "3.0.2",
|
||||
"influxdata/influxdb-client-php": "^1.12"
|
||||
"slickdeals/statsd": "3.0.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"appwrite/sdk-generator": "dev-feat-preps-for-0.8",
|
||||
|
|
48
composer.lock
generated
48
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "ea8c94c961eb9a64a93d87114fbc74cc",
|
||||
"content-hash": "32ceddda707fb8f625f84eec08dc3871",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
@ -647,52 +647,6 @@
|
|||
},
|
||||
"time": "2021-04-26T09:17:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "influxdata/influxdb-client-php",
|
||||
"version": "1.12.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/influxdata/influxdb-client-php.git",
|
||||
"reference": "e04f802a4d9c52b5b497077673269e8463fdb6ea"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/influxdata/influxdb-client-php/zipball/e04f802a4d9c52b5b497077673269e8463fdb6ea",
|
||||
"reference": "e04f802a4d9c52b5b497077673269e8463fdb6ea",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"guzzlehttp/guzzle": "^6.2|^7.0.1",
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.4|^9.1",
|
||||
"squizlabs/php_codesniffer": "~2.6"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"InfluxDB2\\": "src/InfluxDB2"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "InfluxDB (v2+) Client Library for PHP",
|
||||
"homepage": "https://www.github.com/influxdata/influxdb-client-php",
|
||||
"keywords": [
|
||||
"influxdb"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/influxdata/influxdb-client-php/issues",
|
||||
"source": "https://github.com/influxdata/influxdb-client-php/tree/1.12.0"
|
||||
},
|
||||
"time": "2021-04-01T06:28:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "influxdb/influxdb-php",
|
||||
"version": "1.15.2",
|
||||
|
|
Loading…
Reference in a new issue