cachethq / cachet

🚦 The open-source status page system.
https://cachethq.io
MIT License
13.99k stars 1.56k forks source link

500 when getting chart data (docker) #2695

Closed pmajkutewicz closed 6 years ago

pmajkutewicz commented 7 years ago

http http://127.0.0.1:10091/metrics/11?filter=today Response: HTTP/1.1 500 Internal Server Error

But it looks like i have some points: http http://localhost:10091/api/v1/metrics/11/points Response:

HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json
Date: Fri, 25 Aug 2017 13:06:08 GMT
Server: nginx/1.13.0
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Cache: EXPIRED
X-Powered-By: PHP/7.0.16

{
    "data": [
        {
            "calculated_value": 384, 
            "counter": 1, 
            "created_at": "2017-08-25 14:27:55", 
            "id": 32, 
            "metric_id": 11, 
            "updated_at": "2017-08-25 14:27:55", 
            "value": 384
        }, 
        {
            "calculated_value": 696, 
            "counter": 1, 
            "created_at": "2017-08-25 14:28:27", 
            "id": 36, 
            "metric_id": 11, 
            "updated_at": "2017-08-25 14:28:27", 
            "value": 696
        }, 
        {
            "calculated_value": 553, 
            "counter": 1, 
            "created_at": "2017-08-25 14:40:59", 
            "id": 38, 
            "metric_id": 11, 
            "updated_at": "2017-08-25 14:40:59", 
            "value": 553
        }
    ], 
    "meta": {
        "pagination": {
            "count": 3, 
            "current_page": 1, 
            "links": {
                "next_page": null, 
                "previous_page": null
            }, 
            "per_page": 20, 
            "total": 3, 
            "total_pages": 1
        }
    }
}

Metrics configuration: http http://localhost:10091/api/v1/metrics/

HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json
Date: Fri, 25 Aug 2017 13:10:51 GMT
Server: nginx/1.13.0
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Cache: EXPIRED
X-Powered-By: PHP/7.0.16

