Building for the Splunk Platform

Doing my first scripted lookup, trying a basic hello world ... where do I start?



Trying to make a basic scripted python lookup. The examples and tutorials were just way over my head. So trying to do something simpler. I coped the example file and tried to simplify the problem a little. What I am aiming to do here is pass a field called 'mystring' and get back a field called 'myoutput'.

I am passing hello as the field value for mystring and expecting world as the value in the new field myoutput.

When I execute this I get the following

| head 1
| eval mystring = "hello"
| lookup mylookup mystring

I get" Script execution failed for external search command '/opt/splunk/etc/apps/TA-myapp/bin/'."

here is my python.

#!/usr/bin/env python

import csv
import sys

def main():

    if len(sys.argv) != 3:
        print("Usage: python [mystring] [myoutput]")

    # always passing hello as a eval mystring = "hello"
    mystring = sys.argv[1]
    myoutput = sys.argv[2]

    infile = sys.stdin
    outfile = sys.stdout

    r = csv.DictReader(infile)
    header = r.fieldnames

    w = csv.DictWriter(outfile, fieldnames=r.fieldnames)

    for result in r:
            result[mystring] = "hello"
            result[myoutput] = "world"

Labels (1)
0 Karma



Have you configured transforms.conf for external lookup ?


external_cmd = mystring
fields_list = mystring,myoutput
0 Karma
Get Updates on the Splunk Community!

Streamline Data Ingestion With Deployment Server Essentials

REGISTER NOW!Every day the list of sources Admins are responsible for gets bigger and bigger, often making the ...

Remediate Threats Faster and Simplify Investigations With Splunk Enterprise Security ...

REGISTER NOW!Join us for a Tech Talk around our latest release of Splunk Enterprise Security 7.2! We’ll walk ...

Introduction to Splunk AI

WATCH NOWHow are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. ...