influxdata / influxdata/kapacitor
Tickscript not write zeros when no data exist for data batch query
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
###### URL for relevant page?
*
###### What products and version are you using?
Chronograf Version: 1.7.14
Influxdb Version : 1.7.8
Kapacitor Version : 1.5.2
###### Where did you look before opening the issue?
Influxdata doc and many websites with similar topic.
###### Issue
I have this tickscript:
---------------------------------------------------------
var outputDB = 'chronograf'
var outputRP = 'autogen'
var outputMeasurement = 'ADTopupCost'
var triggerType = 'alerta'
var message = ' {{.Time}} {{.TaskName}} {{.ID}} {{.Name}} {{.Level}} {{ index .Fields "value" }}'
var data = batch
|query('SELECT SUM(operation_cost) as topupCost FROM "telegraf"."autogen"."TransformTimestampTOPUP" WHERE operation_code=\'RC\' and user_code=\'GCM\'')
.offset(20m)
.period(5m)
.every(5m)
.align()
.groupBy(time(5m), *)
.fill(0)
|first('topupCost')
.as('topupCost')
var trigger = data
@ADTopupCost()
trigger
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('triggerType', triggerType)
---------------------------------------------------------
The result espected is what the tickscript write zeros in the outpub measurement when no data is in the source table and field selected.
The real result is:
When any of the intervals selected has value (Ej: 24567, 0,0,0,0) the zeros was writed in the output. But when intervals selected not has any value, this present error: "No result" instead of answer all intervals whit zeros(Ej: 0,0,0,0,0).
Can anybody help me whit this?
Contributor guide
Research direction
Start by reproducing the batch query in the provided Tickscript with Kapacitor 1.5.2 and InfluxDB 1.7.8, focusing on .fill(0) when every interval has no data. Trace how the batch query handles an empty result; done means the output measurement receives zero values for all selected intervals instead of returning "No result".
Written by the indexing model from the issue text.
Assessment
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100