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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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