Getting Data In

Pulling logged in users via REST API

hiddenkirby
Contributor

How would one get a list of all the users logged in via the API

In a ruby script i tried this... (POST seems odd for this type of thing) got the idea from http://www.splunk.com/base/Documentation/4.1/Developer/RESTCreateSearch

def list_users_logged_in
  xml = splunk_ssl_post_request("/services/authentication/httpauth-tokens", nil, {'authorization' => "Splunk #{session_key}"})
  puts xml
end

which obvs doesn't operate the same as the list_jobs

>> require 'splunk'
=> ["SplunkClient"]
>> client = SplunkClient.new
=> #<SplunkClient:0x7ff442d44fc0>
>> client.list_users_logged_in
<response>
<messages>
<msg type="ERROR">In handler &apos;&apos;: Cannot perform action &quot;POST&quot; without a target name to act on.</msg>
</messages>
</response>
=> nil

So obviously i'm missing something fundamental. Any help would be appreciated.

Tags (1)
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

You can just make a GET request to that URL to get a list of the tokens.

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee

You can just make a GET request to that URL to get a list of the tokens.

hiddenkirby
Contributor
0 Karma

hiddenkirby
Contributor

where can i post example ruby code for others to see?

0 Karma

hiddenkirby
Contributor

lol thank you..

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...