Splunk Search

Is there a possibility to write an event to splunk index source type through SPL?

shahid285
Path Finder

I have an requirement where the user would like to store the data to a source type of an index. and would be modifying the same data, on repeated intervals.
I would like to know, whether , there is a possibility to write an event to splunk index's source type through SPL.
I am restricted to use any kind of SDK to the max to achieve this, hence expecting the solution through this.

Thanks in advance,

Mohammed Shahid Nawaz

Tags (1)
0 Karma

nickhills
Ultra Champion

The collect command will let you do this:
https://docs.splunk.com/Documentation/Splunk/7.2.5/SearchReference/Collect

If my comment helps, please give it a thumbs up!
0 Karma

shahid285
Path Finder

Hi @nickhills
Thank you for your input, much appreciated! 🙂
I tried to follow the splunk doc, but i was unable to either find a proper example to push the data to the index , nor, was i able to construct a working query with collect command.

I have ended up with this query, hope you may help me here.

| eval _raw = "{\"avgPercentage\":\"70\", \"MaxPercentage\":\"90\"}" | table _raw| collect index="_internal" sourcetype="_internal" run_in_preview=true

also i tried like the below one too.

| makeresults | eval tp = "{\"maxPercentage\":\"70\", \"percentage\":\"90\"}" | return $tp | collect index="xxxx-aci" file=$timestamp$.stash sourcetype="xxxxxx" run_in_preview=true

I have created a new source type for my existing index to store those above percentage values.
None of this is showing either any error or when searched with the index and sourcetype any event results

I hope you can help me in correcting my query.

Thanks again!
Mohammed Shahid Nawaz

0 Karma

shahid285
Path Finder

Guys, Still waiting for update on the solution, need it badly. Please help 🙂

0 Karma

somesoni2
Revered Legend

You can write to Splunk via search command collect via SPL.
https://docs.splunk.com/Documentation/Splunk/7.2.5/SearchReference/Collect

However, you won't be able to modify the data (data once indexed can't be modified). You may want to use a lookup table OR kv-store (preferred) for your requirement.

0 Karma

shahid285
Path Finder

Hi @somesoni2,
Thank you for your input, much appreciated! 🙂
I tried to follow the splunk doc, but i was unable to either find a proper example to push the data to the index , nor, was i able to construct a working query with collect command.

I have ended up with this query, hope you may help me here.

| eval _raw = "{\"avgPercentage\":\"70\", \"MaxPercentage\":\"90\"}" | table _raw| collect index="_internal" sourcetype="_internal" run_in_preview=true

I have created a new source type for my existing index to store those above percentage values.

I hope you can help me in correcting my query.

Thanks again!
Mohammed Shahid Nawaz

0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...