I'm looking for advice on using Kapacitor's regexReplace function.  All I'm 
trying to do is replace slashes in the path for a disk alert with 
underscores or some other character, as Sensu doesn't like slashes in Sensu 
alert names.  I can't figure out a simple use case like this from the 
example in the documentation.  This is my current admittedly lame attempt:

var data = stream
    |from()
        .measurement('disk')
        .groupBy('host', 'path')
    |eval(lambda: regexReplace("[/]", "path", "_"))
        .as('pathsub')

I'm getting this message in the kapacitor.log file:

E! no field or tag exists for [/]

I'm assuming it's complaining about the "[/]" as the first parameter of the 
regexReplace function.  I thought this would work, however, because the 
documentation links out to the Go language's ReplaceAllString function, and 
I managed to get this concoction working in the interactive Go interpreter:

re2 := regexp.MustCompile("[/]")
fmt.Println(re2.ReplaceAllString("/this/is/a/path", "_"))
fmt.Println(re2.ReplaceAllString("/", "_"))

It seems that Kapacitor's regexReplace function is called differently from 
Go's ReplaceAllString function, however, so I'm not terribly surprised that 
my attempt to use this function in Kapacitor isn't working.

By the way, I tried using the regular expression /\// in Go's interpreter, 
but I couldn't get that or any other concoction to work, which is why I 
settled on "[/]".

Anyone spot anything obvious that I'm doing wrong?  The example in the 
Kapacitor documentation uses a capture string, but I can't see how that 
applies here.  I'm just trying to do simple character replacement, so this 
shouldn't be as difficult as it seems to be.

Thanks.

-- 
Remember to include the version number!
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/influxdb/903f6230-d0ba-47a1-b4e7-4d4d0d7363e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to