Getting Data In

Splunk always one event behind

CaptSpify
Engager

I've got a scripted input that is giving me a bit of a headache. My index always be one line behind. For example:

My log looks like this:

2013-03-27      05:30:39 -  Event 1
2013-03-27      09:43:29 -  Event 2
2013-03-27      10:04:40 -  Event 3

But my index only shows 2 events.

2013-03-27      05:30:39 -  Event 1
2013-03-27      09:43:29 -  Event 2

If another line is added to the output:

2013-03-27      05:30:39 -  Event 1
2013-03-27      09:43:29 -  Event 2
2013-03-27      10:04:40 -  Event 3
2013-03-27      12:24:40 -  Event 4

Then my index shows 3 events:

2013-03-27      05:30:39 -  Event 1
2013-03-27      09:43:29 -  Event 2
2013-03-27      10:04:40 -  Event 3

It's like it's one-step behind all the time. I've got the script running in bash, and it shows the events correctly. I also don't think this is a multi-line issue, as each event is added as a separate item in the index correctly, it's not merging the lines.
I also added \n\r to the end of each result so it looked like:

2013-03-27      05:30:39 -  Event 1

2013-03-27      09:43:29 -  Event 2

2013-03-27      10:04:40 -  Event 3

But the index was still one line behind, only showing events 1 and 2 until event 4 came in.

Is there anything I can do in order to debug the input from the script to the index process?

0 Karma

CaptSpify
Engager

Sorry for the delay.

My interval is -1

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

Add SHOULD_LINEMERGE = false to your props. Splunk is waiting for the next event to see if it needs to merge it into the current one, so it can't index the current one until it sees that the next one contains a valid date.

CaptSpify
Engager

I've set the line-merge to false, and now it seems to be two events behind STDOUT. Color me confused.

Any other suggestions?

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

Or if you write to a file, a long enough (default 3 seconds) pause in new data written to a file will cause the file monitor to force an end to the event. There's no way in a scripted input to force the end (add a "_done" key) but you can do this in a modular input.

0 Karma

bmacias84
Champion

No, I would continue to use stdout. What is your scripted input interval also how busy is your indexer?

0 Karma

CaptSpify
Engager

I'm piping to stdout. Should it be going into a log-file?

0 Karma

bmacias84
Champion

Are piping to a log file and then reading the log file or our using the scripted input and piping stdout?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...