Splunk Search

transpose on selected fields

Susha
Engager

Hi Team,

I want to transpose few fields as below ..

(index=abc OR index=def) category= * OR NOT blocked =0 AND NOT blocked =2
|rex field=index "(?<Local_Market>[^cita]\w.*?)_"
| stats count(Local_Market) as Blocked by Local_Market
| addcoltotals col=t labelfield=Local_Market label="Total"
| append [search (index=abc OR index=def) blocked =0 | rex field=index "(?<Local_Market>\w.*?)_"
| stats count as Detected by Local_Market
| addcoltotals col=t labelfield=Local_Market label="Total"]
| stats values(*) as * by Local_Market
| transpose 0 header_field=Local_Market column_name=Local_Market

here i want to add one column of date ( eval Time=strftime(_time,"%m/%d/%y")) which should not be transpose ..

date                    Local_Market    Total   a  b   c
05-09-2021       INDIA                     3      1  1  1
05-09-2021       UK                          5       3  2  0

Labels (1)
Tags (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

I don't follow. You want to have the date column left alone and all other columns transposed? It can't work even from simply algebraic point of view - you have two rows but three columns you want to transpose to rows.

Or is the table you presented the desired format?

Either way, I'd just add "static" column or row and transpose it if needed.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

_time does not exist due to the stats commands removing it from the event pipeline. Which value of time do you want to use? now() or earliest/latest from the search timeframe or something else?

0 Karma

Susha
Engager

@ITWhisperer  this report is scheduled for yesterday so i want to give yesterday date only .. like only 09-06-2021

Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| addinfo
| eval date=info_min_time
| fieldformat date=strftime(date,"%m-%d-%Y")
| fields - info_*
0 Karma

Susha
Engager

thanks a lot @ITWhisperer  its working perfectly .. just one more thing .. as of now date column is coming at last column .. how can we place it in first column ..

 

 

0 Karma
Get Updates on the Splunk Community!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...