Question

I am currently evaluating siddhi for use in a snmp environment. The POC is build around network interface utilization.

A stream is defined as:

define stream interfaceStatsEvents (nodeName string, sdate double, ifSpeed long, ifIndex string, ifAdminStatus string, ifOperStatus string,
ifInDiscards long, ifInErrors long, ifOutDiscards long, ifOutErrors long, ifInOctets long, ifOutOctets long)

The query for calculating interface utilization as:

from every (e1 = interfaceStatsEvents -> e2 = interfaceStatsEvents[nodeName == e1.nodeName and ifIndex == e1.ifIndex]) 
select e1.nodeName, e1.ifIndex, ((e2.ifInOctets - e1.ifInOctets) * 8 * 100) / (((e2.sdate - e1.sdate) / 1000) * e1.ifSpeed) as utilization 
insert into interfaceUtilization;

The problem is that the query seems to run only once. 4 events were added to the interfaceStatsEvents stream. Was expecting 3 events to be generated for interfaceUtilization, instead only a single event was generated.

Does anyone have an idea on the reason for that or how to fix the query?

Was it helpful?

Solution

The issue here is you are using every for the whole pattern, hence this will output for every e1,e2 combination

from every (e1 = interfaceStatsEvents -> e2 = interfaceStatsEvents[nodeName == e1.nodeName and ifIndex == e1.ifIndex])

to get an output as you expected i.e for every e1 followed by e2 you have to change the query as

from every e1 = interfaceStatsEvents -> e2 = interfaceStatsEvents[nodeName == e1.nodeName and ifIndex == e1.ifIndex]

here the every will only apply for e1 and not for e1-e2 combination.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top