To preserve tags across aggregation operations like sum and mean you need to group by those tags
stream |from() .database('monitor') .measurement('system_memory') .where(lambda: "host" == 'dev1' AND "type_instance" == 'memory.used') .groupBy('tag1', 'tag2') On Friday, September 23, 2016 at 3:42:58 AM UTC-6, guotao Yao wrote: > > Hi, > @nathaniel Thanks very much. > > I find out some issues when use the mean function or sum funciton, alert > is ok, but the trigger events output to influxdb may loss some tags. > > My tick script: > stream > |from() > .database('monitor') > .measurement('system_memory') > .where(lambda: "host" == 'dev1' AND "type_instance" == > 'memory.used') > |window() > .period(1m) > .every(1m) > |mean('value') > .as('value') > |window() > .period(2m) > .every(2m) > |alert() > .id('{{index .Tags "host"}}.{{index .Tags "instance"}}') > .message('{{.TaskName}}') > .crit(lambda: "value" >= float(4200)) > .all() > .levelTag('level') > .stateChangesOnly() > .log('/tmp/memoty-alert.log') > |influxDBOut() > .database('monitor') > .measurement('triggers_system') > .tag('id', 'memory-used-too-high') > > Influxdb data:(use mean function) (I want get tags, e.g. 'type_instance', > 'unit', 'host' .etc) > time host > id level > type_instance unit value > 2016-09-23T08:46:30Z > memory-used-too-high > CRITICAL 6134.3671875 > 2016-09-23T08:44:30Z > memory-used-too-high > CRITICAL 6131.887890625 > > > When I use max function: (the data in Influxdb are OK) > time host > id level type_instance > unit value > 2016-09-23T09:03:40Z dev1 > memory-used-too-high CRITICAL memory.used MB > 6123.87109375 > 2016-09-23T09:02:40Z dev1 > memory-used-too-high CRITICAL memory.used MB > 6136.53125 > > [NOTE]: function of sum also have this issue. > > Did I do something wrong?? > > 在 2016-09-23 02:16:52,nath...@influxdb.com <javascript:> 写道: > > > Three consecutive times means for 6 minutes total so: > > stream > |from() > .measurement('m') > |window() > .period(2m) > .every(2m) > |max('value') > |window() > .period(6m) > .every(6m) > |alert() > .crit(lambda: "max" >= threshold) > // mark that all points need to match the criteria > // in order to trigger the alert. > .all() > > > > On Thursday, September 22, 2016 at 2:54:22 AM UTC-6, guotao Yao wrote: >> >> >> I have a scenario like the next: >> Evaluate the max value every 2 minutes, if the max value greater than a >> threshold three consecutive times, alert will be triggered. >> >> How can I write the tick script? >> >> Thanks! >> >> >> 在 2016年9月21日星期三 UTC+8下午10:49:09,nath...@influxdb.com写道: >>> >>> All data that is within the time now - period will be emitted into the >>> pipeline. This means data can be emitted more than once if the period is >>> longer than every. >>> >>> On Wednesday, September 21, 2016 at 12:08:02 AM UTC-6, guotao Yao wrote: >>>> >>>> Hi all, >>>> >>>> I have some confusions when I use kapacitor window node, >>>> >>>> 1. the every property define how ofen the data is emitted into the >>>> pipeline. >>>> But, I want to know whether all data during the time will be >>>> emitted into the pipeline, or is it just a data will be emitted into >>>> the pipeline. >>>> >>>> >>>> Thanks! >>>> >>> -- > Remember to include the InfluxDB version number with all issue reports > --- > You received this message because you are subscribed to the Google Groups > "InfluxDB" group. > To unsubscribe from this group and stop receiving emails from it, 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/2b5b389a-6dac-4a56-9cca-7423b24b95c5%40googlegroups.com > > <https://groups.google.com/d/msgid/influxdb/2b5b389a-6dac-4a56-9cca-7423b24b95c5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > > > > -- Remember to include the InfluxDB version number with all issue reports --- You received this message because you are subscribed to the Google Groups "InfluxDB" 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/75c2cf06-204e-486e-82c2-b5c17c4b3a81%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.