Kapacitor: using other data from source measurement window

Hi

In the capacitor alert node, to construct a meaningful message. If I don’t use an aggregate or selector like mean, for example like this:

stream
    |from()
        .measurement(measurement)
        .groupBy(groups)
    |window()
        .period(period)
        .every(frequency)
    |alert()
         .id('{{ .TaskName }}/{{ .Name }}/{{index .Tags "role"}}/instance: {{index .Tags "instance_id"}}')
         .message('{{ .ID }} is at {{ .Level }}  has {{ index .Fields "available_percent" }}% of memory available on role: {{ index .Tags "role" }}, on instance {{ index .Tags "instance_id" }}. There is {{ index .Fields "available" }}Mb out of {{ index .Fields "total" }}Mb')
         .crit(lambda: "available_percent" > 1.0)
         .victorOps()

I can get access to the other values. However, If I want say the mean over my window, I can’t see how to get this.
I hoped I could ask for the mean of the stat that I want and then the mean of the other fields, and reference those, for e.g.

|mean('available')
  as('mean_available)
|mean('total')
  as('mean_total')
|mean('available_percent')
  as('available_percent')

but, chaining ‘mean’ doesn’t really make sense, and using ‘show’ I can see errors on the 2nd node, which might be expected.

Any hints?

also, forgive me for not picking up autocorrect’s s/kapacitor/capacitor/ above

@glenndavy Have a look at the join node JoinNode | InfluxData Documentation Archive, You can compute the mean of each of the fields and then join them back together into a single point and send that point to the alert node.

1 Like

Thanks Nathaniel, sorry for delayed response. Makes sense, will give it a whirl.