Splunk Search

query to grab the metadata of the host entered by the user

kteng2024
Path Finder

Hello,

Can someone please help me to build a query that will display hostname , IP address , last reported by the forwarder.
If i use the index= star host= star , that will be too much load on the indexers . Is there any better way to grab those metrics.

0 Karma

mayurr98
Super Champion

hey try this

| tstats max(_time) as lastReported WHERE index=* by host | eval LastReported=strftime(lastReported,"%m/%d/%y %H:%M:%S") | table LastReported host  | join host [ search index=_internal hostname=* | stats count by sourceIp hostname | rename hostname as host]

Let me know if it works!

0 Karma

somesoni2
Revered Legend

You can use tstats to get host and last reported by forwarder.

| tstats max(_time) as lastReported WHERE index=* by host 

If you've dnslookup external lookup setup, you add that to above query to get the IP address.

0 Karma

kteng2024
Path Finder

Thank you for the reply. i have edited the query to convert epoch time to human readable format.Since we don't have external dnslookup , i am relying on internal index. But query couldn't display the sourceIP.

| tstats max(_time) as lastReported WHERE index=* by host | eval c_time=strftime(lastReported,"%m/%d/%y %H:%M:%S") | table c_time host | join [ search index=_internal hostname=* | stats count by sourceIp | table sourceIp ]

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 ...