Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tickscript errors on parser:unexpected #6061

Open
harikrishna1083 opened this issue Sep 25, 2023 · 0 comments
Open

tickscript errors on parser:unexpected #6061

harikrishna1083 opened this issue Sep 25, 2023 · 0 comments

Comments

@harikrishna1083
Copy link

The generatd tickscript is erroring out when trying to save the alert rule, though TICK syntax is valid.

The error is like:
parser: unexpected ) line 7 char 67 AND ("ho".expected:"number","string","duration","identifier","TRUE","FALSE"(","-"",!

The generated tick script is like:

var critIO = 70

var highIO = 50

var crit = critIO + 1

var critReset = highIO + 4

var db = 'telegraf'

var rp = 'autogen'

var measurement = 'cpu'

var groupBy = ['host']

var whereFilter = lambda: (isPresent("cpu") AND "cpu" == 'cpu-total') AND ("host" == hostDevice)

var period = 30s

var every = 30s

var idVar = name

var message = 'High IOWait detected on {{ index .Tags "host" }}. Current value: {{ index .Fields "usage_iowait" }}'

var idTag = 'alertID'

var levelTag = 'level'

var messageField = 'message'

var durationField = 'duration'

var outputDB = 'chronograf'

var outputRP = 'autogen'

var outputMeasurement = 'alerts'

var triggerType = 'threshold'

var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|window()
.period(period)
.every(every)
.align()
|max('usage_iowait')
.as('value')

var trigger = data
|alert()
.crit(lambda: "value" > crit)
.critReset(lambda: "value" < critReset)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.slack()

trigger
|eval(lambda: float("value"))
.as('value')
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)

trigger
|httpOut('output')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant