In TICKscript (Kapacitor), how will you split the string?

423 Views Asked by At

For example, var str1 = "abc.test.com:8080"

I need something as follows,

var splitted = split(str1,":")

var only_hostname = splitted[0] //will give abc.test.com*

How can we actually achieve the same in TICKscript?

1

There are 1 best solutions below

1
On

You could define the variable as a regex...Something like var str1 =~ /abc.test.com/ so you will aggregate by host independant of ports...

I never need exactly your use case, but maybe in the go specs you could find what you need!