sensu / sensu-go-fatigue-check-filter

An event filter for Sensu Go for managing alert fatigue
MIT License
6 stars 8 forks source link

Feature request: Option to change default values #17

Closed VeselaHouba closed 4 years ago

VeselaHouba commented 4 years ago

Would anyone be interested in option to change default values by parameters? I mean I want to change default value of occurrences to fatigue_check/occurrences: 2 instead of having to change every single check.

I wouldn't call myself experienced in JS, but if someone else wants this feature I'll try to code it.

nixwiz commented 4 years ago

How about something like this where I could keep my default of 1? My arguments being most checks I have ever worked on I would prefer notification on first failure and this has been out long enough with this as the default that I don't want to break anybody's implementation by changing it.

function fatigue_check(event, occurrences = 1) {

    // my defaults
    // remove this var occurrences = 1;          // only the first occurrence
    var interval = 1800;          // and every 30 minutes thereafter
    var allow_resolution = true;  // allow resolution events through
    var suppress_flapping = true; // suppress when flapping

Where the resource would be:

{
  "type": "EventFilter",
  "api_version": "core/v2",
  "metadata": {
    "name": "fatigue_check_allow_two_failures",
    "namespace": "default"
  },
  "spec": {
    "action": "allow",
    "expressions": [
      "fatigue_check(event, 2)"
    ],
    "runtime_assets": [
      "fatigue-check-filter"
    ]
  }
}

This way by using this filter you could then have this as the default for any check that has this filter assigned to its handler(s).

VeselaHouba commented 4 years ago

Yes, that was exactly what I was thinking of. I didn't want to change default values in code, only have option to override them if someone wants to.

nixwiz commented 4 years ago

Sure, that will be an easy non-breaking change and i'll work on it this weekend. I'll wind up spending more time on the unit tests for it than the actual code.

nixwiz commented 4 years ago

Done and available in version 0.6.1 and is on Bonsai.

Closed by #18

VeselaHouba commented 4 years ago

Awesome, thanks mate.