Help wanted with tickscript

Hi everybody,
although I used Influxdb for a while but I just started with Kapacitor I would need some help.

I am collecting docker metrics with telegraf once per minutes. Several containers (replicas) may belong to the same app, so there is a tag saying the app the containers belong to.

I’m trying to calculate the mean use of cpu between all replicas/containers which belongs to the same app every minute.

if the mean cpu per minute, was above a threshold for 3 minute I want to send an alert. if two minutes were above the threshold and but 1 minute it was’t I don’t want to do anything.

I don’t know I’m clear enough and if you understand me, my english is not very good.

I’m starting like this:

stream
    |from()
      .database('test')
      .retentionPolicy('default')
      .measurement('cpu')
      .where(lambda: ("app" == 'test'))

But not sure how to follow…

Really thanks for your help.

Reagrds,
Claudiu

@cbarzu Looks like you have the first part done! Next you just need to |alert() on the result of that. Thats where you would set your threshold and choose your output.

One thing that might make this easier is the Kapacitor UI in Chronograf. There is a visual editor in there for building these types of alerts. Does that help?