Getting Data In

Parse Time From Splunk Forwarder Logs when not send in Key=value pair

MayankSplunk
Path Finder

Following are the logs I'm sending to Splunk. Can someone please guide me how to time subtract time if I group by id?
Since I'm not sending time in Key=value pair I don't know what column to pull.

2014-11-24 14:25:29,873 id=98d57314-740f-11e4-95a8-fe0b46e8751a, fileSize=0, duration=0, status=uploading
2014-11-24 14:26:04,931 id=e5772c54-740e-11e4-95a8-fe0b46e8751a, fileSize=0, duration=103000, status=completed

0 Karma
1 Solution

MayankSplunk
Path Finder

Hi, you see time 2014-11-24 14:25:29,873 2014-11-24 14:26:04,931 in two different row. I would like to subtract them.

View solution in original post

0 Karma

musskopf
Builder

The timestamp should be automatic placed inside the field "_time". Splunk store time as seconds, but if you use it names "_time" it'll automatic format for you.

index=bla "your search" | table _time, id

Remember that Splunk stores the Time in seconds, but it'll auto-format to a more human readable if the field name is "_time". For example:

index=bla "your search" | eval time2=_time | table _time, time2, id

But you might be looking to do something like:

index=bla "your search" | transaction id | table _time, id, duration, status

Have a look on the transaction command documentation, there are plenty of option...

0 Karma

MayankSplunk
Path Finder

Hi, you see time 2014-11-24 14:25:29,873 2014-11-24 14:26:04,931 in two different row. I would like to subtract them.

0 Karma

MayankSplunk
Path Finder

eval eventTime=_time did the trick , thanks for all the help

0 Karma

MayankSplunk
Path Finder

@musskopf I have follow up question for same query - can you take a look

http://answers.splunk.com/answers/194858/remove-unique-rows-from-table.html

0 Karma

MayankSplunk
Path Finder

transaction is working fine because it gives me multiple eventCount based on # of similar IDs

Problem is _time is always of the first item that we have in group while using transaction.

0 Karma

musskopf
Builder

ok, so add | eval eventTime=_time before the transaction command:

(status="uploading" OR status="completed") | eval eventTime=_time | transaction id | table id, _time, eventTime

But as I mentioned, Splunk will show it as seconds, you should be able to convert it back using somenthing like: | convert timeformat="%F %T" ctime(eventTime) at the end.

0 Karma

MayankSplunk
Path Finder

Using t give null and _time still pulls only 1 item

0 Karma

musskopf
Builder

If you take the transaction command off, is your search returning duplicated values on the id column? The transaction command should just "group" all the events having the same "id" and create multi-value fields for cases where the same field has distinct values.

http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction

0 Karma

MayankSplunk
Path Finder

Yes, I mistakenly removed third row which had same ID as first. Let me try your approach.

0 Karma

MayankSplunk
Path Finder

Sorry but _time is not getting me multiple _time when grouped by id,

(status="uploading" OR status="completed") | transaction id | table id, _time

above query gives only one result time, am I doing something wrong?

P.S : Don't have enuf point to reply to your answer below

0 Karma

musskopf
Builder

Try using:

(status="uploading" OR status="completed") | transaction id mvlist=t | table id, _time

or

(status="uploading" OR status="completed") | transaction id mvlist=_time | table id, _time

0 Karma

musskopf
Builder

Ok, now things changed a bit... You might are looking for the command transaction, which will add the field duration that is exactly the time from the first event till the last event. But in your example, the IDs are different. Should they be the same?

0 Karma

norbert_hamel
Communicator

Hi, I have to admit that I do not really understand the question. What do you want to subtract? Could you drop an example based on the logs?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...