Splunk Search

Fields Creation Problem ??

rakesh_498115
Motivator

Hi

I have created a Field Called "DESTINATION" in this field i have the values like this..

Banglore
Bombay
Karantaka
Kerala
....
...
etc.

Now i wanted this list of fields to be broken down in to two sets

1.One Set that contains all the names that start with "K" and 2.other set that contains all the names that start with "B" .

i have tried using like this..

myseach | rex field=DESTINATION "^K(?)" | rex field=DESTINATION "^B(?)" | table B_Cities,K_Cities

but didnt work ?

Please help..

Tags (2)
0 Karma

ayme
Splunk Employee
Splunk Employee

Various ways to do it. I would probably use like() function from eval. You could put it in within a stats command:

myseach | stats values(eval(if(like(DESTINATION,"K%"), DESTINATION,NULL))) as begins_with_K, values(eval(if(like(DESTINATION,"B%"), DESTINATION,NULL))) as begins_with_B
0 Karma

Ayn
Legend

You have empty matching groups. You probably want something like .* in them in order to actually match anything.

rakesh_498115
Motivator

can we Create fields by Searching the strings.ie i have a fields which has certain values like "rammohan,tejaram,sriram,rakesh,...etc"..

Now can i create a Field Such that it extracts only the names from the above field who has the value "ram"

i.e Field2 should contain rammohan,tejaram,sriram only..

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...