Splunk Search

Search 2 tables with limited characters

VipeRafajzat
Explorer

Hi All,

 

I would like to search for a specific 7 character length of data from 2 tables. Within these 2 tables I have multiple data length, so it varies from 1 to 20, but I need only those which are exactly 7 digits/characters long.

After I  filtered for these 7 digits from these 2 tables, I would like to put them into a common name/ID which I can use for my lookup.

Do you have any idea how can I do it and use with the above lookup?

The lookup search what I am using is:

index=myindex| lookup my_lookup field1 OUTPUTNEW mylookup_name | eval field1=IF(ISNULL(mylookup_name),field1,field2) | rename field1 as "NAME" | chart count by "NAME" | sort -count

 

Do you have any idea how can I do it and use with the above lookup?

Labels (1)
0 Karma
1 Solution

VipeRafajzat
Explorer

Hi Rich,

 

Thanks for your reply. What I did and solve my problem is the following based on your suggestion:

| eval XY = mvappend(field1, field2) | where len(xy_number)=7 

 

Thank you!

View solution in original post

0 Karma

Richfez
SplunkTrust
SplunkTrust

Well, I have some ideas but you never mention *which* field you want the length of (and to limit to ones that are 7 characters). 

Anyway, no worries, it's just a single eval to get the length, and you can search again after you make that eval if you want to filter it down to just ones of length 7.

The eval to create a new field called 'fieldLength', which contains the number of characters in the field "fieldX"

| eval fieldLength=len(<fieldX>)

I recommend adding that and checking that it does what you want (which probably means you want to drop the "chart" command off temporarily).

If you want to filter it to the ones that are length 7, easily enough you'd just do like the above only add a line to search.

| eval fieldLength=len(<fieldX>)
| search fieldLength = 7

You'll have to modify it to fit your fields, but that's about all it should take.

Happy Splunking!

-Rich

VipeRafajzat
Explorer

Hi Rich,

 

Thanks for your reply. What I did and solve my problem is the following based on your suggestion:

| eval XY = mvappend(field1, field2) | where len(xy_number)=7 

 

Thank you!

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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...