We worked on a single stream script here, but I came to the conclusion, that it does not work. The .shift parameter only changes the time, but I need to also cache the predicted value for the given time, until the real value comes in. But maybe you have another approach, or I misunderstood something.
Currently I have stream replay files, but I have already looked into converting them to batch files without success, yet. Don’t know how to set the expected number of batch collectors in the replay file:
running replay: unexpected number of batch collectors. exp 3 got 1
Edit: forgot to give to content of the batch replay file and tick script with the given error above:
replay file:
{"name":"table_test","points":[
{"fields":{"value":1000},"time":"2015-10-18T00:00:00Z"},
{"fields":{"value":1001},"time":"2015-10-18T00:00:02Z"},
{"fields":{"value":1002},"time":"2015-10-18T00:00:04Z"},
{"fields":{"value":1003},"time":"2015-10-18T00:00:06Z"},
{"fields":{"value":1004},"time":"2015-10-18T00:00:08Z"}]}
tick script:
batch
|query('''
SELECT value
FROM "mydb"."autogen"."table_test"
''')
.period(1s)
.every(1s)
|alert()
.crit(lambda: "value" > 0.5)
.log('/var/lib/kapacitor/alerts/batch.log')