I am new to the TICK stack and still getting familiar with the DSL syntax / figuring out how it all works. I’m currently writing a simple stream script that…
- Takes two key values from two different measurements and rewrites them (with a new name) into a new measurement
- Creates a new key value based on a mathematical operation of the two measurements
I created a simple TICKscript to do this, referencing the JoinNode documentation as I went.
// Get inodes_total var inodes_total = stream |from() .database(db) .retentionPolicy(rp) .measurement('container_fs_inodes_total') .where(lambda: "sr" == 'k8s') // Get inodes_free var inodes_free = stream |from() .database(db) .retentionPolicy(rp) .measurement('container_fs_inodes_free') .where(lambda: "sr" == 'k8s') // Calculate difference, aggregate metrics inodes_total |join(inodes_free) .as('inodes_total', 'inodes_free') .tolerance(1s) .fill('null') |eval(lambda: "inodes_total.gauge") .as('inodes_total') |eval(lambda: "inodes_free.gauge") .as('inodes_free') |eval(lambda: "inodes_total.gauge" - "inodes_free.gauge") .as('inodes_used') |influxDBOut() .database(db) .retentionPolicy(rp) .measurement('container_fs_inodes') .precision('s')
I’ve gone through a couple revisions of this script – the most success I had was with creating the new measurement with the new key value (from the mathematical operation). However, I was unable to rewrite the two existing key values from the two measurements into the new measurement.
To resolve this, I thought I would try creating an
eval statement to reference the original key value and then rewrite into the new measurement. This last attempt is reflected in the TICKscript above. However, the error I get in my Influx shell is…
[task_name:eval6] 2017/07/19 23:39:21 E! missing value: "inodes_free.gauge"
Looking through this, I’m not sure where I’m going wrong or why the script isn’t able to read in the value (like it does when it performs the subtraction operation, which does work).
Does anyone know what the issue might be or why this is the case? Even if the script is wrong, I’m still curious to know why the value is unable to be read in when it does work when I use both of the values together. I am pretty new to all of this and working with time-series databases in general, so I hope this isn’t too dumb of a question, but I’m totally stuck!