Skip to content

Commit 8da1679

Browse files
committed
Random numbers mod input example working
1 parent 5c8b256 commit 8da1679

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

examples/random_numbers/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
splunk-sdk-python random_numbers example
2+
========================================
3+
4+
This app provides an example of a modular input that generates a random number between the min and max values provided by the user during setup of the input.
5+
6+
To run this example locally run `SPLUNK_VERSION=latest docker compose up -d` from the root of this repository which will mount this example alongside the latest version of splunklib within `/opt/splunk/etc/apps/random_numbers` and `/opt/splunk/etc/apps/random_numbers/lib/splunklib` within the `splunk` container.
7+
8+
Once the docker container is up and healthy log into the Splunk UI and setup a new `Random Numbers` input by visiting this page: http://localhost:8000/en-US/manager/random_numbers/datainputstats and selecting the "Add new..." button next to the Local Inputs > Random Inputs. If no Random Numbers input appears then the script is likely not running properly, see https://docs.splunk.com/Documentation/SplunkCloud/latest/AdvancedDev/ModInputsDevTools for more details on debugging the modular input using the command line and relevant logs.

examples/random_numbers/bin/random_numbers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
from __future__ import absolute_import
1818
import random, sys
1919
import os
20+
# NOTE: splunklib must exist within random_numbers/lib/splunklib for this
21+
# example to run! To run this locally use `SPLUNK_VERSION=latest docker compose up -d`
22+
# from the root of this repo which mounts this example and the latest splunklib
23+
# code together at /opt/splunk/etc/apps/random_numbers
2024
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
2125

2226
from splunklib.modularinput import *

0 commit comments

Comments
 (0)