AppD Archive

Using standard Time Format

Kay_Koedel
Path Finder

We want to uses email templates and report the event time

Is it possible to use standard timeformat instead of american specific timeprinting?

The international standard is defined here ISO_8601

Example:

Hard to understand american specific: Wed Feb 01 08:00:02 UTC 2017

International standard: 2017-02-01T08:00:02

0 Karma
1 Solution

Saradhi_Pothara
Communicator

Hi Kay,

You could use the following apache velocity template to convert the time into the format you need.

If using html body:

#set( $String = '' )

$String.format('%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS%Tp ', $latestEvent.eventTime)

If using text body:

#set( $String = '' )##
$String.format('%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS%Tp ', $latestEvent.eventTime)

Sample Output:

2017-02-07T13:14:02PM

Let us say you do not need AM/PM at the end of the date, the format is:

#set( $String = '' )
$String.format('%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS ', $latestEvent.eventTime)

Sample Output:

2017-02-07T13:23:06

http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#dt

In your case the on-premise controller I believe is on UTC and you just want to convert from one format to another format. So above works.

As mentioned by Ivan currently it is not possible to convert from one timezone to another, for example from PST to UTC.

Regards,
Saradhi

View solution in original post

0 Karma

Saradhi_Pothara
Communicator

Hi Kay,

You could use the following apache velocity template to convert the time into the format you need.

If using html body:

#set( $String = '' )

$String.format('%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS%Tp ', $latestEvent.eventTime)

If using text body:

#set( $String = '' )##
$String.format('%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS%Tp ', $latestEvent.eventTime)

Sample Output:

2017-02-07T13:14:02PM

Let us say you do not need AM/PM at the end of the date, the format is:

#set( $String = '' )
$String.format('%1$tY-%1$tm-%1$tdT%1$tH:%1$tM:%1$tS ', $latestEvent.eventTime)

Sample Output:

2017-02-07T13:23:06

http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#dt

In your case the on-premise controller I believe is on UTC and you just want to convert from one format to another format. So above works.

As mentioned by Ivan currently it is not possible to convert from one timezone to another, for example from PST to UTC.

Regards,
Saradhi

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

Hi Kay,

I took a look at the documentation, and I found this:

https://docs.appdynamics.com/display/PRO42/Predefined+Templating+Variables, specifically the section "Info Classes for Templating Variables."

I don't think you can modify this variable -- but there is a section that says "If these predefined variables do not meet all your needs, you can define your own custom variables for use in these templates in the Create Template window. Do not use any of the predefined variable names for your custom variables."

However, there doesn't appear to be any steps or best practices provided to do this. I'll dig a bit further but let me know if this information at least gets you started.

Cody

Community Manager

 

0 Karma

Ivan_Merrill
Explorer

This has been a complaint of ours for a long time now. It seems such a simple fix, let us set a timezone for our SaaS controller, that would solve all manner of other problems (working out cron expressions for different timezones for health rules is always fun, especially when the docs incorrectly state PDT carte blanche when it's actually PZT). 

It's a very strange decision to say the tool helps companies quickly diagnose issues but then enforce companies to start translating timestamps as a first activity on anything they do.  This is counterintuitive to me!

0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...