Using variables in influx query


I have a quick question about querying the influx DB. I’ve assigned my database and retention policy as variables at the top of my script (as generated when i use chronograf to create my tick scripts) and was wondering if it is possible to insert my DB and RP variables into my query?

TICK script novice go easy please

var db = 'telegraf'
var rp = 'autogen'
//Store the alerts
var outputDB = 'chronograf'
var outputRP = 'autogen'

var groupBy = ['host', 'time']
var period = 60s
var every = 30s

var threshold = 10.0

var data = batch 
    |query('''SELECT mean(tcp_established) AS stat FROM /^$db$/./$rp$/."netstat";  ''')

When i try to define i get an error message:

found ‘.’ , expected ; at line 1 character 50 (line one is a commented out line with the script/alert name.

So, my question is as follows: am i able to use the queries like this? If I’m defining my DB and RP at the start of the script, it would make sense to be able to reference it in my query (to me at least) right? And if so, how would i go about doing so?

I’ve tried to follow this github page