Getting Data In

Question on monitoring file

darksky21
Path Finder

Hi i am trying to monitor some file in var/log on ubuntu. There is 4 file (auth.log,auth.log.1,auth.log.2.gz,auth.log.3.gz)

when i tried the code below it work

[monitor:///var/log/auth.log]
sourcetype= authlog
index = test
disabled = 0

but this does not work

[monitor:///var/log/auth.log.1]
sourcetype= authlog
index = test
disabled = 0

Why is that so? is there anything wrong with it?

Tags (3)
0 Karma
1 Solution

darksky21
Path Finder

Ayn is right. In the end i have to write a script to index all the diff auth.log instead of using monitor

View solution in original post

0 Karma

darksky21
Path Finder

Ayn is right. In the end i have to write a script to index all the diff auth.log instead of using monitor

0 Karma

kristian_kolb
Ultra Champion

You have been given advice as to why that might be a bad idea. If you are absolutely sure that this is what you want... good luck.

kristian_kolb
Ultra Champion

It could be a permissions issue, check splunkd.log. Make sure that the account running splunkd has read access to /var/auth/auth.log.

The .log.n and .log.n.gz files are just rotated versions of the auth.log, so if you don't need to index the old events, you can just stick with monitoring auth.log. When the current auth.log rotates to auth.log.1, you have already indexed all those events, so you do not need to monitor the rotated files explicitly.

EDIT: typo/bad thinking.

/Kristian

Ayn
Legend

No, you don't need to do that - there are ways to make Splunk index them anyway, but very often this is NOT what you want, because it will make Splunk read the same data multiple times and I don't see why you would want that.

0 Karma

Ayn
Legend

If the auth.log.1, auth.log.2, auth.log.3 etc files are just rotated files that have already been indexed, Splunk won't index them a second time. Might that be what's happening in your case?

darksky21
Path Finder

Hi gpradeepkuma... thx for the reply. i have tried that but it does not seem to work.It only monitor auth.log for some reason. Maybe splunk does not allow monitoring for those file?

0 Karma

pradeepkumarg
Influencer

You can use auth.log* to monitor all the versions and use blacklist attribute to ignore gz ones

blacklist = (\.(tar|gz|bz2|tar.gz|tgz|tbz|tbz2|zip|z)$)

0 Karma

darksky21
Path Finder

Hi thx for the reply. is there anyway to monitor all the different version of auth.log?

0 Karma

kristian_kolb
Ultra Champion

Ooops. I thought I saw a semicolon, and something in my thinking process short-circuited. Colon is supposed to be there, definitely...

Edited answer to include some more clever guessing...

0 Karma

sdaniels
Splunk Employee
Splunk Employee

The colon is ok, no?

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...