CastawayLabs / cachet-monitor

Distributed monitoring plugin for CachetHQ
https://castawaylabs.github.io/cachet-monitor/
MIT License
439 stars 127 forks source link

Metric is empty #110

Open lpossamai opened 5 years ago

lpossamai commented 5 years ago

Hi.

I am getting an error when trying to use cachet-monitor. The metric is not being updated, even though the check works.

my config file:

{
  "api": {
    "url": "http://status.example.com/api/v1",
    "token": "HIDDEN",
    "insecure": true
  },
  "date_format": "02/01/2006 15:04:05 MST",
  "monitors": [
    {
      "name": "api",
      "target": "https://api.example.com/api/v1/status",
      "strict": true,
      "method": "GET",
      "component_id": 1,
      "metric_id": 1,
      "template": {
        "investigating": {
          "subject": "{{ .Monitor.Name }} - {{ .SystemName }}",
          "message": "{{ .Monitor.Name }} check **failed** (server time: {{ .now }})\n\n{{ .FailReason }}"
        },
        "fixed": {
          "subject": "I HAVE BEEN FIXED"
        }
      },
      "interval": 1,
      "timeout": 1,
      "threshold": 80,
      "headers": {
        "Authorization": "Bearer hidden_token"
      },
      "expected_status_code": 200
    }
  ]
}

Output from cachet-monitor / ./cachet_monitor_linux_amd64 -c /usr/lib/cachet-monitor/config-test.json:

INFO[0000] System: status.datacentre.example.com     
INFO[0000] API: http://status.example.com/api/v1   
INFO[0000] Monitors: 1

INFO[0000] Pinging cachet                               
INFO[0000] Ping OK                                      
INFO[0000] Starting Monitor #0:                         
INFO[0000] Features: 
 - Type: http
 - Name: api
 - Method: GET 
INFO[0001] monitor is up                                 monitor=api time="13/03/2019 03:57:48 UTC"

Cachet error:

Next Illuminate\Database\QueryException: SQLSTATE[42803]: Grouping error: 7 ERROR:  column "metric_points.created_at" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT to_char(metric_points.created_at, 'YYYY-MM-DD HH24:00...
                       ^ (SQL: SELECT to_char(metric_points.created_at, 'YYYY-MM-DD HH24:00') AS key, avg(metric_points.value) AS value FROM metrics INNER JOIN metric_points ON metrics.id = metric_points.metric_id WHERE metrics.id = :metricId AND metric_points.created_at >= (NOW() - INTERVAL '12' HOUR) AND metric_points.created_at <= NOW() GROUP BY to_char(metric_points.created_at, 'HH24:00') ORDER BY to_char(metric_points.created_at, 'HH24:00')) in /var/www/html/cachet_2/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
Stack trace: