1

I'm using Sensu to see if error log exists in log files with check-log.rb.(https://github.com/sensu-plugins/sensu-plugins-logs/blob/master/bin/check-log.rb)

I think we don't need "OK" notification when it comes to checking error log, so I'd like not to notifiy "OK" when checking log files in Sensu. I know how to do it in Nagios, but cannot find the way in Sensu's document.

Does anyone help me with this?

Thank you in advance.

tsuda7
  • 413
  • 1
  • 6
  • 25

1 Answers1

2

It is quite simple actually. You need to define a filter that removes the OK/resolved messages.

{
  "filters": {
    "resolve": {
      "attributes": {
        "check": {
          "status": 0
        }
      },
     "negate": true
    }
  }
}

Then apply the filter on your handler. If you use the default handler you need to define a new handler with the 'default' name.

If you want some more flexibility you can add

{
  "filters": {
    "resolve": {
      "attributes": {
        "check": {
          "status": 0,
          "filter_resolve": true
        }
      },
     "negate": true
    }
  }
}

You can then add this filter to all your handlers. If you include the custom attribute "filter_resolve": true to the checks you want to filter resolve events on, it will do so. All other checks will ignore this filter since they do not have the attribute "filter_resolve": true.

Kobbe
  • 809
  • 5
  • 16