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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...