Refine your search:

Using the following search:

|metadata type=hosts |sort lastTime|convert ctime(lastTime)|fields host,lastTime

I am able to get a list of all hosts and when the last time splunk saw an event from that host. What I would like to do is create a saved search based off of this sort of search that I can use as an alert if lastTime is greater than some number of hours for any particular host. I was imagining something along the lines of

|metadata type=hosts |sort lastTime|convert ctime(lastTime)|fields host,lastTime |where NOW - lastTime > 12h

Or something along those lines. Is there a function that would give me NOW (current date/time) and if so, is this the right approach to get what I'm after?

asked 29 Apr '11, 11:24

chadroberts's gravatar image

chadroberts
192
accept rate: 100%


One Answer:

You're looking for the now() function in eval. The following search will alert you if there are any hosts that haven't sent any data for more than one hour (3600 seconds)

# compare last event's time to now 
|metadata type=hosts | eval since=now()-lastTime | search since>3600 |...

OR 
# compare indexer's time when last event came to now
|metadata type=hosts | eval since=now()-recentTime| search since>3600 |...
link

answered 29 Apr '11, 12:05

Ledion%20Bitincka's gravatar image

Ledion Bitincka ♦
1.5k36
accept rate: 34%

edited 29 Apr '11, 12:06

Awesome, exactly what I was looking for. Thanks!

(29 Apr '11, 12:14) chadroberts
Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×172

Asked: 29 Apr '11, 11:24

Seen: 463 times

Last updated: 29 Apr '11, 12:14

Copyright © 2005-2012 Splunk, Inc. All rights reserved.