You do not need to create a custom query method to achieve this.
Simpy identify the correct method to filter to the devices you wish and apply this as a new filter within the rule.
I would suggest this could either use MachineType or and my preference would be to create a Custom Property called something along the lines of 'Device_Type' to allow you to define appropriate values for each node i.e. Router or Firewall, or Core Switch etc. This you would then use in your alert filter.
I hope this helps
Installation | Consultancy | Training | Licenses
You could use machine type for this, but it might be easier to track if you setup a Custom Property for Device Type/Fn to make the naming congruent. Then just add that condition to your separate alert. Now you have an alert for your devices used for routing.