Logs not included in Logrotate

Continuing the discussion from Queue Stats Logs:

Greetings, after installing Sonata Stats, the logs in /usr/share/sonata/queues-stats/backend/storage/logs/ are growing at 300 mb per day… I’ve looked through logrotate and don’t see anything that will keep these logs from filling up the hard drive endlessly…

Is there a log rotate setting for these logs that I’m missing? If not, I would like to add a logrotate setting. Can someone help me with this so I don’t have to monitor these logs and have to manually delete them?

Hello,

If you don’t want log files to be created you can do the following:

edit the file located at /usr/share/sonata/queues-stats/backend/config/logging.php, on line 52 replace ‘level’ => ‘debug’ to '‘level’ => ‘critical’

from this location /usr/share/sonata/queues-stats/backend/ execute this command php artisan config:cache and then systemctl restart sonata-stats

Hi Roger thanks for the info… I tried to edit this php file but it seems to be encrypted with ioncube. What should I do? I’m not familiar with this or how to decode it.

Also, wondering if I wanted to keep it on debug level couldn’t we add an entry to logrotate for this? Right now each day a new log file is create in sequential order named laravel-2022-09-15.log - they are 250 mb each file… so there is a setting somewhere that forces the new log when it reaches to 250… is there an entry where I could add “rotate 4”. I don’t see this file path anywhere in the logrotate files…

How are other users handling this? Is everyone who installed queues stats needing to make this manual change so their hard drives don’t fill up?

1 Like

A log file entry will be created when an error is found, please share one of those for analysis.

There’s no logrotate entry for sonata stats at the moment.

You can copy the attached logging configuration file and change the extension to .php
logging.txt (2.8 KB)

looks like the same entry again and again, can this be fixed?

[previous exception] [object] (PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user ‘stats’@‘localhost’ (using password: NO) at /usr/share/sonata/queues-stats/backend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)
[stacktrace]
#0 /usr/share/sonata/queues-stats/backend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(27): PDO->__construct(‘mysql:host=127…’, ‘stats’, ‘’, Array)
#1 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(67): Doctrine\DBAL\Driver\PDOConnection->__construct(‘mysql:host=127…’, ‘stats’, ‘’, Array)
#2 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection(‘mysql:host=127…’, ‘stats’, ‘’, Array)
#3 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection(‘mysql:host=127…’, Array, Array)
#4 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(182): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#5 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()
#6 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Database/Connection.php(924): call_user_func(Object(Closure))
#7 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(123): Illuminate\Database\Connection->getPdo()
#8 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(105): Illuminate\Database\Connection->createTransaction()
#9 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(23): Illuminate\Database\Connection->beginTransaction()
#10 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Queue/DatabaseQueue.php(203): Illuminate\Database\Connection->transaction(Object(Closure))
#11 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(284): Illuminate\Queue\DatabaseQueue->pop(‘default’)
#12 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(123): Illuminate\Queue\Worker->getNextJob(Object(Illuminate\Queue\DatabaseQueue), ‘default’)
#13 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112): Illuminate\Queue\Worker->daemon(‘database’, ‘default’, Object(Illuminate\Queue\WorkerOptions))
#14 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96): Illuminate\Queue\Console\WorkCommand->runWorker(‘database’, ‘default’)
#15 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#16 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#17 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#18 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#19 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#20 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#21 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\Container\Container->call(Array)
#22 /usr/share/sonata/queues-stats/backend/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#23 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#24 /usr/share/sonata/queues-stats/backend/vendor/symfony/console/Application.php(1009): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /usr/share/sonata/queues-stats/backend/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /usr/share/sonata/queues-stats/backend/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /usr/share/sonata/queues-stats/backend/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 /usr/share/sonata/queues-stats/backend/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 {main}

…about the php file, i’m just to copy this new file over the encrypted one? It doesn’t have to be encrypted?

then after I have to follow the same instructions:

from this location /usr/share/sonata/queues-stats/backend/ execute this command php artisan config:cache and then systemctl restart sonata-stats

Thanks we’ll analyse the log file, yes you can just copy the logging configuration file

Please check the contents of this file /usr/share/sonata/queues-stats/backend/.env, look for this configuration DB_HOST=localhost if you see that change it to this DB_HOST=127.0.0.1 then execute this commands php artisan config:cache and systemctl restart sonata-stats

DB_HOST is already set to 127.0.0.1. This is the content of that file below… is that APP_NAME correct? I deleted out the keys and secrets as I wasn’t sure if that should be shown for a forum post.

APP_NAME=Relatórios
APP_ENV=production
APP_KEY=base64:***********************************
APP_DEBUG=false
APP_URL=

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sonata_stats
DB_USERNAME=stats
DB_PASSWORD=*************************************

DB_ASTERISK_HOST=127.0.0.1
DB_ASTERISK_PORT=3306
DB_ASTERISK_DATABASE=asterisk
DB_ASTERISK_USERNAME=stats
DB_ASTERISK_PASSWORD=*********************************

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
MAIL_BCC_EMAIL=

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY=“${PUSHER_APP_KEY}”
MIX_PUSHER_APP_CLUSTER=“${PUSHER_APP_CLUSTER}”

MEMORY_LIMIT=128

PBX_APP_KEY=******************************************************************************************************************************************
PBX_HOST=localhost
PBX_PORT=443
PBX_SECURE=1

INITIAL_PERIOD=10
MAX_PERIOD=60
INTERVAL=10
CALL_WAIT_LIMIT=
CALL_TALK_LIMIT=
MAX_SESSION_ALLOWED=
MAX_PAUSE_ALLOWED=

JWT_SECRET=************************************************************************

Try the following commands

  • mysql
  • create user if not exists ‘stats’@‘localhost’;
  • set password for ‘stats’@‘localhost’ = password(‘typeapasswordhere’);
  • grant all privileges on sonata_stats.* to ‘stats’@‘localhost’;
  • grant select on asterisk.queues_log to ‘stats’@‘localhost’;
  • grant select on asterisk.cdr to ‘stats’@‘localhost’;

on the same .env file change the value of DB_PASSWORD and DB_ASTERISK_PASSWORD for the password you entered and then php artisan config:cache and systemctl restart sonata-stats.

If the issue persists you can contact me at roger@vitalpbx.com so we can access on the server and look at the issue

Hi Roger… I apologize but I’m only just learning linux and any datatbase commands for the first time, so I need a little more detail to do this myself.

I got the prompt for mariadb after typing “mysql” at the bash# prompt which looked like this:

MariaDB [(none)]>

But I didn’t know how to enter each statement at this prompt or how to check if that user existed. If you could provide me a screenshot of these steps showing me the prompt with the command I can do this…

I’m also guessing after adding the passwords to the .env file (which I already know how to use the nano function, then after saving these changes to .env file, at the bash prompt # I would do the following?

[root@vpbx01 russ.greco]# php artisan config:cache
and then
[root@vpbx01 russ.greco]# systemctll restart sonata-stats

Please let me know or I can schedule for you to take a look at the server at your convenience… whatever is easy… thanks!

at the prompt you can copy the commands and press enter to execute and then ctrl-d to exit

you can send me an email between 8am to 5pm central time if you need help

I tried to reply to your email but for some reason is failing, please send your ssh credentials to my email