influxdata / kapacitor

Open source framework for processing, monitoring, and alerting on time series data
MIT License
2.31k stars 492 forks source link

Relative Alert builder works properly? #1968

Open ChalsGJ opened 6 years ago

ChalsGJ commented 6 years ago

I'm trying to configure some alerts to check if my ICK v1.5 (InfluxDB+Chronograf+Kapacitor) works properly. When I try to configure Threshold or deadman alerts, I have no problems and they create an alert when they should do. But I need to compare if there are any changes in different time instances, so I need to use relative alerts. Is alert builder working properly? It creates somthing like this:

var db = 'bsmetrics' var rp = 'autogen' var measurement = 'dentdeserra' var groupBy = [] var whereFilter = lambda: TRUE var name = 'Borrable' var idVar = name var message = ' {{.ID}} {{.Name}} is KO' var idTag = 'alertID' var levelTag = 'level' var messageField = 'message' var durationField = 'duration' var outputDB = 'chronograf' var outputRP = 'autogen' var outputMeasurement = 'alerts' var triggerType = 'relative' var shift = 10m var crit = 1

var data = stream |from() .database(db) .retentionPolicy(rp) .measurement(measurement) .groupBy(groupBy) .where(whereFilter) |eval(lambda: "valor") .as('value')

var past = data |shift(shift)

var current = data

var trigger = past |join(current) .as('past', 'current') |eval(lambda: float("current.value" - "past.value")) .keep() .as('value') |alert() .crit(lambda: "value" > crit) .stateChangesOnly() .message(message) .id(idVar) .idTag(idTag) .levelTag(levelTag) .messageField(messageField) .durationField(durationField)

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

Analyzing the code generated, I'm not able to see what is wrong. Where can I find a template or something similar to build that type of alerts?

edit: Related to #1972

sinistram commented 4 years ago