Skip to content

Instantly share code, notes, and snippets.

@calebhailey
Last active June 21, 2017 11:17
Show Gist options
  • Save calebhailey/8fed39a2eba3d230933f6d53de038f24 to your computer and use it in GitHub Desktop.
Save calebhailey/8fed39a2eba3d230933f6d53de038f24 to your computer and use it in GitHub Desktop.
{
"handlers": {
"example_handler": {
"type": "pipe",
"command": "notify_somebody.rb",
"timeout": 30,
"filter": "filter_weekly_maintenance"
}
}
}
{
"filters": {
"filter_july_29_maintenance": {
"negate": true,
"attributes": {
"timestamp": "eval: Time.new(2016,7,29,18,0,0,'-06:00') < value && value < Time.new(2016,7,30,6,0,0,'-06:00')",
"check": {
"name": "eval: ['check_foo','check_bar','check_baz'].include?(value)"
}
}
}
}
}
{
"filters": {
"filter_weekly_maintenance": {
"negate": true,
"attributes": {
"timestamp": "eval: (Time.at(value).wday == 5 && Time.at(value).hour > 18) || (Time.at(value).wday == 6 && Time.at(value).hour < 6)",
"check": {
"name": "eval: ['check_foo','check_bar','check_baz'].include?(value)"
}
}
}
}
}
@calebhailey
Copy link
Author

Scenario: Friday night maintenance window(s) for three specific checks (from Friday at 6:00 PM to Saturday at 6:00 AM).

These are a couple of example eval filters someone could use for a one-time scheduled maintenance (i.e. filter_july_29_maintenance), or for a regular weekly maintenance (i.e. filter_weekly_maintenance). While not as ideal as first-class support for scheduled maintenance (which is coming soon), these filters provide a good example of how powerful eval filters can be – and they're not even using filter eval tokens.

PS- the example handler definition is provided as a reminder that filters are applied to handlers, not directly to checks. 😄

@eklein
Copy link

eklein commented Jul 29, 2016

Thank you guys so much! This is exactly what I need until scheduled maintenance is available. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment