Summary across multiple fields and tags using Kapacitor

Hi,

I have a system that monitors throughput of devices. Each device has a number of interfaces (device name and interface name are used as tags). I would like to get the total throughput across all of the interfaces on given device in given minute. Currently I can do it with a tick script similar to this (simplified from original one that goes across more interfaces):

// dbrp "hyper"."autogen"
var intf1 = stream
    |from()
        .measurement('interfaceStats')
        .where(lambda: "host" == 'my-host' AND "interface" == '1')
    |window()
        .period(1m)
        .every(1m)
        .align()

var intf1received = intf1
    |log()
    |mean('rate_byte_rcvd')

var intf1sent = intf1
    |log()
    |mean('rate_byte_sent')

var intf2 = stream
    |from()
        .measurement('interfaceStats')
        .where(lambda: "host" == 'my-host' AND "interface" == '2')
    |window()
        .period(1m)
        .every(1m)
        .align()

var intf2received = intf2
    |log()
    |mean('rate_byte_rcvd')

var intf2sent = intf2
    |log()
    |mean('rate_byte_sent')

intf1received
    |join(intf2received, intf1sent, intf2sent)
        .as('intf1received', 'intf2received', 'intf1sent', 'intf2sent')
    |log()
    |eval(lambda: "intf1received.mean" + "intf2received.mean", lambda: "intf1sent.mean" + "intf2sent.mean")
        .as('received', 'sent')
    |default()
        .tag('host', 'my-host')
    |log()

The script works ok, but for devices with many interfaces it can get really long. Stats about individual interfaces might come at different times hence the ‘window’. Sometimes there’ll be multiple readings within the minute, hence the ‘mean’ value.

The question is - is it possible to make kapacitor to calculate that summary without having to specify all the interfaces manually? And if so - how?