You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition to evaluating the attributes of the most recent check event, Sensu filters can also examine the history of check results for a given entity. This feature provides an additional layer of flexibility in event processing, allowing you to create filters based on trends or changes over time. In a Sensu filter expression, event.check.history.length refers to the total number of check results stored in the history for a specific event:
This expression leverages JavaScript array indexing to access the second-to-last check result in the history. Let's break it down:
event.check.history: The history array containing a sequence of check results.
event.check.history.length - 2: Accessing the second-to-last check result in the history. Remember, arrays in JavaScript use 0-based indexing. We can access the second-to-last element by finding the array's length and subtracting 2.
.status: Accessing the status field of the check result. This field represents the result of the check: 0 for "OK", 1 for "WARNING", 2 for "CRITICAL", and so on.
!=0: Checking if the status is not equal to 0. If the second-to-last check's status was not "OK", the expression will be evaluated as true.
The text was updated successfully, but these errors were encountered:
Description
Category
This is an issue with:
Affected pages
https://docs.sensu.io/sensu-go/latest/observability-pipeline/observe-filter/sensu-query-expressions/#examples
Proposed Addition
Evaluate check history status
In addition to evaluating the attributes of the most recent check event, Sensu filters can also examine the history of check results for a given entity. This feature provides an additional layer of flexibility in event processing, allowing you to create filters based on trends or changes over time. In a Sensu filter expression,
event.check.history.length
refers to the total number of check results stored in the history for a specific event:event.check.history[event.check.history.length - 2].status != 0
This expression leverages JavaScript array indexing to access the second-to-last check result in the history. Let's break it down:
event.check.history
: The history array containing a sequence of check results.event.check.history.length - 2
: Accessing the second-to-last check result in the history. Remember, arrays in JavaScript use 0-based indexing. We can access the second-to-last element by finding the array's length and subtracting 2..status
: Accessing the status field of the check result. This field represents the result of the check: 0 for "OK", 1 for "WARNING", 2 for "CRITICAL", and so on.!=0
: Checking if the status is not equal to 0. If the second-to-last check's status was not "OK", the expression will be evaluated astrue
.The text was updated successfully, but these errors were encountered: