influxdata / influxdata/kapacitor
JOINING kapacitor queries with count and difference methods
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
I have been trying to run this script but no alert is getting created on alerta and logs are not showing any error as well, can anyone help me with this ?
avg_time_gap = sum(current_time - previous_time)/count(num_of_entries)
current_time_gap = (current_value-previous_value)
thresh = abs(current_time_gap-avg_time_gap)
alert when thresh > 0
```
var window = 20s
var every = 5s // defines the frequency at which the window is emitted to the next node in the pipeline.
var timeout = 360s // alert expiry time
var avg_time = batch
|query('select 20.0/count(content) as avg_time_gap from mydb..measurement')
.period(window)
.every(every)
//numerator must be as same as the window value
var adjacent_time_gap = batch
|query('select difference(content) as time_gap from mydb..measurement')
.period(window)
.every(every)
var data = avg_time
|join(adjacent_time_gap)
.as('avg_time','actual_time')
.tolerance(1s)
|eval(lambda: abs("avg_time.avg_time_gap"-"actual_time.time_gap"))
.as('time_delay')
var alert = data
|alert()
.id(event_name)
.crit(lambda: "time_delay" > 0)
```
Contributor guide
Research direction
Start with the Kapacitor script in the issue, then inspect how the batch query, difference query, join, and alert nodes handle emitted data. Reproduce the missing alert and determine whether the query results reach the join and alert criteria; done means identifying the cause and documenting a verified correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100