How I can access to points fields on UnionNode

HI,
I have this TICK script:
var data = stream
|from()
.database(‘counters’)
.retentionPolicy(‘autogen’)
.measurement(‘DataCounters’)
.groupBy(*)
|window()
.periodCount(2)
.everyCount(1)

var InOctets = data
|where(lambda: isPresent(“InOctets”))
|derivative(‘InOctets’)
.nonNegative()
.as(‘InOctets’)
|eval(
lambda: “InOctets”)
.as(‘calc_InOctets’)

var OutOctets = data
|where(lambda: isPresent(“OutOctets”))
|derivative(‘OutOctets’)
.nonNegative()
.as(‘OutOctets’)
|eval(
lambda: “OutOctets”)
.as(‘calc_OutOctets’)
InOctets
|union(OutOctets)
|eval(
lambda: if(“calc_InOctets” > 0, 100.0 / “calc_InOctets”, 0.0))
.as(‘calc_NormalizedBandwidth’)
.keep(‘calc_OutOctets’)

|influxDBOut()
.database(‘counters’)
.retentionPolicy(‘calc_rp’)
.measurement(‘DataCounters’)
.precision(‘ms’)
.flushInterval(5s)

and I got every time this error: rr=“Failed to handle 2 argument: invalid math operator / for type missing”.
without the evalNode the Kapacitor saves the right data on influx as expect.

what can be the problem with my TICK script? how I can access to the field after the union?

Try this:

var data = stream
	|from()
		.database('counters')
		.retentionPolicy('autogen')
		.measurement('DataCounters')
		.groupBy(*)
	|window()
		.periodCount(2)
		.everyCount(1)

var InOctets = data
	|where(lambda: isPresent("InOctets"))
	|derivative('InOctets')
		.nonNegative()
		.as('calc_InOctets')
		
var OutOctets = data
	|where(lambda: isPresent("OutOctets"))
	|derivative('OutOctets')
		.nonNegative()
		.as('calc_OutOctets')
	
InOctets
	|union(OutOctets)
	|eval(lambda: if("calc_InOctets" > 0, 100.0 / "calc_InOctets", 0.0))
		.as('calc_NormalizedBandwidth')
		.keep('calc_OutOctets')
	|influxDBOut()
		.database('counters')
		.retentionPolicy('calc_rp')
		.measurement('DataCounters')
		.precision('ms')
		.flushInterval(5s)

I think the problem is that you were missing the double quotes around the field name

before:
lambda: if(“calc_InOctets” > 0, 100.0 / calc_InOctets, 0.0))
after:
lambda: if(“calc_InOctets” > 0, 100.0 / “calc_InOctets”, 0.0))

let me know if this was the problem

Thank for the replay… but this is my mistake on the script I have the double quotes.
so this is not the problem…

I’m not an expert on tick script, but for what I’ve found looks like this error can be caused by missing points.
Sample:
A | B
null | 13
8 | null

Since the missing point does not have a type you get the error.

To check if this is the case you can add the httpOut Node

InOctets
	|union(OutOctets)
	|httpOut('_The NameYouWant__')

This makes sense since Union just outputs the two datasets as one without modification, you may need to join (and not union) the two different streams in order to have the data on the same “row” and be able to calculate the additional field.

but if I removing the Eval node (this lines,
|eval(lambda: if(“calc_InOctets” > 0, 100.0 / “calc_InOctets”, 0.0))
.as(‘calc_NormalizedBandwidth’)
.keep(‘calc_OutOctets’)
i see all the points on the influxdb, so I dont think there is missing points.

Have a look at this issue on github.
He had the same problem but you can’t see it by querying the data in influx

It seems that on HttpOut I received just the InOctets values, and the OutOctets value is missing… but I don’t understand why? because I know we stream this counters … so weird