- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Passing dynamic parameters in search running from cli
bsrikanthreddy5
Path Finder
02-14-2021
05:06 PM
Hi,
Is there was to dynamically pass a value like below in Splunk for running a search from cli.
I am trying to write a script to find event count from source files on HF and compare event to count indexed by running the below search
/opt/splunk/bin/splunk search 'index=* source=${c2_source}/*.gz | stats count' -uri 'https://<SH IP>:8089/' -auth admin:xxxxxxxxxx 2>/dev/null
Or is there way to achive using restapi commands
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
bsrikanthreddy5
Path Finder
02-18-2021
06:19 AM
I have implemented this way.
query="index=* source=${c2_source}/*.gz earliest=-1d@d | stats count"
event_count=$(/opt/splunk/bin/splunk search "$query" -uri 'https://<SH-IP>:8089/' -auth admin:password 2>/dev/null)
echo $event_count
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
isoutamo

SplunkTrust
02-18-2021
06:59 AM
When you are using “ instead of ‘ those variables etc will be expanded on command line.
