Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

fetching check history via /results and /events switched datatype #1946

Open
MattMulhern opened this issue Feb 27, 2019 · 0 comments
Open

fetching check history via /results and /events switched datatype #1946

MattMulhern opened this issue Feb 27, 2019 · 0 comments

Comments

@MattMulhern
Copy link

When I hit /results for the current status of a check with the api, the history of the last few checks can be seen as expected as a list of int's:

$ curl http://test-sensu-instance/results

[
  {
    "client": "testclient.net",
    "check": {
      "thresholds": {
        "warning": 120,
        "critical": 180
      },
      "name": "keepalive",
      "issued": 1551287799,
      "executed": 1551287799,
      "output": "No keepalive sent from client for 1599 seconds (>=180)",
      "status": 2,
      "type": "standard",
      "history": [
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2,
        2
      ]
    }
  }
]

What I would have expected was this checks data would match what is provided with the /events api and it mainly is, with one notable exception. The history array is switched to a list of strings:

$ curl http://test-sensu-instance/events
[
  {
    "id": "f78b9b80-bdb1-41f7-a389-9542487c3b1d",
    "client": {
      "name": "testclient.net",
      "address": "xxx.xxx.xxx.xxx",
      "subscriptions": [
        "client:testclient.net"
      ],
      "redact": [],
      "socket": {
        "bind": "127.0.0.1",
        "port": 3030
      },
      "safe_mode": false,
      "keepalive": {},
      "version": "1.4.2",
      "timestamp": 1551286200
    },
    "check": {
      "thresholds": {
        "warning": 120,
        "critical": 180
      },
      "name": "keepalive",
      "issued": 1551287709,
      "executed": 1551287709,
      "output": "No keepalive sent from client for 1509 seconds (>=180)",
      "status": 2,
      "type": "standard",
      "history": [
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2",
        "2"
      ],
      "total_state_change": 0
    },
    "occurrences": 45,
    "occurrences_watermark": 45,
    "last_ok": 1551286299,
    "action": "create",
    "timestamp": 1551287709,
    "last_state_change": 1551286389,
    "silenced": false,
    "silenced_by": []
  }
]

Expected Behavior

The datatypes returned for history from /results and /events should match.

Current Behavior

As described above, different datatypes are shown for check history

Steps to Reproduce (for bugs)

  1. hit /events for any event with history
  2. hit /results and look up that same check

Context

Discovered while writing a go application talking to sensu. The json lib failed to unmarshal responses where the same struct was used for both endpoints.

Your Environment

  • Sensu version used: 1.4.2
  • Operating System and version: CentOS 7
  • RabbitMQ version: 3.6.9-1
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant