Skip to content

Instantly share code, notes, and snippets.

@filterfish
Created December 22, 2015 11:38
Show Gist options
  • Save filterfish/072d32ecf1f8e9f3d2b8 to your computer and use it in GitHub Desktop.
Save filterfish/072d32ecf1f8e9f3d2b8 to your computer and use it in GitHub Desktop.
riemann flapping
(udp-server {:host "::"})
(periodically-expire 1)
(let [index (index)]
(streams
index
(match :service #"^serf"
(changed-state {:init "ok"}
(stable 20 :state
prn))))
)
#riemann.codec.Event{:host "ch01", :service "serf", :state "ok", :description "ch01 is reachable", :metric nil, :tags nil, :time 1450783205, :ttl 20.0}
{:time 290156645199/200, :state "expired", :service "serf", :host "ch01"}
require 'riemann/client'
r = Riemann::Client.new
default = {:host => 'ch01', :description => "ch01 is reachable", :metric => nil, :service => "serf", :ttl => 20}
r << default.merge(:state => 'critical', :description => "ch01 is not reachable").tap { |p| puts p }
sleep(2)
r << default.merge(:state => 'ok', :description => "ch01 is reachable").tap { |p| puts p }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment