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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...