racker/cookbook-cloudmonitoring — pull request #20 by philk (2013-03-01 23:02:56+00:00)
Title: Add criteria DSL

I got tired of writing huge <<-EOF blocks for the alarm criteria's so I did this crazy thing. Seems like it might be a bad idea but I was shocked it actually works.

Still needs docs but it basically ends up working something like this:

```ruby
cloud_monitoring_alarm "memory_usage alarm" do
check_label "memory"
criteria do
critical_if(percentage("actual_used", "total"), ">", 95,
"Memory usage is above 95%"
)
warn_if(percentage("actual_used", "total"), ">", 90,
"Memory usage is above 90%"
)
ok "Memory usage is below 90"
end
notification_plan_id npid
action :create
end
```
or you can still use strings if you want:

```ruby
cloud_monitoring_alarm "ping alarm" do
check_label "ping"
criteria "if (metric['available'] < 100) { return CRITICAL, 'ping check packet loss'}"
notification_plan_id npid
action :create
end
```