Knowledge Management

Run Collect command from python giving error

mehala12
Explorer

Hi
I am trying to run collect command from python script. Below is my command:

check_output("%s search \"| savedsearch splunkit_search_chart | addinfo | collect index=%s marker=\"searchname=search_chart1, cycle=1\" \" %s:%s" % (splunkCmdPath,idxName,USERNAME,PASSWORD))

The python script runs fine if I specify only one marker variable (searchname). When more than 1 marker variable is added, separated by comma, it gives me below error:
FATAL: Error in 'collect' command: Invalid argument: 'cycle=1'

Through splunk web, i could add any no. of variables using marker parameter. Did anyone face this error? Please let me know where am i going wrong.

Thanks
Mehala

Tags (2)
0 Karma

mehala12
Explorer

Hi
Thanks for your response. I am trying to add two parameters through marker field (searchname and test cycle number, basically tagging my events with additional key-value pairs). When I run it through web, it works fine:

| savedsearch test1 | collect index=testsummary marker="searchname=test1, cycle=1"

index=testsummary --> this has results of savedsearch "test1" with two additional fields in the event searchname and cycle. But why the same command through python script is failing to add the 2nd key-value pair.

thanks
Mehala

0 Karma

fdi01
Motivator
  • "cycle" is not a argument for the collect command
  • Optional arguments for the collect command are:

    addtime= | file= | spool= | marker= | testmode= | run-in-preview=

  • note: Option 'marker' should not be specified more than once.

0 Karma
Get Updates on the Splunk Community!

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

October 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Splunk Education Goes to Washington | Splunk GovSummit 2024

If you’re in the Washington, D.C. area, this is your opportunity to take your career and Splunk skills to the ...