Your condition looks right as `.crit(lambda: "stat" >= 5 AND "stat" <= 4)` if it is not triggering as expected I recommend adding a `|log()` node before the alert node so you can see the data being processed.
As for the error in the second script it should be `.crit(lambda: "anomalyScore" >= x) ` Single quotes in TICKscript are string literals, double quotes reference a field or a tag in the expression. On Monday, November 14, 2016 at 8:05:09 AM UTC-7, amith hegde wrote: > > Hi, > > Well that is not the case here, I have managed to get the spelling > absolutely wrong :). I am getting a thought that I need to revisit my > condition logic. Wondering if It should have been .crit(lambda: "Airtemp" > >= "stat" AND "Airtemp" <= "stat"). > > Your suggestions and thoughts are welcome. > > On Nov 14, 2016 7:56 PM, <[email protected] <javascript:>> wrote: > >> On Monday, November 14, 2016 at 7:32:20 AM UTC-6, [email protected] >> wrote: >> > Hi, >> > >> > I have couple of doubts in tickscripts, looking for some help with them. >> > >> > Below is the script where I want to find the stddev of a field and want >> to compare it to trigger alerts. But no alerts are getting triggered though >> there are no errors. >> > >> > Want to understand if the conditional statement I have given has to do >> something with it. Please correct me if I am wrong, also let me know what >> is the best possible way to achieve this. >> > batch >> > |query(''' >> > SELECT Airtemp >> > FROM "Station"."autogen"."Temprature" >> > ''') >> > .period(30m) >> > .every(15m) >> > .groupBy('Airtemp','Station') >> > |stddev('Airtemp') >> > .as('stat') >> > |alert() >> > .id('Standard Deviation of Air Temperature : {{ .TaskName }} >> Alert Time : {{ .Time }}') >> > .crit(lambda: "stat" >= 5 AND "stat" <= 4) >> > .message('{{ .ID }}') >> > .log('/tmp/station_sd.log') >> > |influxDBOut() >> > .database('Station') >> > .retentionPolicy('autogen') >> > .flushInterval(1s) >> > .measurement('stationsd') >> > ======================================================================== >> > >> > This is one another tickscript where .crit(lambda: 'scoreField' >= 'x') >> conditions throws error saying invalid comparison, I want to know if it is >> valid in first place to put in a conditional statement within @Morgoth, if >> this is good then kindly advice me how to correct this particular script to >> produce results. >> > >> > >> > // The measurement to analyze >> > var measurement = 'eventflow_IIS' >> > >> > // The amount of data to window at once >> > var window = 5m >> > >> > //Define variable >> > var x = 0.9 >> > >> > // The field to process >> > var field = 'eventcount' >> > >> > // The field to group by >> > var field1 = 'status' >> > >> > // The name for the anomaly score field >> > var scoreField = 'anomalyScore' >> > >> > // The minimum support >> > var minSupport = 0.8 >> > >> > // The error tolerance >> > var errorTolerance = 0.15 >> > >> > // The consensus >> > var consensus = -1.0 >> > >> > // Number of sigmas allowed for normal window deviation >> > var sigmas = 5.0 >> > >> > batch >> > |query(''' >> > SELECT * >> > FROM "statistics"."autogen"."eventflow_IIS" >> > ''') >> > .period(5m) >> > .every(5m) >> > .groupBy(field,field1) >> > // |.where(lambda: TRUE) >> > >> > @morgoth() >> > .field(field) >> > .scoreField(scoreField) >> > .minSupport(minSupport) >> > .errorTolerance(errorTolerance) >> > .consensus(consensus) >> > // Configure a single Sigma fingerprinter >> > .sigma(sigmas) >> > // Morgoth returns any anomalous windows >> > |alert() >> > .details('Count is anomalous') >> > .id('kapacitor/{{ .TaskName }}/{{ .Name }}/{{ .Group }}') >> > .message('{{ .ID }} is at level {{ .Level }} Errorcount is:{{ >> index .Fields "eventcount" }}') >> > .crit(lambda: 'scoreField' >= 'x') >> > .log('/tmp/anomaly_e.log') >> > |influxDBOut() >> > .database('anomaly') >> > .retentionPolicy('autogen') >> > .flushInterval(1s) >> > .measurement('Anomaly_e') >> >> Could it be that in your select query you have this >> >> SELECT Airtemp >> FROM "Station"."autogen"."Temprature" >> >> But meant this >> >> SELECT Airtemp >> FROM "Station"."autogen"."Temperature" >> >> I found it helpful to run the queries on the command line or InfluxDB >> Admin Tool to make sure that they run correctly. >> >> >> -- >> 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/kbyZgfhgaRo/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/4917acca-5746-4b6a-a939-74e439bb6751%40googlegroups.com >> . >> 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/cdb876c5-ac70-4b71-82de-f6f2c403a6df%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
