Getting Data In

Monitor is not working with Python-generated .csv

nick405060
Motivator

I have a .csv file that is being appended to every few minutes using Python. However, monitor reindexes everything each time it is written to, not just the new data. The filename and first 256 bytes are the same, so crcSalt shouldn't be an issue here.

How can I fix this?

0 Karma
1 Solution

nick405060
Motivator

Thanks to @micahkemp and @dwaddle for their assistance here. I posted this question to document the solution for the Splunk community.

micah:fez:  2:34 PM
if that file ever looks like it's less than 256 bytes, say right after it's re-created, but before it's written with the exact same content
2:35
splunk might be fast enough to catch it

duckfez:honk:  2:35 PM
p. sure it is, especially since I think inotify gets used (some) now

To solve, I just had Python write to a temp .csv and then I used shutil.move(temp.csv, myfinalfile.csv). It is possible that changing your Python code to write to the .csv using a instead of w may fix the issue as well.

View solution in original post

0 Karma

nick405060
Motivator

Thanks to @micahkemp and @dwaddle for their assistance here. I posted this question to document the solution for the Splunk community.

micah:fez:  2:34 PM
if that file ever looks like it's less than 256 bytes, say right after it's re-created, but before it's written with the exact same content
2:35
splunk might be fast enough to catch it

duckfez:honk:  2:35 PM
p. sure it is, especially since I think inotify gets used (some) now

To solve, I just had Python write to a temp .csv and then I used shutil.move(temp.csv, myfinalfile.csv). It is possible that changing your Python code to write to the .csv using a instead of w may fix the issue as well.

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...