Splunk Search

Using rest with eval

C_Sparn
Communicator

Hello,

is there a possibility to use the |rest command with an eval like:

anysearch
|eval test = [rest /services/authentication/current-context
|rename username as user|return $user]

With this search I just get an empty field test. But why?
Greetings

Tags (3)
0 Karma
1 Solution

somesoni2
Revered Legend

Use it like this (run anywhere code). You're extracting string and its need to be within double quotes for eval to work.

|stats count |eval test = [|rest /services/authentication/current-context |eval user="\"".username."\""|return $user]

View solution in original post

somesoni2
Revered Legend

Use it like this (run anywhere code). You're extracting string and its need to be within double quotes for eval to work.

|stats count |eval test = [|rest /services/authentication/current-context |eval user="\"".username."\""|return $user]

C_Sparn
Communicator

WOW!
Thank you very much. That solved the problem.
Another possibility is to use:
"+" instead of "." in the eval
Greetings

Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...