Can we write and apply our own functions/algorithms to the database?
Yes. Kapacitor is the alerting portion of the TICK stack. Its other purpose is custom anomaly detection and data manipulation. To achieve this, Kapacitor supports user defined functions (UDFs).
To read more on Kapacitor UDF support, see the below links:
Hope that helps!