alerta / docker-alerta

Run alerta in a docker container
https://hub.docker.com/r/alerta/alerta-web
MIT License
155 stars 137 forks source link

Error: failed to retrieve client config from Alerta API endpoint /api/ config #438

Closed PowerSurj closed 1 year ago

PowerSurj commented 1 year ago

Issue Summary Users get a pop-up error during login This issue has always been present ever since implementation

alerta.mydomain.com

Error: failed to retrieve client config from Alerta API endpoint /api/ config
This could be due to the API not being available, or to a missing or invalid config.json file exists, contains an "endpoint" setting and is in the same directory as the application index.html file.

Checking alerta nginx logs, i can see GET requests to /api/config return with code 200 https://alerta.mydomain.com/api/config i can access the config file via WEB UI with no errors

Environment

Helm values.yaml

alertaConfig:
  AUTH_REQUIRED: "True"
  CUSTOMER_VIEWS: "True"
  # audit log
  AUDIT_LOG: "True"
  AUDIT_TRAIL: "['admin','write','auth']"
  # plug-in settings
  ORIGIN_BLACKLIST: "['not-set']"
  ALLOWED_ENVIRONMENTS: "['prod','uat','test']"
  BLACKOUT_ACCEPT: "['normal','ok','cleared']"
  # webhook settings
  DEFAULT_ENVIRONMENT: "'prod'"
  # timeout settings
  ALERT_TIMEOUT: "604800"
  # web ui settings
  COLUMNS: "['severity','status','lastReceiveTime','environment','service','resource','event','value','text']"

AUTH_PROVIDER: azure

env:
  - name: DEBUG
    value: "1"
  - name: AUTH_REQUIRED
    value: "True"
  - name: AUTH_PROVIDER
    value: "azure"
  - name: CUSTOMER_VIEWS
    value: "True"

and the /web/config files

$ cat /web/config.json.example
{"endpoint": "http://localhost:8080"}

$ cat /web/config.json
{"endpoint": "/api"}

$ cat /web/config.json.j2
{"endpoint": "/api"}

content of the /web directory

$ ls -la /web
total 408
drwxrwxr-x 1 root   root   4096 Jun 16 04:58 .
drwxr-xr-x 1 root   root   4096 Jun 16 04:58 ..
-rw-rw-r-- 1 alerta root    197 Dec  6  2021 404.html
-rw-rw-r-- 1 alerta root     14 Dec  6  2021 CNAME
-rw-rw-r-- 1 alerta root   7612 Dec  6  2021 apple-touch-icon-114x114.png
-rw-rw-r-- 1 alerta root   5136 Dec  6  2021 apple-touch-icon-120x120.png
-rw-rw-r-- 1 alerta root   4768 Dec  6  2021 apple-touch-icon-144x144.png
-rw-rw-r-- 1 alerta root   8361 Dec  6  2021 apple-touch-icon-152x152.png
-rw-rw-r-- 1 alerta root   1796 Dec  6  2021 apple-touch-icon-57x57.png
-rw-rw-r-- 1 alerta root   1800 Dec  6  2021 apple-touch-icon-60x60.png
-rw-rw-r-- 1 alerta root   1795 Dec  6  2021 apple-touch-icon-72x72.png
-rw-rw-r-- 1 alerta root   2992 Dec  6  2021 apple-touch-icon-76x76.png
drwxrwxr-x 1 alerta root   4096 Dec  6  2021 audio
-rw-r--r-- 1 alerta root     21 Jun 16 04:58 config.json
-rw-rw-r-- 1 alerta root     38 Dec  6  2021 config.json.example
-rw-rw-r-- 1 root   root     21 Dec  6  2021 config.json.j2
drwxrwxr-x 1 alerta root   4096 Dec  6  2021 css
-rw-rw-r-- 1 alerta root   1186 Dec  6  2021 favicon-128.png
-rw-rw-r-- 1 alerta root    241 Dec  6  2021 favicon-16x16.png
-rw-rw-r-- 1 alerta root  14155 Dec  6  2021 favicon-196x196.png
-rw-rw-r-- 1 alerta root    319 Dec  6  2021 favicon-32x32.png
-rw-rw-r-- 1 alerta root   1597 Dec  6  2021 favicon-96x96.png
-rw-rw-r-- 1 alerta root  34494 Dec  6  2021 favicon.ico
drwxrwxr-x 1 alerta root   4096 Dec  6  2021 fonts
-rw-rw-r-- 1 alerta root   3588 Dec  6  2021 index.html
drwxrwxr-x 1 alerta root   4096 Dec  6  2021 js
-rw-rw-r-- 1 alerta root   4768 Dec  6  2021 mstile-144x144.png
-rw-rw-r-- 1 alerta root  35835 Dec  6  2021 mstile-150x150.png
-rw-rw-r-- 1 alerta root  57463 Dec  6  2021 mstile-310x150.png
-rw-rw-r-- 1 alerta root 131257 Dec  6  2021 mstile-310x310.png
-rw-rw-r-- 1 alerta root   1186 Dec  6  2021 mstile-70x70.png

