How create one kapacitor alert valid for multiple devices?

Hello! This is a Kapacitor question :slightly_smiling_face:
I am quite new to Kapacitor so apologies if my question sounds bit dumb
I need to create a bunch of alerts rues for different devices in the same DB and they have the same threshold (i.e all routers - CPU threshold 80%) . The only thing that change is obviously the hostname for each device. I was wondering if there is a quicker and clean way to do it instead to create a rule for each device. Anything that template can help me with? Thanks

Found it: GROUP BY does the trick

You also need to use the group by function for any tags you want to retain or use in your alert.

That is, if you want to use the value of the host tag then group by host, if you were monitoring disk or CPU instances then you would include the “instance” tag.

You can also wild card the group by to just include all tags groupBy(*), but if you have a lot of tags it might be better to specify the tags you want.