Sideload() invalid TICKscript: parser: unexpected identifier

Hello,

I was trying to use sideload() but getting an error, any idea what it is complaining of?
Kapacitor Version 1.5
OS: Windows

invalid TICKscript: parser: unexpected identifier line 29 char 17 in " .order('hosts\host". expected: ")"

sideload excerpt-

26 var customized = data
27    |sideload()
28        .source('file:\\\C:\myStack\kapacitor-1.5.3-1\sideload\')
29        .order('hosts\host-{{.host}}.yml')
30        .field('cpu_threshold', 95)

Full Tickscript:

var db = 'test_db'

var rp = 'autogen'

var groupBy = ['instance', 'host']

var data = stream
    |from()
        .database(db)
        .retentionPolicy(rp)
        .measurement('Processor')
        .groupBy(groupBy)
        .where(lambda: "instance" == '_Total')
    |window()
        .period(20s)
        .every(10s)
        .align()
    |log()
    |where(lambda: isPresent("Percent_Processor_Time"))
    |last('Percent_Processor_Time')
        .as('value')
    |eval()
        .keep('value')
    |log()

var customized = data
    |sideload()
        .source('file:\\\C:\mystack\kapacitor-1.5.3-1\sideload\')
        .order('hosts\host-{{.host}}.yml')
        .field('cpu_threshold', 95)
    |log()

var trigger = customized
    |alert()
        .crit(lambda: "value" > "cpu_threshold")
    |influxDBOut()
        .create()
        .database(db)
        .retentionPolicy(rp)
        .measurement('sideload_test')
        .tag('alertName', 'sideload_test')
        .tag('triggerType', 'threshold')

Thanks

I think the problem is caused by backslashes that you use to construct Windows paths. At the end of line 28
\'
means character “quote”, not end of string literal. The string literal that begins on line 28 - ends with the quote before “hosts” on line 29.

You can try using Unix-style paths (with forward-slashes) instead.

I tried it last night and got error: sideload source path must be absolute “/C:/temp/demo”

var customized = data
|sideload()
.source(‘file:///C:/temp/demo’)
.order(‘hosts/host-{{.host}}.yml’)
.field(‘cpu_threshold’, 95)
|log()

have you tried:
.source(‘file://C:/temp/demo’)
?

No i did not.
Just tried, got the error:
sideload source path must be absolute “/temp/demo”

Also tried
.source(‘file://C/temp/demo’)
and
.source(‘file:///C:/temp/demo’)
and
.source(‘file:///C/temp/demo’)

I tried this
.source(‘file:////C:/temp/demo’)

got the error
failed to update sideload cache for source “\\C:\temp\demo”: FindFirstFile \C:\temp\demo: The network path was not found.

How about this?
.source('file://\\C:\\temp\\demo')

Interesting now i got
parse file://\C:\Temp\demo: invalid character “\” in host name

So many wrong ways… :rofl:
I wonder if this will work?..
.source('file://C:\\temp\\demo')

yeah i know :sweat_smile:

getting the same error :ghost:
parse file://C:\temp\demo: invalid character “\” in host name

For now i am running it on linux…
Thank you @nekrassov for spending time and suggestions, really appreciate it!

Good information thanks for sharing
vmware

1 Like