influxdata / influxdata/kapacitor

batch query not returning values with period(30m) but does with period(1h)

Open
#2,063 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.4k
Forks
479
Avg merge
4d 16h
Merged PRs (30d)
4

Description

I have this query on a `.tick` script:

```
batch
|query('''
SELECT max(failed)
FROM "influxdb"."default"."test_tasks"
WHERE "type"='backup' AND "paused"='0' AND "environment"='test'
''')
.groupBy('deployment_name', 'plugin', 'target')
.period(30m)
.every(30m)
|last('max')
.as('max')
|alert()
.warn(lambda: "max" != 0)
.log('/var/log/test.log')
```

While using `kapacitor watch my_task` I get outputs like this:

ks=2018-09-24T19:59:18.480Z lvl=debug msg="starting next batch query" service=kapacitor task_master=main task=my_task node=alert4 query="SELECT max(failed) FROM influxdb.\"default\".test_tasks WHERE type = 'backup' AND paused = '0' AND environment = 'test' AND time >= '2018-09-24T19:29:18.47999607Z' AND time < '2018-09-24T19:59:18.47999607Z' GROUP BY deployment_name, plugin, target"

But no alert has been triggered, if I run the query via http to influxdb I do indeed get results, this is my query:

curl -G 'http://0:9086/query?db=influxdb' --data-urlencode "q=select max(failed) as failed from \"test_tasks\" WHERE \"type\"='backup' AND \"paused\"='0' AND \"environment\" = 'test' AND time >= '2018-09-24T19:29:18.47999607Z' AND time < '2018-09-24T19:59:18.47999607Z' group by deployment_name, plugin,target" -u "foo:bar" -s | jq '.results[].series[]' -c

returns:


{"values":[["2018-09-24T19:30:31Z",1]],"columns":["time","failed"],"tags{"target":"test","plugin":"mysql","deployment_name":"test"},"name":"test_tasks"}

The period that kapacitor is using is `time >= '2018-09-24T19:29:18.47999607Z' AND time < '2018-09-24T19:59:18.47999607Z'` but for some reason is not returning or getting the value at `2018-09-24T19:30:31Z`

If I set `period(1h)` it works, but problem is that I start to get duplicated alerts.

Any ideas of what could it be wrong?

I am using `Kapacitor OSS 1.5.0 (git: master 0e529079ad8384f69e6559622a0d8f9e061097da)`

Contributor guide

Open the contributing guide

Research direction

Start with the .tick batch query and the `kapacitor watch my_task` output, then compare the 30m and 1h periods with the provided InfluxDB HTTP query. Investigate why the result at 2018-09-24T19:30:31Z is not passed through for 30m and why 1h causes duplicate alerts. Done means the 30m query returns the expected value without duplicate alerts.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.