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
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...