Alert rules for OSPF neighbour count and changes

We are bringing some configuration it is being picked up at:

Is it possible to setup alers for neighbours == 0 for a device, and also detect change in a count for neighbours ?

I have been examining the database, and code can see where that count can come from?

It is possible to add alerts rules that will run raw SQL queries to the database?



As per my inspections, yes, it is possible to process rule with direct SQL, skipping alert builder completely.

any solution on this ?