Splunk Search

Change table representation

anisgupt
New Member

I have a table as follows:

CN|Lev|ref1|ref2|ref3|ref4|ref5|ref6
cn1|1|1|2|3|4|||
cn2|2|||||5|6|

The representation required is:

CN|Lev|Ref|Count
cn1|1|ref1|1
cn1|1|ref2|2
cn1|1|ref3|3
cn1|1|ref4|4
cn2|2|ref5|5
cn2|2|ref6|6

Tags (1)
0 Karma

ashajambagi
Communicator

Hi @anisgupt ,

Please try below query and let me know if it helps:

| makeresults 
| eval CN="cn1", Lev="1", ref1="1", ref2="2", ref3="3", ref4="4", ref5="", ref6="" 
| append 
    [| makeresults 
    | eval CN="cn2", Lev="2", ref1="", ref2="", ref3="", ref4="", ref5="5", ref6="6" ] 
| eval cr=mvzip(CN,Lev,"-") 
| fields - _time Lev CN 
| untable cr Ref Count 
| rex field=cr "(?P<CN>[^\,].+)-(?P<Lev>.+)" 
| table CN Lev Ref Count| where Count>0

ashajambagi
Communicator

@anisgupt Can you please accept the answer if it helped with your issue!

0 Karma
Get Updates on the Splunk Community!

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...