stephanediondev / elasticsearch-admin

Web administration for Elasticsearch (2.x to 8.x): cluster, nodes, indices, shards, index templates, repositories, snapshots ...
https://stephanediondev.github.io/elasticsearch-admin/
MIT License
92 stars 10 forks source link

Internal Server Error for subscriptions #71

Closed marcopolomercader closed 1 year ago

marcopolomercader commented 1 year ago

Hellooo, first of all what a nice tool! Really awesome and helpful, also not deprecated as many others... important! :joy:. I'm having some issues that I would love to solve for production. I'm using last version available (9 Sept. 2023) from Docker, and using DockerHub for testing.

When trying to access the subscriptions tab:

Internal Server Error
The controller for URI "/admin/subscriptions" is not callable: Environment variable not found: "MAILER_DSN".

File: /var/www/html/vendor/symfony/http-kernel/Controller/ControllerResolver.php
Line: 76
Route: app_subscriptions
Installation type: docker
PHP version: 8.2.10
Symfony version: 6.3.4
Elasticsearch version: 8.10.0
Browser: Chrome 116.0
OS: Windows 10

This is the same error but from the logs: {"message":"Uncaught PHP Exception InvalidArgumentException: \"The controller for URI \"/admin/subscriptions\" is not callable: Environment variable not found: \"MAILER_DSN\".\" at /var/www/html/vendor/symfony/http-kernel/Controller/ControllerResolver.php line 76","context":{"exception":{"class":"InvalidArgumentException","message":"The controller for URI \"/admin/subscriptions\" is not callable: Environment variable not found: \"MAILER_DSN\".","code":0,"file":"/var/www/html/vendor/symfony/http-kernel/Controller/ControllerResolver.php:76","previous":{"class":"Symfony\\Component\\DependencyInjection\\Exception\\EnvNotFoundException","message":"Environment variable not found: \"MAILER_DSN\".","code":0,"file":"/var/www/html/vendor/symfony/dependency-injection/EnvVarProcessor.php:193"}}},"level":500,"level_name":"CRITICAL","channel":"request","datetime":"2023-09-20T12:54:57.472467+00:00","extra":{}}

Also, when accessing to Notifications tab(/admin/app-notifications) doesn't show nothing. Maybe related to the previous error. There's some other tabs that throw an Internal Server Error such as Snapshots tab (/admin/snapshots), but in this case, personally I don't really need it.

Is this errors from my testing environment or is an application related error? Thanks for help, appreciate it

stephanediondev commented 1 year ago

Hi

Sorry I don't have considered the subscriptions with Docker

First thing todo:

Add 2 environment variables. But you need a SMTP server with credentials (or there is a service like sendmail to add in the container)

MAILER_DSN=smtp://user:password@host:port/?encryption=ssl
SENDER_ADDRESS=example@example.com

Then you need to set the cron script: here I can improve and add the command automatically on container creation

crontab -e
# m h dom mon dow command
*/5 * * * * cd /var/www/html && bin/console app:send-notifications

In /admin/app-notifications you will have the history with all the notifications sent

image image
stephanediondev commented 1 year ago

After some tests, it's difficult for me to have cron running in container, I don't have enough experience with Docker

marcopolomercader commented 1 year ago

Thank you for the quick response. It was nearly impossible for me to run the notifications without getting an error. When forcing to send notifications with app:send-notifications shows the next error:

{"message":"Error thrown while running command \"app:send-notifications\". Message: \"[VAPID] Public key should be 65 bytes long when decoded.\"","context":{"exception":{"class":"ErrorException","message":"[VAPID] Public key should be 65 bytes long when decoded.","code":0,"file":"/var/www/html/vendor/minishlink/web-push/src/VAPID.php:67"},"command":"app:send-notifications","message":"[VAPID] Public key should be 65 bytes long when decoded."},"level":500,"level_name":"CRITICAL","channel":"console","datetime":"2023-09-25T13:49:27.246719+00:00","extra":{}}
13:49:27 CRITICAL  [console] Error thrown while running command "app:send-notifications". Message: "[VAPID] Public key should be 65 bytes long when decoded." ["exception" => ErrorException { …},"command" => "app:send-notifications","message" => "[VAPID] Public key should be 65 bytes long when decoded."]
{"message":"Command \"app:send-notifications\" exited with code \"1\"","context":{"command":"app:send-notifications","code":1},"level":100,"level_name":"DEBUG","channel":"console","datetime":"2023-09-25T13:49:27.267825+00:00","extra":{}}

In VAPID.php line 67:

  [VAPID] Public key should be 65 bytes long when decoded.  

app:send-notifications

Maybe I have a bad understanding of how this app works, but those things and also the /admin/cluster/audit path got errors. Maybe is better to do a dedicated instllation for the app and not using docker images? Whats your suggestion?

Internal Server Error
App\Model\ElasticsearchRepositoryModel::setName(): Argument #1 ($name) must be of type ?string, int given, called in /var/www/html/src/Model/ElasticsearchRepositoryModel.php on line 180

File: /var/www/html/src/Model/ElasticsearchRepositoryModel.php
Line: 86
Route: cluster_audit
Installation type: docker
PHP version: 8.2.10
Symfony version: 6.3.4
Elasticsearch version: 8.10.0
Browser: Chrome 116.0
OS: Windows 10

Also, a suggestion for the app is to have the ability to show different clusters without have multiple installations of the app. Thanks for the help in advance.

stephanediondev commented 1 year ago

Hi

About the notifications, you need also to set the environment variables VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEY. There is a command to generate the values bin/console app:generate-vapid This is required for the Push API.

The errors related to snapshots and repositories are not due to your Docker installation. This project is very confidential, not a lot of users. I tried to cover multiple ES versions, but still you can have surprises.

I think you have a repository with a number as name. And when ES returns the JSON, the repository key is an integer instead of a string. And some functions in the application were defined to have a string for the name.

See "123" as key for the repository name

image

I made a new release to fix that (convert to string).

I think the only challenge with Docker is to have the nofications working.

marcopolomercader commented 1 year ago

Hey! Thank you very much for that release.

It was impossible for me to make the notifications working due to the crontab thing. Doesn't care because I already made the notifications through prometheus.

The application is awesome and really helpful. As a suggestions the app could have the ability to list multiple clusters like Cerebro, whenever I need, not all at the same time because, In our case, we have multiple elastic clusters for different purposes. All in all, it's an amazing application. Also, really fast answer. 😉