Splunk Search

Generate a report where it will output table with different timings in columns

jcsvaldueza
New Member

I need to generate a report where it will output table with different timings in columns.

Trick part is logs captured fall under a unique transaction ID

 

index=<app> "Start Time" OR "End Time"

 

Sample Output Log (Note that this is under 1 transaction ID):

8:00 TransID "Start Time"

8:01 TransID "End Time"

8:30 TransID "Start Time"

8:31 TransID "End Time"

9:00 TransID "Start Time"

9:01 TransID "End Time"

 

Table should look like:

TransID StartTime1 EndTime1 Duration1 StartTime2 EndTime2 Duration 2 StartTime3 EndTime3 Duration3

0123 8:00 8:01 1:00 8:30 8:31 1:00 9:00 9:01 1:00

Labels (6)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

There are two separate challenges one about transform the presentation, the other getting the header into the desired order.  Here is my crack at it.  To begin, you need to extract TransID and the marker "Start time" or "End time".  How you do it is up to you because the data illustrated doesn't seem to be the raw format, at least not the timestamp.  I will take the illustrated format literally.

 

| rex "(?<time>\S+) (?<TransID>\S+) \"(?<marker>[^\"]+)"
| streamstats count by marker
| eval marker = marker . count
| xyseries TransID marker time
| transpose 0 header_field=TransID
| eval order = if(column LIKE "Start%", 1, 2)
| eval sequence = replace(column, ".+Time", "")
| sort sequence order
| fields - sequence order
| transpose 0 header_field=column column_name=TransID

 

So, the bigger challenge is to get desired order of headers.  I have to expense two tranposes.  If you do not need that strict order, things are much simpler.  Output from your mock data is

TransIDStart Time1End Time1Start Time2End Time2Start Time3End Time3
01238:008:018:308:319:009:01

Here is an emulation for you to play with and compare with real data

 

| makeresults format=csv data="_raw
8:00 0123 \"Start Time\"
8:01 0123 \"End Time\"
8:30 0123 \"Start Time\"
8:31 0123 \"End Time\"
9:00 0123 \"Start Time\"
9:01 0123 \"End Time\""
``` the above emulates
index=<app> "Start Time" OR "End Time"
```

 

 

Tags (2)
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...