Getting Data In

Why is my metadata search not returning expected results for hosts reporting in within certain time ranges?

lohit
Path Finder

Hi all,

I have written below metadata search to find the hosts which have reported yesterday, but not reporting in the last 1 hour.

| metadata type=hosts |eval current=now() |eval lastHour=relative_time(current,"-1h")  | eval yesterday=relative_time(now(), "-1d") | where ( recentTime>yesterday AND recentTime<lastHour) | convert ctime(current) as Current_Time, ctime(lastHour) as Last_Hour, ctime(recentTime) as Recent | table Current_Time,Last_Hour,Recent, host

This search is returning a list of hosts, but after I dig into these hosts, they seems to be reporting to their respective indexes which means the metadata search is giving me wrong results.

I start breaking up the search and excluded the recentTime&lt;lastHour from the where clause. Below is the resulting search:

| metadata type=hosts | eval current=now() |eval lastHour=relative_time(current,"-1h") | eval yesterday=relative_time(now(), "-1d") | where recentTime>yesterday  | convert ctime(current) as Current_Time, ctime(lastHour) as Last_Hour, ctime(recentTime) as Recent | table Current_Time,Last_Hour,Recent, host

This gives me a list of only 2 hosts, whereas in my environment, hundreds of hosts are reporting.

Not really sure what is happening.

Please help !!

Tags (2)
0 Karma

ss026381
Communicator

try this for specific indexes.

| metadata index=foo  index=bar  index=baz type=hosts

jacobwilkins
Communicator

You want your search to start with:

| metadata index=* type=hosts
0 Karma

lohit
Path Finder

I have huge number of indexes so i think i cannot use the metadata command. Could you let me the other approach about going after license logs to get this information.

0 Karma

lohit
Path Finder

i have huge indexes , so cannot afford to use index=*.

0 Karma

jacobwilkins
Communicator

How do you expect this to work? The metadatacommand reads the metadata stored inside the indexes...

If you only have a handfull of indexes you want to check, you can try this:

| metadata (index=foo OR index=bar OR index=baz) type=hosts

The other approach to base it on your license logs.

0 Karma

securitypaul
Explorer

This is incorrect:

| metadata (index=foo OR index=bar OR index=baz) type=hosts

For some reason, metadata seems to dislike OR. You can use:

| metadata index=this index=that

It works fine. It does mean that I'm unable to use macros that contain multiple indexes separated by OR with metadata.

 

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...