Getting Data In

identifying sourcetypes by index

cphair
Builder

Hello,

I'd like to display all sourcetypes available for each index in my environment. Unfortunately, metadata type=sourcetypes doesn't preserve the index name, and I want to be able to run it on the entire set of indexes on whatever instance the search runs on (i.e. I don't want to hardcode index=a OR index=b, etc, into the search). I tried getting fancy:


| rest /services/data/indexes | rex field=id mode=sed "s/.\/(\w+)$/\1/" | search id!="_" | fields id | map search="|metadata type=sourcetypes index=$id$ | stats list(sourcetype) as sourcetype | eval whereFrom=$id$ | table sourcetype whereFrom"

...but the second $id$ is always null. Can anyone give me a good way to list all indexes and the sourcetypes they contain? As a bonus, if you can explain why my map command doesn't work as expected, I'd appreciate it.

Tags (3)
1 Solution

somesoni2
Revered Legend

Try this

|metasearch index=* sourcetype=* | stats count by index, sourcetype | fields - count

View solution in original post

Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...