Format of event.check.history in Sensu Go

In the sensu-go event documentation, it gives examples like this:

"history": [
  {
    "executed": 1522100315
  },
  {
    "executed": 1522100915
  }
],

and

"history": [
  {
    "status": 1,
    "executed": 1542667666
  }
],

Note that the first example shows only timestamps, without any status values, but the second includes status.

The documentation for checks doesn’t mention history at all.

The events documentation for original Sensu is clearer, and states that the last 21 exit status codes are returned in history, but these are shown without timestamps:

"history": [0,0,0,0,0,0,1,2,2,0,0,0,0,0,0,0,0,0,0,0,0]

Can someone please clarify:

  1. Are the event formats in Sensu and Sensu Go different?
  2. How much event history does Sensu Go return? Is it the last 21 events, like Sensu?
  3. Is the documentation example showing “executed” but not “status” correct? If so, what does that mean - that the status was zero? That the status could not be determined? Something else?

Thanks!

This data structure is also documented in their API documentation:
https://docs.sensu.io/sensu-go/5.3/api/events/#eventsentitycheck-get-specification

It looks like a documentation bug.

1 Like

Thanks for the pointer. I see that link says:

querying the /events/:entity API returns a list of Sensu events for the sensu-go-sandbox entity

The example shows history with both status and executed.

But it doesn’t say how many events are returned in the list. Nor does it say how many history members are returned for each event. I think it would be very helpful to have such things documented, otherwise you have to find out by experiment or reading the source code.

1 Like

Hi @candlerb

I just sent a pull request to add documentation around those attributes.

But to answer your questions:

  1. Yes, the event format is a bit different in Sensu Go. Here’s an example of an event payload in Sensu Go: https://docs.sensu.io/sensu-go/5.3/reference/events/#example-check-only-event-data
  2. Yes, the last 21 events like in Sensu Core.
  3. This example was taken from an older Sensu Go version, where the JSON encoder would discard attributes using their default values (0 in the case of integer values). This has been fixed now and the documentation will be adjusted in consequence, but in this example it simply means the status is 0.

Let us know if you have any other questions!

2 Likes