简体   繁体   English

黎曼中的自定义正文消息电子邮件触发

[英]custom body message email triggering in Riemann

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 我将值从logstash发送到筒仓字段中的riemann,我想在主体中打印筒仓字段值

IMHO the handle function that you define for :body, has a wrong syntax. 恕我直言,您为:body定义的handle函数的语法错误。 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]
  ...)

So you have a :**silo** key in your event. 因此,您在活动中具有:** silo **键。 But in the :body function, you will have a list of events. 但是在:body函数中,您将有一个事件列表。 (:**silo** events) will be nil. (:** silo **事件)将为零。

You can for example get the :**silo** values separated by a comma with: 例如,您可以获取:** silo **值,并用逗号分隔:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM