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
SplunkTrust
SplunkTrust

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
SplunkTrust
SplunkTrust

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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...