To Reproduce Logging into Alerta WEB UI with Azure AD authentication enabled.

Expected behavior No error pops-up

satterly commented 1 year ago

Github issues is not the best place to resolve problems like this. Issues should be raised for bugs or feature requests, not configuration problems. Please use Slack from now on. Thanks.

roens commented 4 months ago

Yet, when someone opens a GitHub issue like this, other folks who have faced similar trouble end up here seeking similar ideas or even solutions. But when the discussion is sequestered away to a space requiring authentication, any outcome(s) get locked away.

I'm also attempting to get Alerta running as a container, and also face this ERROR: Failed to retrieve client config from Alerta API endpoint /api/config. message on an otherwise blank page loading, starting only with example env vars from the project's own documentation.

hyberdk commented 1 month ago

I have not (yet) been running it in k8s, but I have been running it a while in docker where each feature has its own container (api, ui, db, housekeeping)..

for it to work for me I had to set the BASE_URL to the full url, not relative.

eg: BASE_URL='https://alerta.domain.tld:8443/api'

my config.json then looks like this:

{"endpoint": "/api"}

currently I use nginx (in docker) as the frontend. here is my config template using envsubst '$$HTTP_PORT $$HTTPS_PORT $$SERVER_NAME' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf to generate the config..

worker_processes 1;
pid /tmp/nginx.pid;

daemon off;

events {
        worker_connections 1024;
}

http {

        client_body_temp_path /tmp/client_body;
        fastcgi_temp_path /tmp/fastcgi_temp;
        proxy_temp_path /tmp/proxy_temp;
        scgi_temp_path /tmp/scgi_temp;
        uwsgi_temp_path /tmp/uwsgi_temp;

        include /etc/nginx/mime.types;

        server_tokens off;
        error_log /dev/stdout 'warn';
        access_log /dev/stdout;

        gzip on;
        gzip_disable "msie6";

        log_format main '$remote_addr - $remote_user [$time_local] '
                        '"$request" $status $body_bytes_sent '
                        '"$http_referer" "$http_user_agent" - $request_time '
                        'x_forwarded_for=$http_x_forwarded_for host=$host '
                        '$request_id $sent_http_x_request_id';

        default_type application/octet-stream;

        server {
                listen ${HTTP_PORT} default_server;
                server_name ${SERVER_NAME};
                return 301 https://$host:${HTTPS_PORT}$request_uri;
                }

        server {

                listen              ${HTTPS_PORT} ssl default_server;
                server_name         ${SERVER_NAME};
                ssl_certificate     /etc/nginx/certs/public.cer;
                ssl_certificate_key /etc/nginx/certs/private.key;
                ssl_protocols       TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
                ssl_ciphers         HIGH:!aNULL:!MD5;
                # listen 80 default_server;

                access_log /dev/stdout main;
                client_max_body_size 10M;

                location /api {
                        # include /etc/nginx/uwsgi_params;
                        proxy_pass http://alerta-api:8080/;

                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $remote_addr;
                        # proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
                }

                root /web;
                index index.html;
                location / {
                        try_files $uri $uri/ /index.html;
                }
        }
}

hope that helps.