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.