influxdata / docs.influxdata.com-ARCHIVE

ARCHIVE - 1.x docs for InfluxData
https://archive.docs.influxdata.com/
MIT License
252 stars 292 forks source link

How to get a where clause working in Batch TICK Script? #1359

Closed alwaysrohit closed 6 years ago

alwaysrohit commented 6 years ago
What products and version are you using?

Kapacitor 1.4.0 (git: HEAD fcce3ee9e6abcee5595fd61066bfc904edb1e113)

Where did you look before opening the issue?

A thorough google search, various trials


What am i trying to achieve: I am trying to have different CPU, Memory alerting thresholds on various server groups using Batch data. The problem I am facing is getting the "where clause" in batch working. Stream works fine and works as expected. Below is the code snippet i am trying to get it work.

Note that, hard coding values in where clause works. --->>>>>>>>> var triggerType = 'threshold'

var whereFilter = lambda: ("hostname" == 'host-id3-403' OR "hostname" == 'host-id3-402' OR "hostname" == 'host-id3-401' OR "hostname" == 'host-id3-400')

var whereClause = ''' ("hostname"='host-id3-403' OR "hostname"='host-id3-402' OR "hostname"='host-id3-401' OR "hostname"='host-id3-400') '''

var crit = 2

var period = 5m

var data = batch // WHERE "hostname"="whereFilter" <~ Not working // WHERE "hostname"='whereFilter' <~ Not Working // WHERE ("hostname"='host-id3-403' OR "hostname"='host-id3-402' OR "hostname"='host-id3-401' OR "hostname"='host-id3-400') <~ Not Working // WHERE (whereClause) <~ Not Working // WHERE (\'' + whereClause + '\') <~ Not Working |query(''' SELECT "load1" FROM "hostingdev"."one_week"."system" WHERE ("hostname"='host-id3-403' OR "hostname"='host-id3-402' OR "hostname"='host-id3-401' OR "hostname"='host-id3-400') ''') .period(period) .every(1m) .groupBy(groupBy) |eval(lambda: "load1") .as('value')

var trigger = data |alert() .all() .crit(lambda: "value" > crit) // .stateChangesOnly() .message(message) .id(idVar) .idTag(idTag) .levelTag(levelTag) .messageField(messageField) .durationField(durationField) .email('validid@domain.com')

<<<<<<<<<<<<<<------

timhallinflux commented 6 years ago

Again...not a documentation issue. Please use the online forums for this kind of question.

https://community.infludata.com Thank you!