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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...