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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...