Getting Data In

Is there a way to list all reports using one specific sourcetype or index?

benjaminlin1019
Explorer

As title, Is there a way to list all the reports using one specific sourcetype or index?

Tags (3)
0 Karma

sideview
SplunkTrust
SplunkTrust

Well, one unreliable method would be to go to Settings > Searches and Reports, and use the search bar at the top right to search for sourcetype="foo". One problem is that some searches might use macros, or they might use wildcards in their sourcetype searchterms, or the search might not use quotes around the sourcetype value. Each of those scenarios would result in a search not matching although technically that search does itself match events of that sourcetype or index.

Also sometimes the admin section search can match a little too liberally (I think it searches the raw atomfeeds, so if you search for structural words in the api feeds like "EAI" or "value" or "values", you'll always get all the results to match =/ )

A different approach might be to use the rest search command to pull all the searches and reports out of the API and then filter on them.

| rest /services/saved/searches | table title search eai:acl.app eai:acl.owner eai:acl.sharing *

However basically all three problems persist - macros, wildcards and presence/absence of quotes.

We can deal with the quotes problem with an OR

| rest /services/saved/searches 
| table title search eai:acl.app eai:acl.owner eai:acl.sharing * 
| search search="*index=\"_internal\"*" OR search="*index=_internal*"

Otherwise, in theory we could deal with the macros problem by also using the rest command to pull out all the macros, use the append command to stick those on the end. Then make a multiple match regex to pull multivalue macro_name field out of our searches, normalize the macro_name vs "name" field with eval so they match. Then use eventstats by macro_name to roll up for every search, which macros it uses. Then we could make a big fake string-valued field that gloms together the raw search with the 0-n macros, and then filter against that constructed field. But that would be crazy. And we still wouldnt deal with the case where a search did things like sourcetype="access_*"

Short Answer:
if the searches dont use macros and dont use wildcards in sourcetype terms, yes!

On the other hand if they do use macros and/or wildcarded values, then no not really.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

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 GA in US-AWS!

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