2

I have riemann clojure rule as follows

(streams
 (where (service "a")
                #(info "a-" %)
                (moving-event-window 2 (smap folds/sum (with :service "a-derivative" reinject))))
  (where (service "b")
                #(info "b-" %)
                (moving-event-window 3 (smap folds/sum (with :service "b-derivative" reinject))))
 (project [(service "a-derivative") (service "b-derivative")]
          (smap folds/quotient (with :laa "doooo" prn))))

The intent is to create a sum of 2 events of a and create a-derivative. Similarly for service b to create b-derivative. I then want to find the quotient of the derived events "a-derivative" & "b-derivative".

In the above sample the a-derivative and b-derivative events are reinjected and then the I use project to get the derived events to calculate the quotient.

From the documentation of riemann, it seems we must avoid reinject. If that is the case how do we avoid reinject and rewrite the above rule?

Ok, one approach I tried is as follows:

(streams
 (pipe -
       (splitp = service
               "a" (moving-event-window 2 (smap folds/sum (with :service "a-derivative" -)))
               "b" (moving-event-window 2 (smap folds/sum (with :service "b-derivative" -)))) 
            
       (sdo #(info "hmm" %)
            (project [(service "a-derivative") (service "b-derivative")]
                     (smap folds/quotient (with :laa "doooo" prn))))
       
       )
 )

And it works!. However is this right? Also this approach was easy as both functions were similar. (I.E they both relied on the service name, so split worked.) What if the functions were completely different.(For e.g one function relied on service name and another function relied on tags etc.)

Much help is appreciated.

1 Answer 1

0

That looks like a good use of pipe, and a fine way to solve this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.