Splunk Dev

How long can I keep an open connection to Splunk search head via SDK?

rbarajas
Explorer

There's probably a better way to do this but what I'm trying to do is search on what has been indexed in the last few seconds, process those results and then search again on the next few seconds. I tried using a real-time search that got a bit complicated.

Pseudo, for you:

    service.connect(creds)

    earliestTime = getCurrentTime()
    sleep(X seconds)
    latestTime = getCurrentTime()

    While some condition is not met
       searchString = "search indexearliest=earliestTime indexlatest=latestTime stuff"
       ...
       searchAndProcessResults(service.oneshotsearch(searchString, jobargs))
       earliestTime=latestTime  //search up to the previous latest time
       latestTime=getCurrentTime()  //where there is at least an X seconds gap between earliest and latest time
    end While

I'm currently using a oneshot search and reusing the same service object that issues the connect call.

This design works but, long term I need to understand how long I can keep the one connection open before I start seeing errors (if any).

If you've had any success doing something like this via a realtime search on index time, I'd like to hear your suggestions too!

Thanks!

0 Karma
1 Solution

rbarajas
Explorer

According to Splunk devs, the session token is refreshed each time you submit a new search.
The token expiration is set to 60 minutes by default.
In my case, I don't expect to see any issues with session expiration, which was my motivation for this question.

View solution in original post

0 Karma

rbarajas
Explorer

According to Splunk devs, the session token is refreshed each time you submit a new search.
The token expiration is set to 60 minutes by default.
In my case, I don't expect to see any issues with session expiration, which was my motivation for this question.

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...