Kapacitor sideload with path names as keys?

Hello,

I’m looking into the sideload feature of tickscript, may be someone has experience here?

I want to alert on disk usage with different thresholds per host/path.

The script looks like:

...
var data = stream
    |from()
        .measurement('disk')
        .groupBy(['path', 'host'])
        .where(whereFilter)
    |eval(lambda: "used_percent")
        .as('value')

var trigger = data
    |sideload()
        .source('file:/etc/kapacitor/sideload')
        .order('{{.host}}.yml')
        .field('disk_used_info', 70.0)
        .field('disk_used_warn', 85.0)
        .field('disk_used_crit', 95.0)
    |alert()
        .message(message)
        .info(lambda: "value" > "disk_used_info")
        .warn(lambda: "value" > "disk_used_warn")
        .crit(lambda: "value" > "disk_used_crit")
        .stateChangesOnly(1h)
        .id(idVar)
        .idTag(idTag)
        .levelTag(levelTag)
        .messageField(messageField)
        .durationField(durationField)
...

Now the issue is, I can define thresholds per host, but I cannot figure out how to store thresholds per path.
It would be logical to have an include like

        .order('{{.host}}/{{path}}.yml')

but as “path” contains slashes this won’t work.

It would also be nice to have nested structs inside the yml files like

---
/var:
  warn: 80
  crit: 90

but it looks like the files need to be flat.

I’ve found a solution^whack:

.order('{{.host}}/disk_{{ urlquery .path }}.yml')

This will urlescape the path, hence something like “disk_%2F.yml” will match for “/”.

1 Like

This is exactly what I’ve been trying to do. Could you share your entire tickscript? And an example of the content of one of the sideloaded files?

Thanks!