CastawayLabs / cachet-monitor

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

Cannot parse component body #35

Closed faizshukri closed 7 years ago

faizshukri commented 8 years ago

Cachet v2.2.2 and monitor v2.0

Got this error when it try to fetch component status.

/monitor.go:177: Site creating incident. Monitor is down: Unexpected response code: 502. Expected 200
/incident.go:36: cannot fetch component: Cannot parse component body:
{
    "data":{
        "id":1,
        "name":"API",
        "description":"",
        "link":"",
        "status":"3",
        "order":1,
        "group_id":1,
        "created_at":"2016-04-08 15:07:49",
        "updated_at":"2016-05-20 16:50:25",
        "deleted_at":null,
        "enabled":true,
        "status_name":"Partial Outage",
        "tags":{
            "":""
        }
    }
}
Err = json: cannot unmarshal string into Go value of type int
kholloway commented 8 years ago

Cachet is returning the status in a string and cachet-monitor expects only an integer in the json.

"status":"3"

The proper fix seems to be to fix the return value from Cachet but I can't figure out where exactly that lives in the code.

The other fix is to change the type of data that cachet-monitor expects from the return values in the code below and possibly other places. https://github.com/CastawayLabs/cachet-monitor/blob/master/incident.go#L85-L87

faizshukri commented 8 years ago

I believe this is Cachet issue, since their documentation state that status should be type integer. https://docs.cachethq.io/docs/incidents

kholloway commented 8 years ago

https://github.com/CastawayLabs/cachet-monitor/pull/43

kholloway commented 8 years ago

It's actually the call to check the component status that cachet-monitor makes not the incident API. While the examples show an integer being returned it's not clearly stated that it will always be an integer and currently it's not and int, it's a string.

The original call from cachet-monitor: https://github.com/CastawayLabs/cachet-monitor/blob/master/incident.go#L75

The docs from Cachet site: https://docs.cachethq.io/docs/get-a-component

kholloway commented 8 years ago

I agree though, it should be fixed on the Cachet side I just can't figure out where to fix it.. :) I'm opening an issue on the Cachet repo also just FYI.

Thanks!

kholloway commented 8 years ago

https://github.com/CachetHQ/Cachet/issues/2058

matejkramny commented 7 years ago

Going to close in light of a new release