Splunk Search

How to check if new hosts get added to instance & get alerted?

abhijit_mhatre
Path Finder

The number to hosts have increased in our instance & we want to check which ones are the new ones added. Also we want to get alerted on a weekly basis if a new host gets added. Can anyone let me know the query to check the newly added hosts?

Thanks in Advance.

0 Karma
1 Solution

inventsekar
SplunkTrust
SplunkTrust

i am not sure if there is any direct way available for this one.. but, we can find out the first message from a host and approximately, we can assume that date as the host added date.
i am querying only head 100 hosts(oldest 100 hosts).. we can use tail 100 to get most recent 100 hosts.

| metadata type=hosts | head 100
 | fields host firstTime lastTime totalCount
 | sort -totalCount
 | fieldformat firstTime=strftime(firstTime,"%x %X")
 | fieldformat lastTime=strftime(lastTime,"%x %X")

View solution in original post

inventsekar
SplunkTrust
SplunkTrust

i am not sure if there is any direct way available for this one.. but, we can find out the first message from a host and approximately, we can assume that date as the host added date.
i am querying only head 100 hosts(oldest 100 hosts).. we can use tail 100 to get most recent 100 hosts.

| metadata type=hosts | head 100
 | fields host firstTime lastTime totalCount
 | sort -totalCount
 | fieldformat firstTime=strftime(firstTime,"%x %X")
 | fieldformat lastTime=strftime(lastTime,"%x %X")

inventsekar
SplunkTrust
SplunkTrust

Hi abhijit, if you want to query date wise, lets say, new hosts added last week, then -
tested and working fine..

 | metadata type=hosts |eval SevenDaysBack = relative_time(now(), "-7d@d") 
 | where firstTime > SevenDaysBack 
 | eval hostAdded=strftime(firstTime, "%d-%m-%Y %H:%M") 
 | table host, hostAdded | sort hostAdded 

alt text

0 Karma

abhijit_mhatre
Path Finder

Thanks @inventsekar for your help 🙂

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...