influxdata / influxdata/chronograf

tickscript errors on parser:unexpected

Open
#6,061 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.6k
Forks
250
Avg merge
1d 3h
Merged PRs (30d)
9

Description

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')

Contributor guide

Open the contributing guide

Research direction

Use the generated TICK script in the report as the reproduction case and trace the alert-rule generation entry point that produces its whereFilter. Confirm the generated script parses and saves successfully without the reported parser error, and add or update coverage if the relevant test location is found.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.