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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...