kapacitor icon indicating copy to clipboard operation
kapacitor copied to clipboard

Generate random ID for influxdbOutNode

Open RyeBot33 opened this issue 3 years ago • 4 comments

Is there a way to generate a random ID through a lambda function or anything of the sort? Something Like

|influxDBOut()
    .create()
    .database(outputDB)
    .retentionPolicy(outputRP)
    .measurement(outputMeasurement)
    .tag('alertName', name)
    .tag('triggerType', triggerType)
    .tag('acked', 'false')
    .tag('location', 'Building 1')
    .tag('id', rand.Intn(100))

There was an issue raised about this before but no answer. Any suggestions?

RyeBot33 avatar Dec 06 '21 21:12 RyeBot33

Currently there isn't a way to make a random number. We really should have one.

docmerlin avatar Dec 09 '21 17:12 docmerlin

Yeah it would definitely be beneficial. I am pushing all of the alerts to an Influxdb instance and need a way to delete them. It would be much easier to be able to delete if we get generate a random UUID for each alert. Maybe coming soon? Fingers crossed.

RyeBot33 avatar Dec 13 '21 15:12 RyeBot33

https://github.com/influxdata/kapacitor/pull/2680

docmerlin avatar Mar 29 '22 17:03 docmerlin

Awesome! So in the example, it would be something like:

|influxDBOut() .create() .database(outputDB) .retentionPolicy(outputRP) .measurement(outputMeasurement) .tag('alertName', name) .tag('triggerType', triggerType) .tag('acked', 'false') .tag('location', 'Building 1') .tag('id', rand())

?

RyeBot33 avatar Mar 29 '22 17:03 RyeBot33