Please require help here. Anyone got any idea? Regards, Aditya C S
On Sat 7 Jan, 2017, 1:41 PM Aditya C.S, <[email protected]> wrote: > *This is what I get in kapacitor logs* > > [batch_container_cpu_alert:log3] 2017/01/07 08:06:43 I! > {"name":"service_cpu_usage","tmax":"2017-01-07T08:05:20Z","group":" > com.docker.swarm.service.name=jenkins","tags":{" > com.docker.swarm.service.name > ":"jenkins"},"points":[{"time":"2017-01-07T08:05:20Z","fields":{"cpu_usage":0.01899111111111111},"tags":{" > com.docker.swarm.service.name":"jenkins"}}]} > > *But in alert log I get null for "com.docker.swarm.service.name > <http://com.docker.swarm.service.name>"* > > {"id":"service_cpu_usage:com.docker.swarm.service.name=jenkins","message":"INFO: > has high cpu usage: > 0.048113899999999994","details":"{\u0026#34;Name\u0026#34;:\u0026#34;service_cpu_usage\u0026#34;,\u0026#34;TaskName\u0026#34;:\u0026#34;batch_container_cpu_alert\u0026#34;,\u0026#34;Group\u0026#34;:\u0026#34; > com.docker.swarm.service.name > =jenkins\u0026#34;,\u0026#34;Tags\u0026#34;:{\u0026#34; > com.docker.swarm.service.name > \u0026#34;:\u0026#34;jenkins\u0026#34;},\u0026#34;ID\u0026#34;:\u0026#34;service_cpu_usage: > com.docker.swarm.service.name=jenkins\u0026#34;,\u0026#34;Fields\u0026#34;:{\u0026#34;cpu_usage\u0026#34;:0.048113899999999994},\u0026#34;Level\u0026#34;:\u0026#34;INFO\u0026#34;,\u0026#34;Time\u0026#34;:\u0026#34;2017-01-01T05:11:00Z\u0026#34;,\u0026#34;Message\u0026#34;:\u0026#34;INFO: > com.docker.swarm.service.name=jenkins: > 0.048113899999999994\u0026#34;}\n","time":"2017-01-01T05:11:00Z","duration":1140000000000,"level":"INFO","data":{"series":[{"name":"service_cpu_usage","tags":{" > com.docker.swarm.service.name":"jenkins"}, > > Regards, > Aditya C S > > > > On Tue, Jan 3, 2017 at 9:44 PM, Ross McDonald <[email protected]> wrote: > > In that case I would recommend adding a `log()` node to your script to > examine the data before it hits the alert. For example, updating your > script to look similar to: > > ... > |log() > |alert() > .message('{{ .Level}}: {{ index .Tags " > com.docker.swarm.service.name" }} has high cpu usage: {{ index .Fields > "cpu_usage" }}') > ... > > This will dump all of the data in the stream to the Kapacitor log file. > Can you provide a few samples from the output when the alert is triggered? > > On Sat, Dec 31, 2016 at 2:11 PM, Aditya C.S <[email protected]> wrote: > > Sorry for the typo. I have tried {{ index .Tags " > com.docker.swarm.service.name" }}. > It's not working. > > Thanks, > Aditya C S > > On Sat 31 Dec, 2016, 11:25 PM Ross McDonald, <[email protected]> wrote: > > Does this not work? > > {{ index .Tags "com.docker.swarm.service.name" }} > > There is a space between 'index' and '.Tags'. The brackets need to be > together. And it looks like there is a typo with 'sswarm' (should be > 'swarm'). > > On Fri, Dec 30, 2016 at 11:12 PM, Aditya C.S <[email protected]> wrote: > > How to write custom message with tag value of " > com.docker.swarm.service.name"?. Below is my script. However, tag value > is displayed as null in the alert. I even tried this way ".message('{{ > .Level}}: { {index.Tags "[[com.docker.sswarm.service.name]]" }} has high > cpu usage: {{ index .Fields "cpu_usage" }}')". > > batch > |query(''' > select sum(usage_percent) as cpu_usage from > "telegraf"."default"."service_cpu_usage" where " > com.docker.swarm.service.name"='jenkins' order by time desc > ''') > .period(15m) > .every(1m) > .groupBy(time(10s), 'com.docker.swarm.service.name') > > |alert() > .message('{{ .Level}}: { {index.Tags " > com.docker.sswarm.service.name" }} has high cpu usage: {{ index .Fields > "cpu_usage" }}') > .crit(lambda: "cpu_usage" > 80) > .log('/opt/kap/container_cpu_alerts.log') > .exec('/opt/kap/container_cpu_alert.py') > > > Thanks, > Aditya C S > > -- > 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/309d9300-4191-41d7-b727-8ef81ea8da12%40googlegroups.com > <https://groups.google.com/d/msgid/influxdb/309d9300-4191-41d7-b727-8ef81ea8da12%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > -- > Remember to include the version number! > --- > You received this message because you are subscribed to a topic in the > Google Groups "InfluxData" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/influxdb/KEy900H4vtE/unsubscribe. > To unsubscribe from this group and all its topics, 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/CAD8sRLBFFX_2ADqdNrotROu-kyFpieiXrqh8v9yi97V0dPk1Vg%40mail.gmail.com > <https://groups.google.com/d/msgid/influxdb/CAD8sRLBFFX_2ADqdNrotROu-kyFpieiXrqh8v9yi97V0dPk1Vg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > -- > 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/CAFEGz4maC9HDMYwnO0m2LN2KQKRNO98ZJfFfHnwt-sSW5VgRkg%40mail.gmail.com > <https://groups.google.com/d/msgid/influxdb/CAFEGz4maC9HDMYwnO0m2LN2KQKRNO98ZJfFfHnwt-sSW5VgRkg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > > > -- > Remember to include the version number! > --- > You received this message because you are subscribed to a topic in the > Google Groups "InfluxData" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/influxdb/KEy900H4vtE/unsubscribe. > To unsubscribe from this group and all its topics, 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/CAD8sRLDBF8A-a%3Dhjf9eSfp2es4EYA2E%2B1uEujGsQrnSAyoA6Fw%40mail.gmail.com > <https://groups.google.com/d/msgid/influxdb/CAD8sRLDBF8A-a%3Dhjf9eSfp2es4EYA2E%2B1uEujGsQrnSAyoA6Fw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > > > -- 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/CAFEGz4k1N2MT3R5xcx6B7P%2B0ecNE%3D%3D6r%3Dv19%3D3X7SEd1SV%3D6gg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
