1

I want to trigger a mail with custom body message. I can parse timestamp in my body, but i want to add the string in my body when i try to add string value in body i'm unable to reproduce it. can anyone help me to resolve it. I'm in very critical implementation.

Please find my sample code below,

 (let [email (mailer {:host "cccc"
                            :port 25
                            :user "111111"
                            :pass "111111"
                            :auth "true"
                            :subject (fn [events] "1DD Monitoring - Response time SLA breach")
                            :body (fn [events] 
                       (apply str "Hello Team, now the time is" (:**silo** events) "Thank You!"))
                            :from "xxx@xxxx.com"})]

I'm sending value from logstash to riemann in silo field and i want to print silo field value in body

Gan
  • 93
  • 1
  • 3
  • 11

2 Answers2

0

IMHO the handle function that you define for :body, has a wrong syntax. According to the doc, you must define a function that takes a sequence of events and return a string. For example:

(defn prn-str [& events]
  ...)
Minh Tuan Nguyen
  • 1,026
  • 8
  • 13
  • 'fn' is there sytax to create a function. 'defn' is convenience function that defines a function, then saves it under a fixed names so it can be called from many places. 'defn' expands to '(def nane-here (fn [] rest of function body here))' – Arthur Ulfeldt Oct 16 '17 at 13:00
0

So you have a :**silo** key in your event. But in the :body function, you will have a list of events. (:**silo** events) will be nil.

You can for example get the :**silo** values separated by a comma with:

:body (fn [events]
        (str "Hello Team, now the time is "
              (clojure.string/join "," (map #(:**silo** %) events))
               " Thank You!"))
mcorbin
  • 9
  • 1