Getting Data In

How do I write a search for devices not reporting to Splunk?

nuro
New Member

I need to get a report on devices that are not reporting to SPLUNK.
When I try with:

| metadata type=hosts | rename lastTime as "Last Event"| fieldformat "Last Event"=strftime('Last Event', "%c") 

I am getting only IP address. When I try with:

metatype = sourcetypes | rename lastTime as "Last Event"| fieldformat "Last Event"=strftime('Last Event', "%c") 

I am getting only source types.

What I need is sourcetype, IPs, and last event.

How can I create this search?

0 Karma

steveyz
Splunk Employee
Splunk Employee

metadata stores only information segregated by source, sourcetype, or host individually, so it will not have information necessary divided by both sourcetype and host. For that, you could use the metrics.log, or you can use tstats to query what is stored in the indexes.

| tstats max(_time) WHERE index=* GROUPBY sourcetype host
0 Karma

somesoni2
Revered Legend

There is a very nice app called "Splunk Health Overview" available in app base which does provides lot of similar reports. Have a look at the same. https://splunkbase.splunk.com/app/1919/

0 Karma

hagjos43
Contributor

This query might help. Assuming you are talking about devices that were once reporting into Splunk and have since stopped:

index="_internal" source="*metrics.lo*" group=tcpin_connections NOT eventType=* | eval sourceHost=if(isnull(hostname), sourceHost,hostname) | eval connectionType=case(fwdType=="uf","universal forwarder", fwdType=="lwf", "lightweight forwarder",fwdType=="full", "heavy forwarder", connectionType=="cooked" or connectionType=="cookedSSL","Splunk forwarder", connectionType=="raw" or connectionType=="rawSSL","legacy forwarder")| eval build=if(isnull(build),"n/a",build) | eval version=if(isnull(version),"pre 4.2",version) | eval os=if(isnull(os),"n/a",os)| eval arch=if(isnull(arch),"n/a",arch) | eval lastReceived = case(kb>0, _time) | eval seconds=30 | eval event_count= tcp_eps * seconds | bin _time span=10m | stats first(connectionType) as connectionType first(version) as version max(_time) as lastConnected max(lastReceived) as lastReceived sum(kb) as kbTotal  sum(event_count) as events sum(seconds) as secs by sourceHost _time | stats first(connectionType) as connectionType first(version) as version max(lastConnected) as lastConnected max(lastReceived) as lastReceived by sourceHost | eval LastReceived=strftime(lastReceived, "%Y/%m/%d %H:%M:%S") | fields sourceHost, connectionType, LastReceived | sort + LastReceived

I got this from here gosplunk.com

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Build the Future of Agentic AI: Join the Splunk Agentic Ops Hackathon

AI is changing how teams investigate incidents, detect threats, automate workflows, and build intelligent ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...