{
    "data": [
        {
            "calc_type": 1, 
            "created_at": "2017-08-25 14:27:55", 
            "default_value": 0, 
            "default_view": 1, 
            "default_view_name": "Last 12 Hours", 
            "description": "Response time in ms", 
            "display_chart": true, 
            "id": 12, 
            "name": "Sonar", 
            "order": 0, 
            "places": 2, 
            "suffix": "ms", 
            "threshold": 1, 
            "updated_at": "2017-08-25 14:41:28"
        }, 
        {
            "calc_type": 1, 
            "created_at": "2017-08-25 14:27:55", 
            "default_value": 0, 
            "default_view": 0, 
            "default_view_name": "Last Hour", 
            "description": "Response time in ms", 
            "display_chart": true, 
            "id": 11, 
            "name": "Jenkins", 
            "order": 0, 
            "places": 0, 
            "suffix": "ms", 
            "threshold": 2, 
            "updated_at": "2017-08-25 15:04:27"
        }
    ], 
    "meta": {
        "pagination": {
            "count": 2, 
            "current_page": 1, 
            "links": {
                "next_page": null, 
                "previous_page": null
            }, 
            "per_page": 20, 
            "total": 2, 
            "total_pages": 1
        }
    }

Tested with cachethq/docker:2.3.12 and cachethq/docker:latest

jbrooksuk commented 7 years ago

Can you send us your log file please?

pmajkutewicz commented 7 years ago

@jbrooksuk


+ initialize_system
+ echo 'Initializing Cachet container ...'
+ APP_KEY=base64:e3y0DXoJaUuPF6Wqay55R+bTMjKLTA9hpEJodyc3/xE=
+ APP_ENV=development
+ APP_DEBUG=true
+ APP_URL=http://localhost
+ DB_DRIVER=pgsql
+ DB_HOST=postgres
+ DB_DATABASE=postgres
+ DB_PREFIX=chq_
+ DB_USERNAME=postgres
+ DB_PASSWORD=postgres
+ [[ pgsql = \p\g\s\q\l ]]
+ DB_PORT=5432
+ [[ pgsql = \m\y\s\q\l ]]
+ DB_PORT=5432
+ CACHE_DRIVER=apc
+ SESSION_DRIVER=apc
+ QUEUE_DRIVER=database
Initializing Cachet container ...
+ CACHET_EMOJI=false
+ CACHET_BEACON=true
+ CACHET_AUTO_TWITTER=true
+ MAIL_DRIVER=smtp
+ MAIL_HOST=localhost
+ MAIL_PORT=25
+ MAIL_USERNAME=null
+ MAIL_PASSWORD=null
+ MAIL_ADDRESS=null
+ MAIL_NAME=null
+ MAIL_ENCRYPTION=null
+ REDIS_HOST=null
+ REDIS_DATABASE=null
+ REDIS_PORT=null
+ REDIS_PASSWORD=null
+ GITHUB_TOKEN=null
+ NEXMO_KEY=null
+ NEXMO_SECRET=null
+ NEXMO_SMS_FROM=Cachet
+ PHP_MAX_CHILDREN=5
+ [[ base64:e3y0DXoJaUuPF6Wqay55R+bTMjKLTA9hpEJodyc3/xE= == null ]]
+ sed 's,{{APP_KEY}},base64:e3y0DXoJaUuPF6Wqay55R+bTMjKLTA9hpEJodyc3/xE=,g' -i /var/www/html/.env
+ sed 's,{{APP_ENV}},development,g' -i /var/www/html/.env
+ sed 's,{{APP_DEBUG}},true,g' -i /var/www/html/.env
+ sed 's,{{APP_URL}},http://localhost,g' -i /var/www/html/.env
+ sed 's,{{DB_DRIVER}},pgsql,g' -i /var/www/html/.env
+ sed 's,{{DB_HOST}},postgres,g' -i /var/www/html/.env
+ sed 's,{{DB_DATABASE}},postgres,g' -i /var/www/html/.env
+ sed 's,{{DB_PREFIX}},chq_,g' -i /var/www/html/.env
+ sed 's,{{DB_USERNAME}},postgres,g' -i /var/www/html/.env
+ sed 's,{{DB_PASSWORD}},postgres,g' -i /var/www/html/.env
+ sed 's,{{DB_PORT}},5432,g' -i /var/www/html/.env
+ sed 's,{{CACHE_DRIVER}},apc,g' -i /var/www/html/.env
+ sed 's,{{SESSION_DRIVER}},apc,g' -i /var/www/html/.env
+ sed 's,{{QUEUE_DRIVER}},database,g' -i /var/www/html/.env
+ sed 's,{{CACHET_EMOJI}},false,g' -i /var/www/html/.env
+ sed 's,{{CACHET_BEACON}},true,g' -i /var/www/html/.env
+ sed 's,{{CACHET_AUTO_TWITTER}},true,g' -i /var/www/html/.env
+ sed 's,{{MAIL_DRIVER}},smtp,g' -i /var/www/html/.env
+ sed 's,{{MAIL_HOST}},localhost,g' -i /var/www/html/.env
+ sed 's,{{MAIL_PORT}},25,g' -i /var/www/html/.env
+ sed 's,{{MAIL_USERNAME}},null,g' -i /var/www/html/.env
+ sed 's,{{MAIL_PASSWORD}},null,g' -i /var/www/html/.env
+ sed 's,{{MAIL_ADDRESS}},null,g' -i /var/www/html/.env
+ sed 's,{{MAIL_NAME}},null,g' -i /var/www/html/.env
+ sed 's,{{MAIL_ENCRYPTION}},null,g' -i /var/www/html/.env
+ sed 's,{{REDIS_HOST}},null,g' -i /var/www/html/.env
+ sed 's,{{REDIS_DATABASE}},null,g' -i /var/www/html/.env
+ sed 's,{{REDIS_PORT}},null,g' -i /var/www/html/.env
+ sed 's,{{REDIS_PASSWORD}},null,g' -i /var/www/html/.env
+ sed 's,{{GITHUB_TOKEN}},null,g' -i /var/www/html/.env
+ sed 's,{{NEXMO_KEY}},null,g' -i /var/www/html/.env
+ sed 's,{{NEXMO_SECRET}},null,g' -i /var/www/html/.env
+ sed 's,{{NEXMO_SMS_FROM}},Cachet,g' -i /var/www/html/.env
+ sudo sed 's,{{PHP_MAX_CHILDREN}},5,g' -i /etc/php7/php-fpm.d/www.conf
+ rm -rf bootstrap/cache/config.php bootstrap/cache/services.php
+ chmod -R 777 storage
+ check_database_connection
+ echo 'Attempting to connect to database ...'
+ case "${DB_DRIVER}" in
+ prog=/usr/bin/pg_isready
+ prog='/usr/bin/pg_isready -h postgres -p 5432 -U postgres -d postgres -t 1'
+ timeout=60
Attempting to connect to database ...
+ /usr/bin/pg_isready -h postgres -p 5432 -U postgres -d postgres -t 1
+ timeout=59
+ [[ 59 -eq 0 ]]
+ echo -n .
+ sleep 1
+ /usr/bin/pg_isready -h postgres -p 5432 -U postgres -d postgres -t 1
+ echo
+ check_configured
+ case "${DB_DRIVER}" in
+ checkdbinitpsql
+ table=sessions
+ export PGPASSWORD=postgres
+ PGPASSWORD=postgres
.
++ psql -h postgres -p 5432 -U postgres -d postgres -c 'SELECT to_regclass('\''chq_sessions'\'');'
++ grep -c chq_sessions
+ [[ 1 -eq 1 ]]
+ echo 'Table chq_sessions exists! ...'
+ echo 'Starting Cachet! ...'
+ php artisan config:cache
Table chq_sessions exists! ...
Starting Cachet! ...
Configuration cache cleared!
Configuration cached successfully!
+ /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
2017-08-27 06:23:28,437 WARN For [program:queue-worker], AUTO logging used for stderr_logfile without rollover, set maxbytes > 0 to avoid filling up filesystem unintentionally
2017-08-27 06:23:28,439 INFO supervisord started with pid 56
2017-08-27 06:23:29,441 INFO spawned: 'nginx' with pid 59
2017-08-27 06:23:29,442 INFO spawned: 'php-fpm' with pid 60
2017-08-27 06:23:29,442 INFO spawned: 'queue-worker' with pid 61
[27-Aug-2017 06:23:29] NOTICE: fpm is running, pid 60
[27-Aug-2017 06:23:29] NOTICE: ready to handle connections
2017-08-27 06:23:30,488 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2017-08-27 06:23:30,488 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2017-08-27 06:23:30,488 INFO success: queue-worker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2017/08/27 09:54:03 [crit] 62#62: *3 connect() to [::1]:9000 failed (99: Address not available) while connecting to upstream, client: 172.20.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://[::1]:9000", host: "127.0.0.1:10091"
2017/08/27 09:54:03 [warn] 62#62: *3 upstream server temporarily disabled while connecting to upstream, client: 172.20.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://[::1]:9000", host: "127.0.0.1:10091"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET / HTTP/1.1" 200 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET / HTTP/1.1" 200 3631 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET /build/dist/css/all-2812406e36.css HTTP/1.1" 200 125256 "http://127.0.0.1:10091/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET /build/dist/js/all-b2c62d4294.js HTTP/1.1" 200 677211 "http://127.0.0.1:10091/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET /fonts/ionicons.ttf?v=2.0.1 HTTP/1.1" 200 188508 "http://127.0.0.1:10091/build/dist/css/all-2812406e36.css" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET /metrics/11?filter=last_hour HTTP/1.1" 500 3177 "http://127.0.0.1:10091/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET /metrics/12?filter=today HTTP/1.1" 500 3177 "http://127.0.0.1:10091/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET /metrics/16?filter=today HTTP/1.1" 500 3177 "http://127.0.0.1:10091/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET /metrics/15?filter=today HTTP/1.1" 500 3177 "http://127.0.0.1:10091/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET /metrics/17?filter=today HTTP/1.1" 500 3177 "http://127.0.0.1:10091/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"
172.20.0.1 - - [27/Aug/2017:09:54:04 +0000] "GET /img/favicon.png HTTP/1.1" 200 6221 "http://127.0.0.1:10091/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.105 Safari/537.36 Vivaldi/1.92.917.43" "-"```
Diogo-Ferreira commented 7 years ago

I have the same issue, I found this in my logs, maybe it can help you

Next Illuminate\Database\QueryException: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "metric_points" does not exist LINE 1: ..._points.counter) as value FROM chq_metrics m JOIN metric_poi... ^ (SQL: select avg(metric_points.value * metric_points.counter) as value FROM chq_metrics m JOIN metric_points ON metric_points.metric_id = m.id WHERE metric_points.metric_id = :metricId AND to_char(metric_points.created_at, 'YYYYMMDDHH24') = :timeInterval GROUP BY to_char(metric_points.created_at, 'H')) in /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:713 I tried to run migrate, but there's no migration left to do, maybe there's migration missing ?

Diogo-Ferreira commented 7 years ago

I found out what the problem is. The file /var/www/html/app/Repositories/Metric/PgSqlRepository.php (And I think other db implementations too) doesn't handle the DB_PREFIX which is "chq_" by default in the docker image.

@pmajkutewicz A quick way to fix this is to remove the DBPREFIX ( You can remove it from the docker-compose.yml and rebuild it) or to add "chq" to each "metrics_points" strings in that file.

I'll see if I have time to make a PR with a clean fix.

pmajkutewicz commented 7 years ago

@pmajkutewicz A quick way to fix this is to remove the DBPREFIX ( You can remove it from the docker-compose.yml and rebuild it) or to add "chq" to each "metrics_points" strings in that file.

@Diogo-Ferreira Thanks! Works fine.

jbrooksuk commented 6 years ago

Needs opening on https://github.com/CachetHQ/Docker please.