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, <[email protected] <javascript:>> 
> 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, [email protected] 
>>> 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 
>> [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <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/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 the Google Groups 
"InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to