All Apps and Add-ons

Error in 'eval' command: The expression is malformed. Expected ).

seriouscat
Explorer

Hi All,

Fairly new to Splunk and am attempting to write a query that checks for invalid login attempts and extracts ip and username. The interesting thing however is that sometimes host names appear in the 'ip' field instead of actual IP addresses. When this happens I attempt to do a DNS query to resolve to that host's IP address. It appears I'm missing a ')' in my eval statement, but I can't tell for the life of me where. It's not quite finished yet just trying to get the eval statement fixed.

The error I'm getting is this "Error in 'eval' command: The expression is malformed. Expected ). "

Any help is appreciated !

My Query:

sourcetype="xxxxx" "xxxxx" 
| eval lookupip = if (ip == rex "(?<ip>\d+\.\d+\.\d+\.\d+)", ip, lookup dnslookup clientip AS ip)
| table lookupip
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try like this (check the field that you want to extract from your dnslookup)

sourcetype="foo" "bar"
| lookup dnslookup clientip as ip OUTPUT ip as temp 
| eval ip=if(match(ip,"\d+\.\d+\.\d+\.\d+"),ip,temp) | table ip ...other fields..

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Try like this (check the field that you want to extract from your dnslookup)

sourcetype="foo" "bar"
| lookup dnslookup clientip as ip OUTPUT ip as temp 
| eval ip=if(match(ip,"\d+\.\d+\.\d+\.\d+"),ip,temp) | table ip ...other fields..

seriouscat
Explorer

This is great thank you! However, now I am receiving this error:

'Error in 'lookup' command: Could not find all of the specified destination fields in the lookup table. '

I've been scouring the interwebs, but haven't been able to come up with answer to why this happens so far. Will keep searching in the meantime.

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Do this and check the field name that you want to use if a hostname is specified instead of IP address. Once you find that replace "OUTPUT ip as temp" with "OUTPUT whateverfieldyoufound as temp"

| inputlookup dnslookup 
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 ...