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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...