Getting Data In

Search sourcetypes by forwarders

johnchamp
Explorer

I need to collect list of sourcetypes for each forwarder using search query. i can get forwarders list from metics.log and sourcetype list from licence_usage log seperately from _internal index.
Is there any way to get all the sourcetypes configured from each forwarder using single search query?

Tags (2)
0 Karma
1 Solution

lguinn2
Legend

Sort of - if the host name matches the forwarder name:

index="_internal" source="*license_usage.lo*" type!=*Summary 
| stats sum(b) as bytes by h st 
| rename h as host st as sourcetype 
| eval MB=round(bytes/(1024*2014),1) | fields - bytes

Hopefully, there will be some correlation between this and

index="_internal" source="*metrics*" group=tcpin_connections 
| stats sum(kb) as kb by hostname 
| eval MB =round(kb/1024,1) 
| rename hostname as host 
| fields - kb

If you wanted to combine these, you could do something like this

index="_internal" source="*license_usage.lo*" type!=*Summary 
| stats sum(b) as bytes by h st 
| rename h as host st as sourcetype 
| eval MB=round(bytes/(1024*2014),1) | fields - bytes
| join host type=outer [ search index="_internal" source="*metrics*" group=tcpin_connections 
    | stats sum(kb) as kb by hostname 
    | eval totalMBforwarded =round(kb/1024,1) 
    | rename hostname as host 
    | fields status host totalMBforwarded]

Any result that has a "totalMBforwarded" was a match. If the host name is being reset on the forwarder, you could also create a lookup table to define a mapping that could also be used in this search.

View solution in original post

0 Karma

somesoni2
Revered Legend

Another option could have been using |metasearch command

|metasearch host=* sourcetype=* | stats count by host, sourcetype

Here host name is the name of forwarder using which data is been indexed into splunk.

0 Karma

lguinn2
Legend

That gives a count of the events - and it is very fast - but it still has the problem that it doesn't map back to the actual forwarder name.

0 Karma

lguinn2
Legend

Sort of - if the host name matches the forwarder name:

index="_internal" source="*license_usage.lo*" type!=*Summary 
| stats sum(b) as bytes by h st 
| rename h as host st as sourcetype 
| eval MB=round(bytes/(1024*2014),1) | fields - bytes

Hopefully, there will be some correlation between this and

index="_internal" source="*metrics*" group=tcpin_connections 
| stats sum(kb) as kb by hostname 
| eval MB =round(kb/1024,1) 
| rename hostname as host 
| fields - kb

If you wanted to combine these, you could do something like this

index="_internal" source="*license_usage.lo*" type!=*Summary 
| stats sum(b) as bytes by h st 
| rename h as host st as sourcetype 
| eval MB=round(bytes/(1024*2014),1) | fields - bytes
| join host type=outer [ search index="_internal" source="*metrics*" group=tcpin_connections 
    | stats sum(kb) as kb by hostname 
    | eval totalMBforwarded =round(kb/1024,1) 
    | rename hostname as host 
    | fields status host totalMBforwarded]

Any result that has a "totalMBforwarded" was a match. If the host name is being reset on the forwarder, you could also create a lookup table to define a mapping that could also be used in this search.

0 Karma

johnchamp
Explorer

Thanks for you help. In my case host names are not matching with forwarders. I need to work on lookup table to do the mapping.

0 Karma

lguinn2
Legend

BTW - totalMVforwarded may always be larger than the sum of the sourcetypes from a host.

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...