Getting Data In

How to set checkpoint value in the rest api modular input?

soumyacharya91
Path Finder

I am trying to fetch the logs from a REST url. But when ever the url getting hit all the data is fetched from the url rather than the new one. So planning to implement some check point values to fetch only the data which are not indexed from that REST URL.

Is there any way to achieve this task. Any help or response will be very much appreciated.

bsayatovic_ipco
Engager

As far as I know, you can't.

The main script, rest.py, doesn't use the checkpoint directory. It doesn't write anything to it, and it doesn't read anything from it.

I've been trying my hand at adding a custom handler to it, and in the handlers, you can modify the req_args such as the query parameters. I was using that to advance my "start" query parameter to be the previous "end" parameter.

After the custom handler is done, the main script checks to see if any of the special req_arms (such as the query parameters) have changed, and if so, it updates its own stanza in the inputs.conf.

However, when its stanza changes, Splunk restarts the script. This in and of itself isn't the end of the world, but if you're using a polling interval, it basically ignores your sleep and just spawns a new script which executes its first poll right away. The end result is that you're polling every few seconds (as fast as my burdened workstation can do it).

I've not tried it, but I suspect that if you used the cron polling instead of the interval (though I don't think the REST Modular Input UI exposes it), it will pause before it queries for data since the cron pause is at the front of the script, not the end.

I've debated how far to try and bend the code because at some point I might be better off writing something from scratch.

0 Karma

45bpever
New Member

I have run into this exact same scenario. Short of modify the rest.py script to run only once, I'm not sure what else to do to fix this.

I am in the exact same boat as you are on this.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...