Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Examining Check History Status to Sensu Query Expressions examples #4207

Open
1 of 4 tasks
jhenderson-pro opened this issue Jun 6, 2023 · 0 comments
Open
1 of 4 tasks
Assignees
Labels
improvement Improves docs content

Comments

@jhenderson-pro
Copy link
Contributor

Description

Category

This is an issue with:

  • errata (error in doc content)
  • new doc (requires a completely new doc)
  • update (add missing or refresh existing content)
  • improvement (improve docs content or format)

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 as true.

@jhenderson-pro jhenderson-pro self-assigned this Jun 6, 2023
@jhenderson-pro jhenderson-pro added the improvement Improves docs content label Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improves docs content
Projects
None yet
Development

No branches or pull requests

1 participant