splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

ModularInput: make app where input is defined available to script

Open prigio opened this issue 8 years ago • 2 comments

When writing a modular input, the name of the application within which the input is defined is not made available to the modular input itself, even though it is available within the XML configurations through stdin. It would be nice to get an app key within the InputDefinition provided to the modular input's stream_events method.

Sample XML provided on STDIN:

<?xml version="1.0" encoding="UTF-8"?>
<input>
  <server_host>aws-service-mon-hfw-10-124-160-167</server_host>
  <server_uri>https://127.0.0.1:8089</server_uri>
  <session_key>.....</session_key>
  <checkpoint_dir>/opt/splunk/current/var/lib/splunk/modinputs/jmeter</checkpoint_dir>
  <configuration>
    <stanza name="jmeter://etc/apps/CA-jmeter/scenarios/test.jmx" app="CA-jmeter">
      <param name="debug">0</param>
      <param name="host">aws-service-mon-hfw-10-124-160-167</param>
      <param name="index">main</param>
      <param name="interval">900</param>
      <param name="sourcetype">jmeter_input</param>
    </stanza>
  </configuration>
</input>

The app could be parsed by altering the utils.py/parse_xml_data

https://github.com/splunk/splunk-sdk-python/blob/689998070b513a335efee1e4cc27fbf568b256f3/splunklib/modularinput/utils.py#L69

by adding the following:

data[child.get("name")]['app'] = child.get("app")

Thank you, Paolo

prigio avatar Apr 27 '18 16:04 prigio

Hi @prigio, thanks for the bug report. We're open to a pull request if you're interested in taking this on

shakeelmohamed avatar Apr 30 '18 17:04 shakeelmohamed

@prigio Please reopen this issue when you have a corresponding PR with the fix. Thanks.

skylasam avatar Jun 22 '18 17:06 skylasam