Highlighted
SoporteBCN Valued Contributor.
Valued Contributor.
1834 views

How can I parse a dMMMyyyy date format + a HH:mm:ss time format into a timestamp (in a fixed-format log file of a flexconnector)?

Jump to solution

Hello,

I am having some troubles when programming a flexconnector:

The log file has a date with dMMMyyyy format (for example 1Ago2015), and a time with HH:mm:ss. So I am trying to have a timestamp like "1ago2015 21:02:36".

I have tried many ways and anyone worked:

1) I tried to use the function __createTimeStamp(date,time) and i get the error:

[FATAL][default.com.arcsight.agent.sdk.b.o][constructAlertFromValues]

com.arcsight.agent.parsers.operation.WrongArgumentsException: Unable to create time stamp with Date null and time null

Even though I have tried many combinations like using strings instead of Date and Time, the configuration that I am using for date and time is:

token[1].name=myDate

token[1].type=Date

token[1].format=dMMMyyyy

token[2].name=myTime

token[2].type=Time

token[2].format=HH:mm:ss


2) I tried the function __createOptionalTimeStampFromString(__concatenate(myDate, " ", myTime), dMMMyyy HH:mm:ss), having the following configuration:

token[1].name=myDate

token[1].type=String

token[2].name=myTime

token[2].type=String

It doesn't work because the format is not accepted by the function. I have thought to reformat the date to an accepted format, splitting it and joining it again, but the day, month and year are not separated by any delimiter and I don't know how to solve this.

3) I tried the function __parseMutableTimeStamp(__concatenate(myDate," ",myTime)) with the date and time as Strings and it won't work because of the format again...

Does anyone know how to solve this?

Many thanks and regards

0 Likes
1 Solution

Accepted Solutions
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: How can I parse a dMMMyyyy date format + a HH:mm:ss time format into a timestamp (in a fixed-format log file of a flexconnector)?

Jump to solution

Try this

Get both date and time as string

event.deviceCustomDate1=__safeToDate(__concatenate(_date," ",_time),"dMMMyyy HH\:mm\:ss")

------------------------------------
Please use the Like button below, if you find this post useful or mark it as an accepted solution if it resolves your issue.
0 Likes
6 Replies
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: How can I parse a dMMMyyyy date format + a HH:mm:ss time format into a timestamp (in a fixed-format log file of a flexconnector)?

Jump to solution

Try this

Get both date and time as string

event.deviceCustomDate1=__safeToDate(__concatenate(_date," ",_time),"dMMMyyy HH\:mm\:ss")

------------------------------------
Please use the Like button below, if you find this post useful or mark it as an accepted solution if it resolves your issue.
0 Likes
michael.selph Absent Member.
Absent Member.

Re: How can I parse a dMMMyyyy date format + a HH:mm:ss time format into a timestamp (in a fixed-format log file of a flexconnector)?

Jump to solution

Can you be a bit more specific on how the date works in your log file and post a few examples out of the logs? The example you have listed, "1ago2015 21:02:36", does not look like a valid timestamp. Did you mean 1AUG2015 21:02:36?


In the first example, it should be __createTimeStamp(myDate,myTime) as those are your token names. The full line should similar to:


event.endTime=__createTimeStamp(myDate,myTime)

0 Likes
michael.selph Absent Member.
Absent Member.

Re: How can I parse a dMMMyyyy date format + a HH:mm:ss time format into a timestamp (in a fixed-format log file of a flexconnector)?

Jump to solution

It just occurred to me that AGO was probably short for Agosto, so most likely that timestamp is correct.

0 Likes
SoporteBCN Valued Contributor.
Valued Contributor.

Re: How can I parse a dMMMyyyy date format + a HH:mm:ss time format into a timestamp (in a fixed-format log file of a flexconnector)?

Jump to solution

Oops, I missed this function...

This solved the problem. The function is the same as "__createOptionalTimeStampFromString" but you don't need to enter a common TimeStamp format.

Many Thanks !!


Kind regards.

0 Likes
SoporteBCN Valued Contributor.
Valued Contributor.

Re: How can I parse a dMMMyyyy date format + a HH:mm:ss time format into a timestamp (in a fixed-format log file of a flexconnector)?

Jump to solution

Indeed, ago is from Agosto.

The token names were correct in the function call, just a typing mistake.

The problem is already solved.

Thanks!

0 Likes
Nagaraja_1 Super Contributor.
Super Contributor.

Re: How can I parse a dMMMyyyy date format + a HH:mm:ss time format into a timestamp (in a fixed-for

Jump to solution

Hi,

 

I have following time stamp captured into string which needs to be converted to time stamp

04/Dec/2004:00:21:37 +0000

 

I cant use parseMutableTimeStamp  takes single string, which should be in one of these formats:

MMM dd HH:mm:ss

MMM dd HH:mm:ss.SSS zzz

MMM dd HH:mm:ss.SSS

MMM dd HH:mm:ss zzz

Any pointers on using __createOptionalTimeStampFromString ?

 

rgds

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.