0

I am trying to set up an alert in riemann (through pagerduty) based on a threshold for a metric. If the threshold is breached the alert should be triggered, if the metric goes back within the threshold the alert should be resolved.

My steps are: 1) Create an event with state "warning" if threshold is breached 2) Create an event with state "ok" if threshold is not breached

My code for this looks like -

(let [index (default :ttl 120 (index))]
   (streams
      index
      (where (service #"test")
         (where (>= metric 100)
            (smap (fn [e]
                    (event {:service (:service e) :metric (:metric e) 
                            :state "warning" }) 
               index))))

(I have only shown the relevant bits of code)

I see that this code does not create a new event if threshold is breached.

I am not sure if I am making a mistake. Any help would be appreciated.

Regards,

Sathya

Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284
Sathya
  • 1,076
  • 1
  • 8
  • 17
  • Could you include part of the code related to triggering pagerduity events? and would you like the alert to be canceled if a single event is below the threshold. (calling PD without a call to `rollup` will trigger an immense number of PD allerts and may result in unkind frown from sleep deprived co-workers. – Arthur Ulfeldt Feb 06 '15 at 22:40
  • 1
    it's often useful to tag Riemann configuration questions with Clojure (the language they are written in). – Arthur Ulfeldt Feb 06 '15 at 22:55

1 Answers1

1

It sounds like you have two questions:

  • why if the event not getting into the index when the metric is greater than 100
  • where should I put the calls to create and resolve the PD alerts.

As to the first one, your code looks correct, it should be indexing the event. You may want to put a :ttl in there so the events expire at the corect times. and :host key as well for good measure. In general it looks like the with function will accomplish the same thing more easily

For the second question a rough outline looks something like this:

(let [index (default :ttl 120 (index))]
   (streams
      index
      (where (service #"test")
         (where (>= metric 100)
           (with :state "warning"
             (rollup 2 3600 (create-pd-alert-here))))
         (where (< metric 50)
           (with :start "warning"
             (resolve-pd-alert-here)))
Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284