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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...