Splunk Dev

How to generate logs from a custom Python script?

mrrci
Explorer

Hey there Splunk community. I'm new here and I would appreciate some help if it is possible.

So, I have to create a Splunk app that runs a Python script each day and it should generate random log events and index them into Splunk.

I'm not sure what's the best approach for this. I already wrote a custom script and successfully tested it by implementing it in Splunk (Data Inputs > Scripts...) but I don't know how to run it once a day and get x amount of log events.

I did use Cron schedule for scheduling it once a day but I only get one log event. Is there a way Splunk can run a script x amount of times at once?

Thank you!

Labels (1)
Tags (2)
0 Karma

Azeemering
Builder

Without going into a lot of other settings that you need to apply you can run a rudimentary inputs

Create a splunk app with a structure like this

yoursplunkapp\bin\yourpythonscripthere.py

yoursplunkapp\local\inputs.conf

[script://$SPLUNK_HOME/etc/apps/yoursplunkapp/bin/yourpythonscripthere.py]
interval = 30
index=foo
sourcetype=faa

 

This will run your script every 30 seconds. You can use seconds there or a cron expression.

0 Karma

mrrci
Explorer

I did experiment with Cron scheduling but it doesn't really solve my problem. As I said, I need to execute it multiple times at once. Let's say I need to run that script 100 000 consecutive times in a row. I didn't find anything to do it.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...