Getting Data In

Service item.update causes modular input to restart

aronsemle
New Member

In my modular input I want to update a configuration setting between runs so I don't poll for the same data again and again. The code I use to do this is below. It's using the splunklib.client library (https://docs.splunk.com/DocumentationStatic/PythonSDK/1.1/client.html#splunklib.client.Service.login) to make a REST connection to Splunk, using the session held by the modular input, it grabs the config section and calls item.update to update the query_param.

The call to item.update causes the entire modular input to reload... and in the logs I get a "Winsock error 10054", most likely because of the reload.

I'm on Splunk 8.0.1 running Python3. I can't find any documentation on this behavior. I tried not using the SESSION_TOKEN, and instead connecting with username/password, but same issue. I also tried adding service.logout at the end, but that code never executes. Is this expected?

            try:
                args = {'host':'localhost','port':SPLUNK_PORT,'token':SESSION_TOKEN}
                service = Service(**args)

                item = service.inputs.__getitem__(STANZA[len(APP_NAME) + 3:])
                item.update(query_params = dictionary_to_params(url_args))

            except Exception as e:
                logging.error("Error trying to update args: %s" % str(e))

One last note. In the logs I get the following warning. I assume this is being causes by the app restarting.

03-16-2020 08:52:25.232 -0400 WARN HttpListener - Socket error from 127.0.0.1:56292 while accessing /servicesNS/nobody/launcher/data/inputs/my_app/my_data_input/: Winsock error 10054

0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...