Splunk Search

adding lookup or eval to transforms.conf

fk319
Builder

I would like to do an eval on every log entry, from a certian sourcetype. In this case I have a real number that I would like to quantize.

I also have a series of IPs that I would like to group by location. I am using a lookup at search, but I am only interested one or two locations for a search. Some of the IP ranges are /24, so I would also like to use wildcards.

I would like to make these changes when the log is loaded and not at search time so that I can search by location. Do I do this in transforms.conf? or is there another location?

Tags (1)
0 Karma
2 Solutions

bwooden
Splunk Employee
Splunk Employee

You can not automatically call an eval out of the box using transforms.conf. You could create a macro though to minimize your typing. Instead of typing

... | eval some_var=<some eval opeartion>

you would type

... `macro_name`


Wildcards are not currently supported in lookups but you do have a few options.

  1. You can create a scripted input to do it.
  2. You can use event types.
  3. You can leverage the search language (note: the below example would need to be updated for different mask bits)

    ... | rex field=ip "(?\d{1,3}.\d{1,3}.\d{1,3}.)" | strcat cidr_test "0/24" cidr_test | eval cidr=if(cidrmatch(cidr_test,ip),cidr_test,null) | where isnotnull(cidr) | lookup cidr OUTPUT location | search location="home_office"

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee

You can not do this at index time (except by preprocessing your data before it even gets to Splunk).

You can configure automatic lookups that execute a script that can do whatever operations you need on the incoming data however.

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee

You can not do this at index time (except by preprocessing your data before it even gets to Splunk).

You can configure automatic lookups that execute a script that can do whatever operations you need on the incoming data however.

bwooden
Splunk Employee
Splunk Employee

You can not automatically call an eval out of the box using transforms.conf. You could create a macro though to minimize your typing. Instead of typing

... | eval some_var=<some eval opeartion>

you would type

... `macro_name`


Wildcards are not currently supported in lookups but you do have a few options.

  1. You can create a scripted input to do it.
  2. You can use event types.
  3. You can leverage the search language (note: the below example would need to be updated for different mask bits)

    ... | rex field=ip "(?\d{1,3}.\d{1,3}.\d{1,3}.)" | strcat cidr_test "0/24" cidr_test | eval cidr=if(cidrmatch(cidr_test,ip),cidr_test,null) | where isnotnull(cidr) | lookup cidr OUTPUT location | search location="home_office"

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...