Refine your search:

I have multiple scripts that perform functions outside of Splunk to build XML on the fly. To run them its easiest to have Splunk actively schedule and execute these, what I wondered is what I should do with output. For debugging I am designing the scripts to return messages to signify the success or failure of their run however I don't want this input to be indexed into main or another custom index.

Would it be appropriate in this instance to direct this to _internal or perhaps another default splunk index for troubleshooting and system logging?

Just to re-iterate, the script will not be returning ANY output that I want to be able to search except for in the event of an apparent failure or need to debug.

asked 13 Sep '11, 01:31

Drainy's gravatar image

Drainy
8.4k618
accept rate: 25%


One Answer:

With scripted inputs, you could simply write out a status code via the standard error output stream. (Most scripting languages and unix utilities will do this by default when the encounter a problem or programmatic exception). Splunk will index any such "error" messages in the internal index automatically so you can track down problems with your scripted inputs.

If you are using python, you can write to standard error using the command like:

 sys.stderr.write("Job complete:  status=SUCCESS\n")

I use a search like this to periodically report any errors from my various scripted inputs: (I also filter out a bunch of Splunk's built-in scripted input errors that happen frequently, but I don't really care about.)

index=_internal sourcetype=splunkd component=ExecProcessor "message from" NOT (splunk-regmon OR splunk-wmi) | rex " - message from \"(?<inputscript>[^\"]+)\"" | rename inputscript as script | rex mode=sed "s/^.* - message from \"[^\"]+\" (.*)$/\1/" | transaction fields="host,source,script" maxpause=45s

One this that isn't clear: Are you using a scripted inputs simply for it's scheduling capabilities? You made it sound as though you aren't sending any data to the indexes by default. If this is correct, then I'd really suggest using a different scheduling mechanism and simply writing out your status information to a log file and then monitor that file with splunk. CRON or the windows task scheduler work well.

link

answered 13 Sep '11, 07:09

Lowell's gravatar image

Lowell ♦
11.2k91291
accept rate: 41%

Ta, just what I needed to know. Well its a bit of both, I am using the script to generate some extra things for Splunk based on the results of an external process so I really want it to be handled and executed by Splunk

(14 Sep '11, 01:23) Drainy
Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×159
×121
×26

Asked: 13 Sep '11, 01:31

Seen: 894 times

Last updated: 14 Sep '11, 01:23

Copyright © 2005-2012 Splunk Inc. All rights reserved.