Splunk Search

How to use a file to map results from fields to more meaningful names?

exocore123
Path Finder

I have log files that contain compCodes (over 500 different types of them). Is there a way I can create a mapping from a txt file, so when I query for the results, say:

stats count by compCodes

Can I use the file to map those and replace the compCodes to more meaningful names? (this is intended for an input populated drop-down search)

0 Karma
1 Solution

DalJeanis
Legend

Yes, you can create a a lookup csv file and use the | lookup command, or a join, or a whole bunch of other ways.

Assuming the file is mylookup.csv and has fields TheCode and TheDescription ...

| stats count as TheCount by compCodes
| lookup mylookup.csv TheCode as compCodes OUTPUT TheDescription as compDescription 
| table CompCodes compDescription TheCount

...or...

| stats count as TheCount by compCodes
| rename compCodes to TheCode
| inputlookup append=t mylookup.csv 
| stats values(*) as * by TheCode
| table TheCode TheDescription TheCount

View solution in original post

0 Karma

DalJeanis
Legend

Yes, you can create a a lookup csv file and use the | lookup command, or a join, or a whole bunch of other ways.

Assuming the file is mylookup.csv and has fields TheCode and TheDescription ...

| stats count as TheCount by compCodes
| lookup mylookup.csv TheCode as compCodes OUTPUT TheDescription as compDescription 
| table CompCodes compDescription TheCount

...or...

| stats count as TheCount by compCodes
| rename compCodes to TheCode
| inputlookup append=t mylookup.csv 
| stats values(*) as * by TheCode
| table TheCode TheDescription TheCount
0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...