Go to your $SPLUNK_HOME/etc/system/bin and look for the script "external_lookup.py". That's a very simple example.
For you to understand, the lookup script receives the data via PIPE in CSV format and return the same data with the lookup fields populated, for example (on Linux):
Create a file /tmp/test.csv with the content:
host,ip
google.com,
microsoft.com,
Run the commands (adapt to your environment):
export SPLUNK_HOME=/apps/splunk
export PYTHONPATH=$SPLUNK_HOME/lib/python2.7
cat /tmp/test.csv | $SPLUNK_HOME/bin/python $SPLUNK_HOME/etc/system/bin/external_lookup.py host ip
You should see an CSV output like that:
host,ip
google.com,131.242.32.38
google.com,131.242.32.42
(...)
google.com,131.242.32.37
microsoft.com,134.170.185.46
microsoft.com,134.170.188.221
The output above is how the lookup works... it injects a CSV with all fields, including the empty ones and your script will be responsible to handle it and fill the gaps.
Now if you decide to use any Python library, make sure it exists inside $SPLUNK_HOME/lib/python2.7, and Splunk will run all Python scripts using it's own Python and not the Python the your OS. If you can't find a required library you might need to compile it using an Python 2.7 and copy there... you might get around by copying the OS one there, but I already have trouble doing that as my OS uses Python 2.6.
Hope it helps!
... View more