Variables in TICK scripts

I have a large number of devices running Telegraf all writing custom metrics to a central InfluxDB server. Each machine logs its metrics tagged with a customer ID.

I’m looking for a way to use this ID in a TICK script in Kapacitor, so I can copy metrics for a given customer into a database with the same name as the ID.

So measurements tagged with ‘customer1’ as customer ID need to end up in database ‘customer1’, etc.

I’m looking for a way to use the variable in the measurement as value for the database I’m copying data into, without doing tricks like making a tick script per customer, since this list changes all the time.

Is there any way to achieve this in a TICK script?