Getting Data In

Custom search command Values for these required options are missing: ...

Unige2021
Loves-to-Learn

I need to pass to my python custom search command two values: and y.

I found some examples where it's shown this:

 

 

x = Option(require=True, validate=validators.Fieldname())
y = Option(require=True, validate=validators.Fieldname())

 

 

 

Now I simply run my script by simply entering my_script x=50, y=25

Unfortunately I get this errors:

Illegal value: x=50
Illegal value: y=25
Values for these required options are missing: x, y

 

I cannot find neither the problem nor anyone who is facing this problem.

The code I copied from is an example taken from this url: Create a custom Splunk search commands with Python3 | HoldMyBeer (holdmybeersecurity.com)

 

Thank you in advance! 

Labels (1)
Tags (1)
0 Karma

s2_splunk
Splunk Employee
Splunk Employee

I am not an expert on this, but it seems like the way you have it implemented, the code will check if the values for x and y are field names, when you likely want to validate that they are integers.

Can you try changing to this and see if that helps:

x = Option(require=True, validate=validators.Integer())
y = Option(require=True, validate=validators.Integer())

If it does, specifying my_script x="abc" y="def" should throw an error.

As you currently have it, validation would support my_script x=some_event_field  y=some_other_event_field

At least that's my understanding on how it works. You can find a list of all implemented validators here. 

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 ...