Created
January 15, 2014 10:18
-
-
Save actionshrimp/8433889 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Pick up service x events, sent by error detection in service 'y' stream | |
(streams | |
(where (service "x") | |
;Index API service events for 60s we can watch for expiries info | |
(with :ttl 60 (update-index (index))) | |
(changed-state {:init "ok"} | |
(service-x-state-change-email "[email protected]")) | |
(expired (with :state "ok" reinject)))) | |
; Handle errors passed from dotcom MVC or node apps | |
(streams | |
(where (service "y") | |
(tagged "Log" | |
;And high severity | |
(where (or (tagged "Error") | |
(tagged "Fatal")) | |
(where (tagged "live") | |
;Send all logs to papertrail | |
log-to-papertrail | |
;Looks like the API is down (more than 5 errors in 30s) | |
(where (description "service x errored") | |
(fixed-time-window 30 | |
(fn [events] | |
(if (> (count events) 5) | |
;Send back to top level streams with 60s TTL | |
((with {:host "service-x-host" | |
:state "critical" | |
:service "x" | |
:error-count (count events)} | |
reinject) (first event))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an alternative, staring from L25
This assumes your streams are defined like so: