kapacitor icon indicating copy to clipboard operation
kapacitor copied to clipboard

Change timezone and rounding off time in kapacitor alerts

Open vipulkhullar opened this issue 10 years ago • 15 comments

Can there be a provision to change timezone of kapacitor alerts ex from UTC TO IST . Also can "2016-11-02 09:39:05.560565984 +0000 UTC" be changed to something like" 2016-11-02 09:39" or any other format

vipulkhullar avatar Nov 03 '16 05:11 vipulkhullar

any news on enhancement.. by default kapacitor is in GMT TZ. how can I make this to PST TZ?

maddygoes avatar Mar 03 '17 11:03 maddygoes

@vipulkhullar @maddygoes Are you talking about the timezone in the alert messages or somewhere else?

nathanielc avatar Mar 06 '17 21:03 nathanielc

In the alerting... I think, we should have an option to change the TZ or kapacitor should pickup default server TZ...like grafana... right ?

maddygoes avatar Mar 07 '17 03:03 maddygoes

Hi @nathanielc.

I'm quite surprised for the lack of support for timezones in a monitoring tool.. :(

We would like migrate part of our monitoring infrastructure to use with kapacitor , but we can not send alerts with N hours in the past to our system administrators. They will get confused on the time where to look for problems.

There is any plans to support TZ ? As a workaround could you send timestamp instead that we can transform to a valid time in our timezone ?

toni-moreno avatar Jul 27 '17 12:07 toni-moreno

Hi @nathanielc we need a workaround to fix the time sent in the message.

There is any way to force kapacitor execute a "date" command in the host server and attach the output to the message on each triggered alert?

Thank you very much

toni-moreno avatar Aug 16 '17 11:08 toni-moreno

Any update on this ? I really to change the timezone to my local timezone in the message.

davistran86 avatar Jun 21 '18 08:06 davistran86

Ok, I solved this myself. For those need to change timezone, 1st you need to change timezone in kapacitor server, then use this:

Time:               {{ .Time.Local.Format "Mon, Jan 2 2006 at 15:04:05 MST" }}

You can use golang format here

davistran86 avatar Jun 25 '18 10:06 davistran86

Time: {{ .Time.Local.Format "Mon, Jan 2 2006 at 15:04:05 MST" }}

Adding context, here is the golang time format documentation: https://golang.org/pkg/time/#example_Time_Format

RobHoman avatar Jul 19 '18 17:07 RobHoman

1st you need to change timezone in kapacitor server

@davistran86 How did you accomplish changing the timezone of the kapacitor server? I'm struggling to find kapacitor configuration that does this.

RobHoman avatar Jul 19 '18 17:07 RobHoman

then use this:

Time:               {{ .Time.Local.Format "Mon, Jan 2 2006 at 15:04:05 MST" }}

Use where?

rdxmb avatar Oct 05 '18 12:10 rdxmb

I would also like to know where this is set. I can't find anything in kapacitor.conf

scottwilson312 avatar Oct 09 '18 02:10 scottwilson312

I would also like to know where this is set. I can't find anything in kapacitor.conf

That would go into your Kapacitor alert rule, such as in a TICKscript or in Chronograf's built-in monitoring config tool if you use that.

dataviruset avatar Nov 05 '18 07:11 dataviruset

1st you need to change timezone in kapacitor server

@davistran86 How did you accomplish changing the timezone of the kapacitor server? I'm struggling to find kapacitor configuration that does this.

You can either change the TZ environment variable for the kapacitord process or change /etc/localtime. I'm running Kapacitor in Docker, so I added this to my run command: -e TZ=Asia/Shanghai

dataviruset avatar Nov 07 '18 10:11 dataviruset

That would go into your Kapacitor alert rule, such as in a TICKscript or in Chronograf's built-in monitoring config tool if you use that.

Could you please post a link how to do that? With https://community.influxdata.com/t/setting-time-zones/4974 this is not possible.

You can either change the TZ environment variable for the kapacitord process or change /etc/localtime. I'm running Kapacitor in Docker, so I added this to my run command: -e TZ=Asia/Shanghai

correct. I am doing this with mounting /etc/localtime from the host. But this has no effect for the kapacitor-timezone.

rdxmb avatar Nov 12 '18 09:11 rdxmb

The time variable and format string is put directly into the alert message (.details) in tickscript. So your message could look like this:

var details = '<p>
Website abc.com is <b>{{ if eq .Level "CRITICAL" }}DOWN{{ else }}BACK ONLINE{{ end }}</b>: HTTP response code of http://abc.com/ is {{ index .Fields "value" }}.
</p>
<p>
Time: {{ .Time.Local.Format "Mon, Jan 2 2006 at 15:04:05 CST" }}
</p>
<p>
For more details go to https://chronograf.abc.com/
</p>'

What I struggle with now is that chronograf still shows the alerts time in UTC. Very confusing, when browsing data, all times are adapted to your browser's time zone, but when listing alerts, time is in UTC.

hydrandt avatar Nov 12 '18 12:11 hydrandt