If you want to use the variable in the message then use the template if expressions like you are doing in your example ` {{ if eq .Level "WARNING" }}... {end}}`
On Monday, November 14, 2016 at 12:03:19 PM UTC-7, Rishma Gupta wrote: > > The problem with this is : I am unable to include the new variable in the > message. Lets say my output is : Like the message shows the individual > variables; how can I include the new variable in the message based on the > warning or critical message . > > ["azure.fwd.influxperf",1479150100,{"Date":"2016-11-14T19:01:40Z","Host":" > chslspldep001.karmalab.net","Source":"Influx","SourceInstance":"Not > Applicable","ObjectName":"mem_usage","InstanceName":"mem_usage/ > chslspldep001.karmalab.net/mean is CRITICAL value: 19.812357598067546 > (threshold of Severity:1 > CRIT_THRESHOLD)","CounterName":"mean","SampleValue":"19.812357598067546","KPI":"Not > > Applicable","ThresholdOperator":"Not Applicable","Average":"Not > Applicable"}] > > On Mon, Nov 14, 2016 at 8:18 AM, <nath...@influxdb.com <javascript:>> > wrote: > >> You will have to use an `|eval()` node and the `if` function See >> https://docs.influxdata.com/kapacitor/v1.1/tick/expr/#conditional-functions >> after the alert node to transform the data. >> >> On Friday, November 11, 2016 at 4:41:36 PM UTC-7, Rishma Gupta wrote: >>> >>> Thanks Nate, >>> >>> How can I set the variable according to the condition if .level is >>> warning, set it as severity 1, if critical set severity as 2 and if Ok set >>> the severity as 0? >>> >>> Thanks, >>> Rishma >>> >>> On Fri, Nov 11, 2016 at 1:02 PM, <nath...@influxdb.com> wrote: >>> >>>> I think this is what you are looking for. >>>> https://docs.influxdata.com/kapacitor/v1.1/nodes/alert_node/#levelfield >>>> >>>> In combination with an eval node you can convert the level string to a >>>> 0,1, or 2 value. >>>> >>>> >>>> On Friday, November 11, 2016 at 10:42:53 AM UTC-7, Rishma Gupta wrote: >>>>> >>>>> Thanks Nate for your quick reply. >>>>> >>>>> This is what I am doing. I am written the below script to send the >>>>> alerts if mem used is increasing thresholds. I want to send the new >>>>> variable Severity in the alerts. Lets say this alert is warning alert; it >>>>> should send the severity as "1" in the message or if it is Critical it >>>>> should send the severity as "2" otherwise send the severity as "0". >>>>> >>>>> var WARN_THRESHOLD = 20 >>>>> >>>>> var CRIT_THRESHOLD = 21 >>>>> >>>>> var period = 10s >>>>> >>>>> var every = 10s >>>>> >>>>> stream >>>>> >>>>> |from().database('processes_status').measurement('mem').groupBy('host') >>>>> >>>>> |window() >>>>> >>>>> .period(period) >>>>> >>>>> .every(every) >>>>> >>>>> |mean('used_percent').as('mean') >>>>> >>>>> |alert() >>>>> >>>>> .id('{{ .TaskName }}/{{ index .Tags "host" }}/mean') >>>>> >>>>> //.details('{{ index .Fields "mean" }}') >>>>> >>>>> .details('{{ .ID }} is {{ .Level }} value: {{ index .Fields "mean" }} >>>>> (threshold of {{ if eq .Level "WARNING" }}WARN_THRESHOLD{{ else if eq >>>>> .Level "CRITICAL" }}CRIT_THRESHOLD{{ end }})') >>>>> >>>>> .warn(lambda: "mean" > WARN_THRESHOLD) >>>>> >>>>> .crit(lambda: "mean" > CRIT_THRESHOLD) >>>>> >>>>> .stateChangesOnly() >>>>> >>>>> On Friday, November 11, 2016 at 8:24:22 AM UTC-8, nath...@influxdb.com >>>>> wrote: >>>>>> >>>>>> It is not clear to me what you are trying to do. Can you provide some >>>>>> examples? And perhaps some TICKscript you have tried and why they didn't >>>>>> work? Thanks >>>>>> >>>>>> On Thursday, November 10, 2016 at 8:50:11 PM UTC-7, Rishma Gupta >>>>>> wrote: >>>>>>> >>>>>>> I am writing the script to declare new variable severity and set the >>>>>>> severity based on the .level and send it in the alert using stream . >>>>>>> Please >>>>>>> guide, >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>> Remember to include the version number! >>>> --- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "InfluxData" group. >>>> To unsubscribe from this topic, visit >>>> https://groups.google.com/d/topic/influxdb/V-LiaexP3OE/unsubscribe. >>>> To unsubscribe from this group and all its topics, send an email to >>>> influxdb+u...@googlegroups.com. >>>> To post to this group, send email to infl...@googlegroups.com. >>>> Visit this group at https://groups.google.com/group/influxdb. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/influxdb/78e7bcf0-c499-44bd-86ca-70d25d3c84f2%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/influxdb/78e7bcf0-c499-44bd-86ca-70d25d3c84f2%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >> Remember to include the version number! >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "InfluxData" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/influxdb/V-LiaexP3OE/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> influxdb+u...@googlegroups.com <javascript:>. >> To post to this group, send email to infl...@googlegroups.com >> <javascript:>. >> Visit this group at https://groups.google.com/group/influxdb. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/influxdb/1840c65d-9228-40f1-b28c-aa476a76d73c%40googlegroups.com >> >> <https://groups.google.com/d/msgid/influxdb/1840c65d-9228-40f1-b28c-aa476a76d73c%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- Remember to include the version number! --- You received this message because you are subscribed to the Google Groups "InfluxData" group. To unsubscribe from this group and stop receiving emails from it, send an email to influxdb+unsubscr...@googlegroups.com. To post to this group, send email to influxdb@googlegroups.com. Visit this group at https://groups.google.com/group/influxdb. To view this discussion on the web visit https://groups.google.com/d/msgid/influxdb/b0ab8c60-e0b0-4e41-989d-0fe8d9cce59d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.