influxdata / influxdata/kapacitor
Kapacitor join problem
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Hi,
I want to make easy 'if' on my historical data using kapacitor replay
```
if Status1 > 0 and Status2 > 0 then 2
else if Status1 > 0 then 1
else 0
```
Doe to it I join two batch data:
> time Status1
> 2019-09-28T00:00:41.546Z 0
> 2019-09-28T00:01:41.546Z 0
> 2019-09-28T00:02:41.546Z 0
> 2019-09-28T00:03:41.546Z 0
> 2019-09-28T00:04:31.746Z 1
> 2019-09-28T00:04:41.546Z 1
> 2019-09-28T00:05:41.546Z 1
>
and
> time Status2
> 2019-09-28T02:58:00.000Z 1
> 2019-09-28T03:02:00.000Z 0
> 2019-09-28T06:52:00.000Z 1
> 2019-09-28T06:58:00.000Z 0
> 2019-09-28T14:12:00.000Z 1
> 2019-09-28T15:18:00.000Z 0
> 2019-09-28T16:08:00.000Z 1
> 2019-09-28T16:36:00.000Z 0
And my script is that:
```
var Status1 = batch
|query(' SELECT Status1 AS "BB" FROM "chronograf"."autogen".S1')
.period(1m)
.every(1m)
.fill(0.0)
var Status2 = batch
|query(' SELECT Status2 AS "S2" FROM "chronograf"."autogen".S2')
.period(1m)
.every(1m)
.fill(0.0)
Status1
|join(Status2 )
.tolerance(1m)
.as('Status1', 'Status2')
.fill(2.0)
|default()
.field('Status1', 0)
.field('Status2', 'previous') //information only with status change
|eval(
lambda: if("Status1.S1" > 0, if("Status2.S2" > 0, int(1), int(2)), int(0)),
lambda: "Status1.S1",
lambda: "Status2.S2"
)
.as('3LevelFlag', 'S1', 'S2')
.keep('3LevelFlag', 'S1', 'S2')
|influxDBOut()
.create()
.database('chronograf')
.retentionPolicy('autogen')
.measurement('3LevelStatus')
```
In 3LevelStatus result is that:
- 'if' result is incorrectly, I observe only 2 and 0.
- S1 and S2 is diffrent from Status1 and Status2, and when I manipulate the tolerance and default field I observe sometimes S1 is correct and S2 is 2, sometimes S2 is correct and S1 is 2 or 0, but never both.
It is a bug, or maybe I do something wrong?
I use kapacitor version 1.5.3 on docker on Ubuntu 18.04.
Contributor guide
Research direction
Reproduce the reported Kapacitor 1.5.3 task from the script, using the two batch queries and the shown Status1 and Status2 data. Start by examining the join tolerance and fill/default behavior, then compare the S1, S2, and 3LevelFlag output with the expected conditional results. Done means the joined fields and conditional result are consistent, or the issue is explained as expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, ubuntu
- Domain
- databases, stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100