Splunk Search

Splunk Hosts metadata correlation with index

Mag2sub
Path Finder

Im using a metadata type=hosts query to output hosts that have not logged data using recenttime
However i dont see the index name being output by this..is there anyway to correlate the host to its index in a query that starts with |metadata type=hosts ?
thanks!

Tags (2)

somesoni2
Revered Legend

This works with Splunk 5 but is on slower side

|eventcount summarize=false index=* | table index | map maxsearches=100 search="|metadata type=hosts  index=$index$ | eval index=\"$index$\""
0 Karma

Mag2sub
Path Finder

Its so much on slower side does not look feasible for us...any inputs /modifications to enhance performance appreciated

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

You could use this to emulate metadata:

| tstats latest(_time) latest(_indextime) count where index=* by host index

martin_mueller
SplunkTrust
SplunkTrust

metasearch is a different command from metadata.

http://docs.splunk.com/Documentation/Splunk/5.0.4/SearchReference/metasearch

0 Karma

Mag2sub
Path Finder

unless i misunderstand when i run metadata type=hosts...index name is not a key value pair returned

is a metadata search not a metasearch ..sorry if i got that wrong

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

metasearch does output the index.

0 Karma

Mag2sub
Path Finder

Thanks ... unless i misundertood something recenttime is indextine for metaseach on hosts ...but metasearch do not output the index names on which they run...i need to be able to read the results to act on it and it needs to have the index name...

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Yeah, metasearch with _indextime should be about twice as fast as regular stats... if your forwarders basically send current data then you could get along with using _time as a workaround.

0 Karma

Ayn
Legend

I've filed an ER for metasearch to output _indextime in results. With that, you could quickly grab these stats.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Anything tstats can do with indexes can be done with stats:

index=* | stats latest(_time) latest(_indextime) count by host index

However, that may be slow, very slow, or glacial. You can of course speed things up by running this query regularly over a short timerange and storing the data in a lookup: http://blogs.splunk.com/2011/01/11/maintaining-state-of-the-union/

0 Karma

Mag2sub
Path Finder

yes on splunk 5.0.4 unfortunately...is there some way we can do the same ? i just need to find the latest time each host has logged using metadata but also output what index it belongs to ...

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

This runs against indexes... on Splunk 6. Are you still on version 5?

0 Karma

Mag2sub
Path Finder

Hmmm...this throws error expecting a namespace ...tsidxstats error...missing "FROM" keyword to specify namespace
does this work against indexes ? above error suggests it runs only against tsidxstats of tscollect

0 Karma
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...